Hi Daniel

Yes this is a typo in my post code should look like the following


public function setup()
{
  // ...

  $this->dispatcher->connect('template.filter_parameters', array(
    $this, 'templateFilterParameters'
  ));

}

public function templateFilterParameters(sfEvent $event, $parameters)
{
  $parameters['my_helper_object'] = MyHelperObject::getInstance();

  return $parameters;

}

and the MyHelperObject::getInstance() method looks like:

public static function getInstance()
    {
        if(!isset ( self::$instance ))
        {
            $c = __CLASS__;
            self::$instance = new $c;
        }
        return self::$instance;
    }

On Oct 12, 6:19 pm, Richtermeister <nex...@gmail.com> wrote:
> Might just be a typo, but you're calling "getInstance" while the
> method you show is called "createInstance"..
>
> Daniel
>
> On Oct 11, 1:43 pm, wickass <wick...@gmail.com> wrote:
>
> > Im trying to pass a single instance of a helper object to the view by
> > making use of "template.filter_parameters" event. However it seems
> > that for every partial the object gets instantiated again, is there a
> > way around this?
>
> > This is the code that I have in my Pluginconfiguration, Am I just
> > being stupid.
>
> > public function setup()
> > {
> >   // ...
>
> >   $this->dispatcher->connect('template.filter_parameters', array(
> >     $this, 'templateFilterParameters'
> >   ));
>
> > }
>
> > public function templateFilterParameters(sfEvent $event, $parameters)
> > {
> >   $parameters['my_helper_object'] = MyHelperObject::getInstance();
>
> >   return $parameters;
>
> > }
>
> > and the MyHelperObject::getInstance() method looks like:
>
> > public static function createInstance()
> >     {
> >         if(!isset ( self::$instance ))
> >         {
> >             $c = __CLASS__;
> >             self::$instance = new $c;
> >         }
> >         return self::$instance;
> >     }
>
> > Any advice would be apreciated :)

-- 
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 symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en

Reply via email to