【发布时间】:2011-04-02 17:21:09
【问题描述】:
我的 factory.yml 文件中设置了以下配置...
all:
mailer:
param:
transport:
class: Swift_SendmailTransport
param:
command: /usr/sbin/sendmail -oi -t
...克服here 所述的“双点”问题。
当我运行以下代码时...
$mailer = $this->getMailer();
$message = $mailer->compose();
$message->setTo('foo@bar.com');
$message->setFrom('foo@bar.com');
$message->setSubject('Testing');
$message->setBody(
$mailer->getRealtimeTransport()->getCommand(),
'text/plain'
);
$mailer->send($message);
...在一个动作中,一切都按预期工作。但是,当我在任务中运行相同的代码时,我会收到一个致命错误 - PHP Fatal error: Call to undefined method getCommand - 因为 SwiftMailer 使用的是默认传输类,而不是 factory.yml 配置中指定的 Swift_SendmailTransport 类。
任何想法为什么没有在 symfony 任务中加载 factory.yml 配置,以及我该如何解决这个问题?
【问题讨论】:
标签: php configuration symfony1 yaml factories