我在factories.yml文件中设置了以下配置...
all:
mailer:
param:
transport:
class: Swift_SendmailTransport
param:
command: /usr/sbin/sendmail -oi -t
正如here所描述的那样,...to克服了“双点”问题。
当我运行下面的代码时...
$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);
...inside一个动作,一切都按预期运行。但是,当我从任务内部运行相同的代码时,我得到一个致命错误- PHP Fatal error: Call to undefined method getCommand
-因为SwiftMailer使用的是默认传输类,而不是factories.yml配置中指定的Swift_SendmailTransport
类。
你知道为什么symfony任务中没有加载factories.yml配置吗?我该如何着手解决这个问题?
发布于 2010-08-24 16:59:02
即使您只有一个应用程序,您的任务也不知道要加载哪个应用程序的factories.yml。您需要像这样传递一个应用程序参数:
php symfony namespace:task --application=frontend
要在您的任务中使用默认应用程序,请按如下方式更新配置:
protected function configure()
{
$this->addOptions(array(
new sfCommandOption('application', null, sfCommandOption::PARAMETER_REQUIRED, 'The application name', 'frontend'),
));
}
https://stackoverflow.com/questions/3549110
复制相似问题