0

在呈现请求后,如何找到 phalcon 用于单个请求的所有视图?我想知道动作视图、控制器布局和主布局。

4

1 回答 1

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

于 2013-01-13T02:56:12.913 回答