当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Controller_Action_Helper_ViewRenderer::setInflector方法代码示例

本文整理汇总了PHP中Zend_Controller_Action_Helper_ViewRenderer::setInflector方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Controller_Action_Helper_ViewRenderer::setInflector方法的具体用法?PHP Zend_Controller_Action_Helper_ViewRenderer::setInflector怎么用?PHP Zend_Controller_Action_Helper_ViewRenderer::setInflector使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Controller_Action_Helper_ViewRenderer的用法示例。


在下文中一共展示了Zend_Controller_Action_Helper_ViewRenderer::setInflector方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getViewRenderer

 /**
  * Retrieves the view renderer object
  *
  * @return Zend_Controller_Action_Helper_ViewRenderer|null
  * @throws Glitch_Application_Resource_Exception
  */
 public function getViewRenderer()
 {
     if (null === $this->_viewRenderer) {
         // Pull in the front controller; bootstrap first if necessary
         $this->_bootstrap->bootstrap('FrontController');
         $front = $this->_bootstrap->getResource('FrontController');
         // Ignore if no view renderer is to be used
         if ($front->getParam('noViewRenderer')) {
             return null;
         }
         // Get existing renderer, if any, or create a new one
         $this->_viewRenderer = Zend_Controller_Action_HelperBroker::hasHelper('viewRenderer') ? Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer') : new $this->_className(null, $this->getOptions());
         // Dynamic class loading; perform sanity check
         if (!$this->_viewRenderer instanceof Zend_Controller_Action_Helper_ViewRenderer) {
             throw new Glitch_Application_Resource_Exception('Class is not a valid view renderer instance');
         }
         // Register the view as the default view for handling view scripts
         $this->_bootstrap->bootstrap('View');
         $view = $this->_bootstrap->getResource('View');
         $this->_viewRenderer->setView($view);
         // It is paramount to set this base path spec: ZF otherwise uses its own
         // spec, causing it to create a path to a conventional ZF-style directory
         $this->_viewRenderer->setViewBasePathSpec(':module/' . Glitch_View::PATH_VIEW);
         // Set empty inflector settings: all path translations are handled by the custom dispatcher
         $inflector = new Zend_Filter_Inflector();
         $inflector->addRules(array(':module' => array(), ':controller' => array(), ':action' => array()));
         $this->_viewRenderer->setInflector($inflector, true);
         if (!Zend_Controller_Action_HelperBroker::hasHelper('viewRenderer')) {
             Zend_Controller_Action_HelperBroker::addHelper($this->_viewRenderer);
         }
     }
     return $this->_viewRenderer;
 }
开发者ID:nstapelbroek,项目名称:Glitch_Lib,代码行数:39,代码来源:Viewrenderer.php

示例2: testCustomInflectorUsesViewRendererTargetWhenPassedInWithReferenceFlag

    public function testCustomInflectorUsesViewRendererTargetWhenPassedInWithReferenceFlag()
    {
        $this->request->setModuleName('bar')
                      ->setControllerName('index')
                      ->setActionName('test');
        $controller = new \Bar\IndexController($this->request, $this->response, array());
        $controller->setHelperBroker($this->broker);

        $this->helper->view->resolver()->addPath($this->basePath . '/_files/modules/bar/views');


        $inflector = new Filter\Inflector('test.phtml');
        $inflector->addRules(array(
            ':module'     => array('Word\CamelCaseToDash', 'stringToLower'),
            ':controller' => array('Word\CamelCaseToDash', new \Zend\Filter\Word\UnderscoreToSeparator(DIRECTORY_SEPARATOR), 'StringToLower'),
            ':action'     => array(
                'Word\CamelCaseToDash',
                new Filter\PregReplace('/[^a-z0-9]+/i', '-'),
                'StringToLower'
            ),
        ));
        $this->helper->setInflector($inflector, true);

        $this->helper->render();
        $body = $this->response->getBody();
        $this->assertContains('Rendered index/test.phtml in bar module', $body);
    }
开发者ID:alab1001101,项目名称:zf2,代码行数:27,代码来源:ViewRendererTest.php


注:本文中的Zend_Controller_Action_Helper_ViewRenderer::setInflector方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。