本文整理汇总了PHP中Zend\Mvc\Controller\PluginManager::setServiceLocator方法的典型用法代码示例。如果您正苦于以下问题:PHP PluginManager::setServiceLocator方法的具体用法?PHP PluginManager::setServiceLocator怎么用?PHP PluginManager::setServiceLocator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Mvc\Controller\PluginManager
的用法示例。
在下文中一共展示了PluginManager::setServiceLocator方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testCreateService
public function testCreateService()
{
$pm = new ControllerPluginManager();
$sm = new ServiceManager();
$sm->setService('AcMailer\\Service\\MailService', new MailServiceMock());
$pm->setServiceLocator($sm);
$this->assertInstanceOf('AcMailer\\Controller\\Plugin\\SendMailPlugin', $this->factory->createService($pm));
}
示例2: createControllerManager
protected function createControllerManager($config = [])
{
$pm = new ControllerPluginManager();
$sm = new ServiceManager();
$sm->setService('Config', $config);
$pm->setServiceLocator($sm);
return $pm;
}
示例3: setUp
/**
* {@inheritDoc}
*/
public function setUp()
{
$this->serviceManager = Bootstrap::getServiceManager();
$this->entityManager = $this->serviceManager->get('doctrine.entitymanager.orm_default');
$this->createMergedDocument = new CreateMergedDocument();
$pluginManager = new PluginManager();
$pluginManager->setServiceLocator($this->serviceManager);
$this->createMergedDocument->setServiceLocator($pluginManager);
}
示例4: testFactory
public function testFactory()
{
$serviceManager = new ServiceManager();
$pluginManager = new PluginManager();
$pluginManager->setServiceLocator($serviceManager);
$serviceManager->setService('ZfjRbac\\Service\\AuthorizationService', $this->getMock('ZfjRbac\\Service\\AuthorizationServiceInterface'));
$factory = new IsGrantedPluginFactory();
$isGranted = $factory->createService($pluginManager);
$this->assertInstanceOf('ZfjRbac\\Mvc\\Controller\\Plugin\\IsGranted', $isGranted);
}
示例5: testIdentityFactoryCanInjectAuthenticationServiceIfInParentServiceManager
public function testIdentityFactoryCanInjectAuthenticationServiceIfInParentServiceManager()
{
$services = new ServiceManager();
$services->setInvokableClass('Zend\\Authentication\\AuthenticationService', 'Zend\\Authentication\\AuthenticationService');
$pluginManager = new PluginManager();
$pluginManager->setServiceLocator($services);
$identity = $pluginManager->get('identity');
$expected = $services->get('Zend\\Authentication\\AuthenticationService');
$this->assertSame($expected, $identity->getAuthenticationService());
}
示例6: testFactory
public function testFactory()
{
$serviceManager = new ServiceManager();
$serviceManager->setService(LayoutInterface::class, $this->layout);
$serviceManager->setService(LayoutUpdaterInterface::class, $this->layoutUpdater);
$serviceManager->setService(BlockPoolInterface::class, $this->blockPool);
$controllerPluginManager = new PluginManager();
$controllerPluginManager->setServiceLocator($serviceManager);
$factory = new LayoutManagerFactory();
$instance = $factory->createService($controllerPluginManager);
$this->assertInstanceOf(LayoutManager::class, $instance);
}
示例7: testFactory
public function testFactory()
{
$serviceManager = new ServiceManager();
$serviceManager->setService('ConLayout\\Layout\\LayoutInterface', $this->layout);
$serviceManager->setService('ConLayout\\Updater\\LayoutUpdaterInterface', $this->updater);
$serviceManager->setService('ConLayout\\View\\Renderer\\BlockRenderer', $this->renderer);
$controllerPluginManager = new PluginManager();
$controllerPluginManager->setServiceLocator($serviceManager);
$factory = new LayoutManagerFactory();
$instance = $factory->createService($controllerPluginManager);
$this->assertInstanceOf('ConLayout\\Controller\\Plugin\\LayoutManager', $instance);
}
示例8: testCanDisplayListOfMessagesCustomisedByConfig
public function testCanDisplayListOfMessagesCustomisedByConfig()
{
$this->seedMessages();
$config = array(
'view_helper_config' => array(
'flashmessenger' => array(
'message_open_format' => '<div%s><ul><li>',
'message_separator_string' => '</li><li>',
'message_close_string' => '</li></ul></div>',
),
),
);
$sm = new ServiceManager();
$sm->setService('Config', $config);
$helperPluginManager = new HelperPluginManager(new Config(array(
'factories' => array(
'flashmessenger' => 'Zend\View\Helper\Service\FlashMessengerFactory',
),
)));
$controllerPluginManager = new PluginManager(new Config(array(
'invokables' => array(
'flashmessenger' => 'Zend\Mvc\Controller\Plugin\FlashMessenger',
),
)));
$helperPluginManager->setServiceLocator($sm);
$controllerPluginManager->setServiceLocator($sm);
$sm->setService('ControllerPluginManager', $controllerPluginManager);
$helper = $helperPluginManager->get('flashmessenger');
$displayInfoAssertion = '<div class="info"><ul><li>bar-info</li></ul></div>';
$displayInfo = $helper->render(PluginFlashMessenger::NAMESPACE_INFO);
$this->assertEquals($displayInfoAssertion, $displayInfo);
}
示例9: testCreateServiceWithoutModelManager
/**
* @expectedException \Zend\ServiceManager\Exception\ServiceNotCreatedException
*/
public function testCreateServiceWithoutModelManager()
{
$this->pm->setServiceLocator($this->sm);
$this->factory->createService($this->pm);
}
示例10: testCanDisplayListOfCurrentMessagesCustomisedByConfigSeparator
public function testCanDisplayListOfCurrentMessagesCustomisedByConfigSeparator()
{
$this->seedCurrentMessages();
$config = array('view_helper_config' => array('flashmessenger' => array('message_open_format' => '<div><ul><li%s>', 'message_separator_string' => '</li><li%s>', 'message_close_string' => '</li></ul></div>')));
$sm = new ServiceManager();
$sm->setService('Config', $config);
$helperPluginManager = new HelperPluginManager(new Config(array('factories' => array('flashmessenger' => 'Zend\\View\\Helper\\Service\\FlashMessengerFactory'))));
$controllerPluginManager = new PluginManager(new Config(array('invokables' => array('flashmessenger' => 'Zend\\Mvc\\Controller\\Plugin\\FlashMessenger'))));
$helperPluginManager->setServiceLocator($sm);
$controllerPluginManager->setServiceLocator($sm);
$sm->setService('ControllerPluginManager', $controllerPluginManager);
$helper = $helperPluginManager->get('flashmessenger');
$displayInfoAssertion = '<div><ul><li class="foo-baz foo-bar">foo</li><li class="foo-baz foo-bar">bar</li></ul></div>';
$displayInfo = $helper->renderCurrent(PluginFlashMessenger::NAMESPACE_DEFAULT, array('foo-baz', 'foo-bar'));
$this->assertEquals($displayInfoAssertion, $displayInfo);
}