【问题标题】:How do I find all the views used by Phalcon?如何找到 Phalcon 使用的所有视图?
【发布时间】:2013-01-13 00:27:59
【问题描述】:

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

【问题讨论】:

    标签: php phalcon


    【解决方案1】:

    您可以将监听器附加到视图组件:

    <?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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-02-01
      相关资源
      最近更新 更多