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


PHP Application::getLocator方法代码示例

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


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

示例1: testCanRetrieveLocatorOnceSet

 /**
  * @dataProvider validLocators
  */
 public function testCanRetrieveLocatorOnceSet($locator)
 {
     $app = new Application();
     $app->setLocator($locator);
     $this->assertSame($locator, $app->getLocator());
 }
开发者ID:rafalwrzeszcz,项目名称:zf2,代码行数:9,代码来源:ApplicationTest.php

示例2: setupView

 /**
  * Sets up the view integration
  *
  * Pulls the View object and PhpRenderer strategy from the locator, and 
  * attaches the former to the latter. Then attaches the 
  * DefaultRenderingStrategy to the application event manager.
  * 
  * @param  Application $application 
  * @return void
  */
 protected function setupView($application)
 {
     // Basic view strategy
     $locator = $application->getLocator();
     $events = $application->events();
     $staticEvents = StaticEventManager::getInstance();
     $view = $locator->get('Zend\\View\\View');
     $phpRendererStrategy = $locator->get('Zend\\View\\Strategy\\PhpRendererStrategy');
     $defaultViewStrategy = $locator->get('Zend\\Mvc\\View\\DefaultRenderingStrategy');
     $view->events()->attachAggregate($phpRendererStrategy);
     $events->attachAggregate($defaultViewStrategy);
     // Error strategies
     $noRouteStrategy = $locator->get('Zend\\Mvc\\View\\RouteNotFoundStrategy');
     $exceptionStrategy = $locator->get('Zend\\Mvc\\View\\ExceptionStrategy');
     $events->attachAggregate($noRouteStrategy);
     $events->attachAggregate($exceptionStrategy);
     // Template/ViewModel listeners
     $arrayListener = $locator->get('Zend\\Mvc\\View\\CreateViewModelFromArrayListener');
     $injectTemplateListener = $locator->get('Zend\\Mvc\\View\\InjectTemplateListener');
     $injectViewModelListener = $locator->get('Zend\\Mvc\\View\\InjectViewModelListener');
     $staticEvents->attach('Zend\\Stdlib\\Dispatchable', 'dispatch', array($arrayListener, 'createViewModelFromArray'), -80);
     $staticEvents->attach('Zend\\Stdlib\\Dispatchable', 'dispatch', array($injectTemplateListener, 'injectTemplate'), -90);
     $events->attach('dispatch.error', array($injectViewModelListener, 'injectViewModel'), -100);
     $staticEvents->attach('Zend\\Stdlib\\Dispatchable', 'dispatch', array($injectViewModelListener, 'injectViewModel'), -100);
     // Inject MVC Event with view model
     $mvcEvent = $application->getMvcEvent();
     $viewModel = $mvcEvent->getViewModel();
     $viewModel->setTemplate($defaultViewStrategy->getLayoutTemplate());
     // Inject MVC Event view model as root view model
     $renderer = $phpRendererStrategy->getRenderer();
     $modelHelper = $renderer->plugin('view_model');
     $modelHelper->setRoot($viewModel);
 }
开发者ID:navtis,项目名称:xerxes-pazpar2,代码行数:43,代码来源:Bootstrap.php


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