Retrieving the result set from the action
In ,Chapter 2Developing Our Application, we briefly looked at the application logic in the actions class. We have now looked at the business logic—creating a custom query, calling this function, and then passing the results to the template so that we can display the information. Going back into the menuAction class in apps/frontend/modules/menu/actions/actions.class.php, append the index action with the following:
/**
* Executes index action
*
*/
public function executeIndex()
{
//Get all out all of the shakes
$this->milkshakeArray = MilkShakePeer::getAllShakes();
return sfView::SUCCESS;
}
Looking at this code snippet, we make a call to our MilkShakePeer model and use our static function getAllShakes(). As all the peer functions provide static methods, we use the scope resolution operator (::) to access our static function.
When giving the template access to variables, you must use $this as Symfony uses PHP magic functions widely. Assigning variables...