JSPHPSymfony
JSPHPSymfony

Reputation: 31

SLOTS in Actions?

I'm just learning Symfony - with bought paper-book, electronic pdfs accessible for free on the net and the internet itself. I must admit I never saw so poorly written guides about certain topic (including all of the mentioned above). They often lack in basic details.

I don't know if it's just me missing some information, but I haven't seen clear indication on where SLOTS can be used in Symfony. I took by default that I can use them anywhere. So after quick check in VIEW (and saw that they were working), I got down to the work and used them in ACTION method ( executeIndex() ).

And then my many-hours-wasted run began. After tones of pages viewed on the net, trying different things (like enforcing Symfony to autoload classes, which should be autoloaded) and checking even unprobable ways to find any solution to make slots work, I eventually came to realisation that SLOTS can be used only in VIEWS in Symfony.

Is this correct, or still am I missing something?

Upvotes: 2

Views: 1377

Answers (2)

Nachtgold
Nachtgold

Reputation: 548

You can use slots also in your actions:

$this->getResponse()->setSlot('mySlot', $myValue);

or

$this->getResponse()->setSlot('myPartialSlot', $this->getPartial('myPartial'));

This is explained in the chapter Slots (http://www.symfony-project.org/book/1_2/07-Inside-the-View-Layer)

Upvotes: 4

Jody
Jody

Reputation: 1743

Yes, you are correct. Slots are part of the view. They're just templates that can use variables that were defined in the action.

This should be a helpful page if you haven't found it already: http://www.symfony-project.org/book/1_2/07-Inside-the-View-Layer

The Symfony documentation is relatively good. You should check out some of the Zend Framework docs for a real treat :)

Upvotes: 1

Related Questions