本文整理汇总了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);
}
}
示例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();
}
示例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');
}
示例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());
}
示例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;
}
示例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);
}
示例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);
}
}
示例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);
}
示例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;
}
示例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));
}
示例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;
}
示例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'));
}
示例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();
}
示例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();
}
示例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;
}