ZF-Commons / zfc-rbac

Role-based access control module to provide additional features on top of Zend\Permissions\Rbac
BSD 3-Clause "New" or "Revised" License
181 stars 111 forks source link

UnauthorizedStrategy does not render templates #290

Open thestanislav opened 9 years ago

thestanislav commented 9 years ago
  1. In UnauthorizedStrategy templates are never rendered, because view model is overridden later by InjectViewModelListener. See https://github.com/zendframework/zf2/blob/master/library/Zend/Mvc/View/Http/InjectViewModelListener.php We should attach listener with less priority than -100
  2. We should add model as child of layout model. See how things are done here: https://github.com/zendframework/zf2/blob/master/library/Zend/Mvc/View/Http/InjectViewModelListener.php#L47 The code should look somehow like this:
....
$model = new ViewModel();
$model->setTemplate($this->getTemplate());
if ($event->getError() && $event->getViewModel() instanceof ClearableModelInterface) {
     $event->getViewModel() ->clearChildren();
}
$event->getViewModel()->addChild($model);
....
atukai commented 9 years ago

Have the same problem

danizord commented 9 years ago

@thestanislav can you provide a PR? Tell me if I can help.