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


PHP ServiceManager::setAllowOverride方法代码示例

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


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

示例1: setup

 public function setup()
 {
     parent::setup();
     $pathDir = getcwd() . "/";
     $config = (include $pathDir . 'config/application.config.php');
     $this->serviceManager = new ServiceManager(new ServiceManagerConfig(isset($config['service_manager']) ? $config['service_manager'] : array()));
     $this->serviceManager->setService('ApplicationConfig', $config);
     $this->serviceManager->setFactory('ServiceListener', 'Zend\\Mvc\\Service\\ServiceListenerFactory');
     $moduleManager = $this->serviceManager->get('ModuleManager');
     $moduleManager->loadModules();
     $this->routes = array();
     $this->modules = $moduleManager->getModules();
     foreach ($this->filterModules() as $m) {
         $moduleConfig = (include $pathDir . 'module/' . ucfirst($m) . '/config/module.config.php');
         if (isset($moduleConfig['router'])) {
             foreach ($moduleConfig['router']['routes'] as $key => $name) {
                 $this->routes[$key] = $name;
             }
         }
     }
     $this->serviceManager->setAllowOverride(true);
     $this->application = $this->serviceManager->get('Application');
     $this->event = new MvcEvent();
     $this->event->setTarget($this->application);
     $this->event->setApplication($this->application)->setRequest($this->application->getRequest())->setResponse($this->application->getResponse())->setRouter($this->serviceManager->get('Router'));
     $this->em = $this->serviceManager->get('Doctrine\\ORM\\EntityManager');
     foreach ($this->filterModules() as $m) {
         $this->createDatabase($m);
     }
 }
开发者ID:argentinaluiz,项目名称:Learning-ZF2,代码行数:30,代码来源:TestCase.php

示例2: setup

 public function setup()
 {
     parent::setup();
     $config = (include 'config/application.config.php');
     $config['module_listener_options']['config_static_paths'] = array(getcwd() . '/config/test.config.php');
     if (file_exists(__DIR__ . '/config/test.config.php')) {
         $moduleConfig = (include __DIR__ . '/config/test.config.php');
         array_unshift($config['module_listener_options']['config_static_paths'], $moduleConfig);
     }
     $this->serviceManager = new ServiceManager(new ServiceManagerConfig(isset($config['service_manager']) ? $config['service_manager'] : array()));
     $this->serviceManager->setService('ApplicationConfig', $config);
     $this->serviceManager->setFactory('ServiceListener', 'Zend\\Mvc\\Service\\ServiceListenerFactory');
     $moduleManager = $this->serviceManager->get('ModuleManager');
     $moduleManager->loadModules();
     $this->routes = array();
     foreach ($moduleManager->getModules() as $m) {
         $moduleConfig = (include __DIR__ . '/../../../../' . ucfirst($m) . '/config/module.config.php');
         if (isset($moduleConfig['router'])) {
             foreach ($moduleConfig['router']['routes'] as $key => $name) {
                 $this->routes[$key] = $name;
             }
         }
     }
     $this->serviceManager->setAllowOverride(true);
     $this->application = $this->serviceManager->get('Application');
     $this->event = new MvcEvent();
     $this->event->setTarget($this->application);
     $this->event->setApplication($this->application)->setRequest($this->application->getRequest())->setResponse($this->application->getResponse())->setRouter($this->serviceManager->get('Router'));
     $this->createDatabase();
 }
开发者ID:alfredocoj,项目名称:blogzf2tutorial,代码行数:30,代码来源:TestCase.php

示例3: setUp

 protected function setUp()
 {
     $this->setApplicationConfig(include __DIR__ . '/../../../../../config/application.config.php');
     $this->sm = $this->getApplicationServiceLocator();
     $this->sm->setAllowOverride(true);
     $this->serializer = $this->getApplicationServiceLocator()->get('serializer');
 }
开发者ID:eschwartz,项目名称:zend-rest-api-tutorial,代码行数:7,代码来源:BreweryRestControllerTest.php

示例4: testAllowOverride

 /**
  * @covers Zend\ServiceManager\ServiceManager::setAllowOverride
  * @covers Zend\ServiceManager\ServiceManager::getAllowOverride
  */
 public function testAllowOverride()
 {
     $this->assertFalse($this->serviceManager->getAllowOverride());
     $ret = $this->serviceManager->setAllowOverride(true);
     $this->assertSame($this->serviceManager, $ret);
     $this->assertTrue($this->serviceManager->getAllowOverride());
 }
开发者ID:,项目名称:,代码行数:11,代码来源:

示例5: setMockToServiceLocator

 /**
  * Set service to service locator
  *
  * @param string $name
  * @param object $object
  *
  * @return ServiceManager
  */
 protected function setMockToServiceLocator($name, $object)
 {
     if (!$this->serviceLocator) {
         $this->serviceLocator = $this->getApplicationServiceLocator();
         $this->serviceLocator->setAllowOverride(true);
     }
     $this->serviceLocator->setService($name, $object);
     return $this->serviceLocator;
 }
