i had a bit of fun when trying to get partial/url helpers working in my
task, i had to put the context logic at the top of my execute method like
this:

  protected function execute($arguments = array(), $options = array())
  {
    // initialize the database connection
    $this->configuration =
ProjectConfiguration::getApplicationConfiguration($arguments['application'],
$options['env'], true);
    $context = sfContext::createInstance($this->configuration);
    $databaseManager = new sfDatabaseManager($this->configuration);
    $connection =
$databaseManager->getDatabase($options['connection'])->getConnection();


On Wed, Feb 9, 2011 at 5:49 PM, Daniel Lohse
<[email protected]>wrote:

> Look at creating a custom environment that is similar to the test
> environment. For this to work, take a look at symfony's own factories.yml
> for the test environment — they are substituting the prod and dev
> environment's session handler.
>
> You'll find the factories.yml in (guessing here :)):
> lib/vendor/symfony/lib/config/.../factories.yml. You can also take a look at
> your app's factories.yml, should be in there, too.
>
> Cheers, Daniel
>
> Sent from my iPhone4
>
> On Feb 9, 2011, at 3:59 PM, Basil Hussain <
> [email protected]> wrote:
>
> > I am writing a custom task for my Symfony project. In it I am sending
> > a bunch of e-mails generated using content from the database. To
> > compose the e-mail message, I am using an instance of sfPartialView so
> > that I can use the same partial template for each message and
> > substitute in the data.
> >
> > The sfPartialView constructor requires a context to be passed to it,
> > which I am creating using the task's configuration, like so:
> >
> > $context = sfContext::createInstance($this->configuration);
> > $view = new sfPartialView($context, 'global', 'fooMailTemplate', '');
> > foreach($dbStuff as $x) {
> >    $view->setPartialVars(array(
> >        'foo' => doSomething($x->foo),
> >        'bar' => $x
> >    ));
> >    // Render $view, send mail, etc here...
> > }
> >
> > The problem is that when I execute the task, I get a lot of warnings
> > from sfSessionStorage about how it can't start the session, send
> > cookies or write session data on session close. This is because the
> > user I am running the task with doesn't have permission to write to
> > that part of the filesystem. These warnings don't stop the task doing
> > its job, but are annoying as they fill the task's output with needless
> > garbage.
> >
> > Ideally, I would like to turn session storage off for the task's
> > context, but I don't see how I can do that. Is there a way to do that?
> >
> > --
> > If you want to report a vulnerability issue on symfony, please send it to
> security at symfony-project.com
> >
> > You received this message because you are subscribed to the Google
> > Groups "symfony users" group.
> > To post to this group, send email to [email protected]
> > To unsubscribe from this group, send email to
> > [email protected]
> > For more options, visit this group at
> > http://groups.google.com/group/symfony-users?hl=en
>
> --
> If you want to report a vulnerability issue on symfony, please send it to
> security at symfony-project.com
>
> You received this message because you are subscribed to the Google
> Groups "symfony users" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/symfony-users?hl=en
>



-- 
-----------------------------------------------------------------
http://www.linkedin.com/in/justendoherty - LinkedIn
http://www.twitter.com/phpchap - Twitter
http://www.anotherwebdeveloper.com - Portfolio

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en

Reply via email to