Evidently seems this isn't something that can be set globally via YAML (which is sad).
You can set it as stated in the documentation per view, i.e. in view.yml:
indexSuccess:
layout: layout
has_layout
But this is pretty laborious if you have many actions and against DRY concepts.
Note: Setting the values for all
takes no effect.
$this->setLayout('layout')
Does work within an action, but again in my scenario this would need to be set in every action, again not particularly DRY.
Thus, I chose to extend sfActions and bind it into the preExecute method.
class myActions extends sfActions {
public function execute($request) {
if($request->getRequestFormat() == 'xml') {
$this->setLayout('layout');
}
return parent::execute($request);
}
}
Sorts the problem globally if you make sure all your actions extend myActions
instead of sfActions
, if you want to do it for all formats you could make use of the preExecute
method instead, but I wanted to make use of the sfWebRequest
to ensure I don't try and force layouts onto prospective other formats I may add such as JSON.