开发者ID:omusico,项目名称:zf2-demo,代码行数:17,代码来源:AbstractFunctionalControllerTestCase.php

示例6: reloadConfig

 /**
  * Listen for theme change and override Config.
  */
 public function reloadConfig()
 {
     $request = $this->service->get('Request');
     $config = $this->service->get('Config');
     $this->service->setAllowOverride(true);
     $config['theme']['name'] = $request->getPost()['themeName'];
     $this->service->setService('Config', $config);
     $this->service->setAllowOverride(false);
 }
开发者ID:samsonasik,项目名称:unnamed,代码行数:12,代码来源:Module.php

示例7: setUp

 public function setUp()
 {
     $this->serviceLocator = null;
     $this->setApplicationConfig(Bootstrap::getConfig());
     parent::setUp();
     if (!is_object($this->serviceLocator)) {
         $this->serviceLocator = $this->getApplicationServiceLocator();
         $this->serviceLocator->setAllowOverride(true);
     }
 }
开发者ID:cross-solution,项目名称:yawik,代码行数:10,代码来源:FunctionalTestCase.php

示例8: testViewFactoryAllowsConfiguringViewHelpers

 public function testViewFactoryAllowsConfiguringViewHelpers()
 {
     $config = ['view_manager' => ['template_path_stack' => [__DIR__ . '/../view']], 'view_helpers' => ['invokables' => ['foo' => FooHelper::class]]];
     $this->serviceManager->setAllowOverride(true);
     $this->serviceManager->setService('Configuration', array_merge($this->getSmConfig(), $config));
     $view = $this->serviceManager->get(View::class);
     $vm = new ViewModel();
     $vm->setTemplate('helper-test.phtml');
     $result = $view->render($vm);
     $this->assertEquals('FOOBAR', $result);
 }
开发者ID:mtymek,项目名称:blast-view,代码行数:11,代码来源:ViewFactoryTest.php

示例9: getServiceManager

 public static function getServiceManager()
 {
     // configure service manager
     $configuration = static::$serviceConfig ?: (require __DIR__ . '/../../../test.application.on.config.php');
     $serviceManager = new ZendServiceManager(new ServiceManagerConfig());
     $serviceManager->setService('ApplicationConfig', $configuration);
     $serviceManager->get('ModuleManager')->loadModules();
     $serviceManager->setAllowOverride(true);
     $serviceManager->setService('request', Request::getRequest());
     $serviceManager->setAllowOverride(false);
     return $serviceManager;
 }
开发者ID:dollyaswin,项目名称:pyro,代码行数:12,代码来源:ServiceManager.php

示例10: setUp

 /**
  * Setup the service manager
  */
 protected function setUp()
 {
     $this->serviceConfig = (require TEST_BASE_PATH . '/config/module.config.php');
     $this->serviceManager = new ServiceManager();
     $this->serviceManager->setAllowOverride(true);
     $this->serviceManager->setService('Config', $this->serviceConfig);
     $this->serviceManager->setService('custom.strategy', $this->getMock('Zend\\Stdlib\\Hydrator\\Strategy\\StrategyInterface'));
     $this->serviceManager->setService('custom.filter', $this->getMock('\\Zend\\Stdlib\\Hydrator\\Filter\\FilterInterface'));
     $this->serviceManager->setService('custom.naming_strategy', $this->getMock('Zend\\Stdlib\\Hydrator\\NamingStrategy\\NamingStrategyInterface'));
     $this->hydratorManager = $this->getMock('Zend\\Stdlib\\Hydrator\\HydratorPluginManager');
     $this->hydratorManager->expects($this->any())->method('getServiceLocator')->will($this->returnValue($this->serviceManager));
 }
开发者ID:noc-med,项目名称:zf-doctrine-hydration-module,代码行数:15,代码来源:DoctrineHydratorFactoryTest.php

示例11: getServiceManager

 /**
  * @return \Zend\ServiceManager\ServiceManager
  */
 protected function getServiceManager()
 {
     if (null === $this->serviceManager) {
         $configuration = self::$applicationConfig;
         $smConfig = isset($configuration['service_manager']) ? $configuration['service_manager'] : array();
         $this->serviceManager = new ServiceManager(new ServiceManagerConfig($smConfig));
         $this->serviceManager->setAllowOverride(true);
         $this->serviceManager->setService('ApplicationConfig', $configuration);
         $this->serviceManager->get('ModuleManager')->loadModules();
     }
     return $this->serviceManager;
 }
开发者ID:outeredge,项目名称:edge-zf2,代码行数:15,代码来源:AbstractTestCase.php

