如何在呈现请求后找到phalcon用于单个请求的所有视图?我想知道Action视图,控制器布局和Main布局。
答案 0 :(得分:2)
您可以将侦听器附加到视图组件:
<?php
//Setting up the view component
$di->set('view', function() {
// Create an event manager
$eventsManager = new Phalcon\Events\Manager();
// Attach a listener for type 'view'
$eventsManager->attach('view', function($event, $view) {
if ($event->getType() == 'beforeRenderView') {
echo $view->getActiveRenderPath(), PHP_EOL;
}
});
$view = new \Phalcon\Mvc\View();
$view->setViewsDir('../app/views/');
// Bind the eventsManager to the view component
$view->setEventsManager($eventsManager);
return $view;
}, true);
此处有更多信息:http://docs.phalconphp.com/en/latest/reference/views.html#view-events