Symfony 1.4.6 loading factories .yml configuration from task

I have the following set of settings in my factory.yml file ...

all: mailer: param: transport: class: Swift_SendmailTransport param: command: /usr/sbin/sendmail -oi -t 

... to overcome the double point problem as described here .

When I run the following code ...

 $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 the action, everything works as expected. But when I run the same code from within the task, I get a fatal error - PHP Fatal error: Call to undefined method getCommand - because SwiftMailer uses the default transport class and not the Swift_SendmailTransport class, as specified in the factories.yml configuration.

Any ideas why the factory.yml configuration is not loading into the symfony task and how can I solve this problem?

+4
source share
1 answer

Your task does not know which factory.yml applications to load - even if you have only one application. You need to pass the application parameter as follows:

 php symfony namespace:task --application=frontend 

To have a default application in your task, update the configuration as follows:

 protected function configure() { $this->addOptions(array( new sfCommandOption('application', null, sfCommandOption::PARAMETER_REQUIRED, 'The application name', 'frontend'), )); } 
+6
source

All Articles