示例12: renderDropDownMenu

 /**
  * Issue #80
  *
  * @test
  */
 public function renderDropDownMenu()
 {
     $spiffyNavStub = $this->getMockBuilder('SpiffyNavigation\\View\\Helper\\NavigationMenu')->disableOriginalConstructor()->getMock();
     $spiffyNavStub->expects($this->any())->method('renderMenu')->will($this->returnValue('<ul><li><ul><li>one</li><li>two</li></ul></li><li><ul><li>one</li><li>two</li></ul></li></ul>'));
     $this->serviceManager->setAllowOverride(true);
     $this->serviceManager->setService('navigationMenu', $spiffyNavStub);
     $service = $this->serviceManager->get('navigationMenu');
     try {
         $this->helper->setNavigationMenu($spiffyNavStub)->renderDropDownMenu('test');
     } catch (\PHPUnit_Framework_Error_Warning $e) {
         $this->fail($e->getMessage());
     }
     $this->assertContains('<b class="caret"></b>', $this->helper->setNavigationMenu($spiffyNavStub)->renderDropDownMenu('test'));
 }
开发者ID:spoonx,项目名称:sxbootstrap,代码行数:19,代码来源:NavigationMenuTest.php

示例13: setUpController

 protected function setUpController(\Zend\Mvc\Controller\AbstractActionController $controller)
 {
     $config = (include 'config/application.config.php');
     $serviceManager = new ServiceManager(new ServiceManagerConfig());
     $serviceManager->setService('ApplicationConfig', $config);
     $serviceManager->get('ModuleManager')->loadModules();
     $serviceManager->setAllowOverride(true);
     $this->controller = $controller;
     $this->request = new Request();
     $this->response = new Response();
     $this->routeMatch = new RouteMatch(array('controller' => 'index'));
     $this->event = new MvcEvent();
     $this->event->setRequest($this->request)->setResponse($this->response);
     $config = $serviceManager->get('Config');
     $routerConfig = isset($config['router']) ? $config['router'] : array();
     $router = HttpRouter::factory($routerConfig);
     $this->event->setRouter($router);
     $this->event->setRouteMatch($this->routeMatch);
     $this->controller->setEvent($this->event);
     $this->controller->setServiceLocator($serviceManager);
     $this->setupForwardPlugin();
     $this->setupParamsPlugin();
     $this->setupFormPlugin();
     $this->setupGridControllerPlugin();
     $this->setupControllerFilePlugin();
 }
开发者ID:noikiy,项目名称:tools,代码行数:26,代码来源:ControllerTestCase.php

示例14: createServer

 public function createServer($name = 'default')
 {
     Console::overrideIsConsole(false);
     $configuration = $this->configuration;
     $smConfig = isset($configuration['service_manager']) ? $configuration['service_manager'] : array();
     $serviceManager = new ServiceManager(new ServiceManagerConfig($smConfig));
     $serviceManager->setService('ApplicationConfig', $configuration);
     $serviceManager->get('ModuleManager')->loadModules();
     $application = new Application($configuration, $serviceManager);
     $application->setServerOptions($this->options->getServer($name));
     $allow = $serviceManager->getAllowOverride();
     $serviceManager->setAllowOverride(true);
     $serviceManager->setService('application', $application);
     $serviceManager->setAllowOverride($allow);
     return $application->bootstrap();
 }
开发者ID:im286er,项目名称:ent,代码行数:16,代码来源:ApplicationManager.php

示例15: init

 public static function init()
 {
     /**
      * Load Test Config to include other modules we require
      */
     if (is_readable(__DIR__ . '/TestConfig.php')) {
         $testConfig = (include __DIR__ . '/TestConfig.php');
     } else {
         $testConfig = (include __DIR__ . '/TestConfig.php.dist');
     }
     $zf2ModulePaths = array();
     if (isset($testConfig['module_listener_options']['module_paths'])) {
         $modulePaths = $testConfig['module_listener_options']['module_paths'];
         foreach ($modulePaths as $modulePath) {
             if ($path = static::findParentPath($modulePath)) {
                 $zf2ModulePaths[] = $path;
             }
         }
     }
     $zf2ModulePaths = implode(PATH_SEPARATOR, $zf2ModulePaths) . PATH_SEPARATOR;
     $zf2ModulePaths .= getenv('ZF2_MODULES_TEST_PATHS') ?: (defined('ZF2_MODULES_TEST_PATHS') ? ZF2_MODULES_TEST_PATHS : '');
     static::initAutoloader();
     // use ModuleManager to load this module and it's dependencies
     $baseConfig = array('module_listener_options' => array('module_paths' => explode(PATH_SEPARATOR, $zf2ModulePaths)));
     $config = ArrayUtils::merge($baseConfig, $testConfig);
     \Zend\Mvc\Application::init($config);
     $serviceManager = new ServiceManager(new ServiceManagerConfig());
     $serviceManager->setAllowOverride(true);
     $serviceManager->setService('ApplicationConfig', $config);
     $serviceManager->get('ModuleManager')->loadModules();
     static::$serviceManager = $serviceManager;
     static::$config = $config;
 }
开发者ID:netglue,项目名称:zf2-money-module,代码行数:33,代码来源:bootstrap.php


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