Symfony 1.4.6 从任务加载factories.yml配置
我在 Factory.yml 文件中设置了以下配置...
all:
mailer:
param:
transport:
class: Swift_SendmailTransport
param:
command: /usr/sbin/sendmail -oi -t
...以克服描述的“双点”问题 此处。
当我运行以下代码时...
$mailer = $this->getMailer();
$message = $mailer->compose();
$message->setTo('[email protected]');
$message->setFrom('[email protected]');
$message->setSubject('Testing');
$message->setBody(
$mailer->getRealtimeTransport()->getCommand(),
'text/plain'
);
$mailer->send($message);
...在操作内一切都按预期工作。但是,当我从任务内部运行相同的代码时,出现致命错误 - PHP Fatal error: Call to undefined method getCommand - 因为 SwiftMailer 使用的是默认传输类,而不是 Swift_SendmailTransport 类在factories.yml 配置中指定。
知道为什么 Factory.yml 配置没有加载到 symfony 任务中,以及如何解决这个问题吗?
I have the following configuration set in my factories.yml file...
all:
mailer:
param:
transport:
class: Swift_SendmailTransport
param:
command: /usr/sbin/sendmail -oi -t
...to overcome the 'double dot' issue as described here.
When I run the following code...
$mailer = $this->getMailer();
$message = $mailer->compose();
$message->setTo('[email protected]');
$message->setFrom('[email protected]');
$message->setSubject('Testing');
$message->setBody(
$mailer->getRealtimeTransport()->getCommand(),
'text/plain'
);
$mailer->send($message);
...inside an action everything works as expected. But when I run the same code from inside a task, I get a fatal error - PHP Fatal error: Call to undefined method getCommand
- because SwiftMailer is using the default transport class and not the Swift_SendmailTransport
class as specified in the factories.yml configuration.
Any ideas why the factories.yml configuration isn't loaded in a symfony task, and how I can go about solving this issue?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的任务不知道要加载哪个应用程序的factory.yml - 即使您只有一个应用程序。您需要传递这样的应用程序参数:
要在您的任务中拥有默认应用程序,请像这样更新您的配置:
Your task doesn't know which application's factories.yml to load - even if you only have one app. You need to pass an application parameter like this:
To have a default app in your task, update your configure like this: