本文整理汇总了PHP中Zend\Mvc\Controller\PluginManager::getServiceLocator方法的典型用法代码示例。如果您正苦于以下问题:PHP PluginManager::getServiceLocator方法的具体用法?PHP PluginManager::getServiceLocator怎么用?PHP PluginManager::getServiceLocator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Mvc\Controller\PluginManager
的用法示例。
在下文中一共展示了PluginManager::getServiceLocator方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __invoke
/**
* __invoke
*
* Create the identity controller plugin.
*
* @param PluginManager $controllerPluginManager The controller plugin manager.
* @param string $name The name of the service being created.
* @param string $requestedName The requested name of the service being created.
*
* @return Identity
*/
public function __invoke(PluginManager $controllerPluginManager, $name, $requestedName)
{
/** @var ServiceManager $serviceManager */
$serviceManager = $controllerPluginManager->getServiceLocator();
$options = $this->getOptions($serviceManager, $requestedName);
if (empty($options['auth_service'])) {
throw new ServiceNotCreatedException(sprintf('The required \'auth_service\' configuration option for service \'%s\' could not be found in \'%s\'.', $requestedName, __METHOD__));
}
/** @var AuthenticationServiceInterface $authenticationService */
$authenticationService = $serviceManager->get($options['auth_service']);
return new Identity($authenticationService);
}
示例2: testNonArrayListenerDoesNotRaiseErrorWhenPluginDispatchsRequestedController
/**
* @group 5432
*/
public function testNonArrayListenerDoesNotRaiseErrorWhenPluginDispatchsRequestedController()
{
$services = $this->plugins->getServiceLocator();
$events = $services->get('EventManager');
$sharedEvents = $this->getMock('Zend\\EventManager\\SharedEventManagerInterface');
$sharedEvents->expects($this->any())->method('getListeners')->will($this->returnValue(array(new CallbackHandler(function ($e) {
}))));
$events = $this->getMock('Zend\\EventManager\\EventManagerInterface');
$events->expects($this->any())->method('getSharedManager')->will($this->returnValue($sharedEvents));
$application = $this->getMock('Zend\\Mvc\\ApplicationInterface');
$application->expects($this->any())->method('getEventManager')->will($this->returnValue($events));
$event = $this->controller->getEvent();
$event->setApplication($application);
$result = $this->plugin->dispatch('forward');
$this->assertInternalType('array', $result);
$this->assertEquals(array('content' => 'ZendTest\\Mvc\\Controller\\TestAsset\\ForwardController::testAction'), $result);
}
示例3: __construct
public function __construct(PluginManager $pluginManager)
{
$this->serviceLocator = $pluginManager->getServiceLocator();
}
示例4: factory
/**
* @param ControllerManager $controllerManager
* @return Mailer
*/
public static function factory(ControllerManager $controllerManager)
{
return new static($controllerManager->getServiceLocator());
}
示例5: factory
/**
* @param ControllerManager $controllerManager
* @return \Auth\Controller\Plugin\LoginFilter
*/
public static function factory(ControllerManager $controllerManager)
{
return new static($controllerManager->getServiceLocator()->get('Auth/LoginFilter'));
}
示例6: getServiceLocator
/**
* @return ServiceLocatorInterface
*/
public function getServiceLocator()
{
return $this->serviceLocator->getServiceLocator();
}
示例7: __invoke
/**
* @param PluginManager $pluginManager
* @return GetEntity
*
* @throws \Interop\Container\Exception\ContainerException
*/
public function __invoke(PluginManager $pluginManager) : GetEntity
{
/* @var ContainerInterface $container */
$container = $pluginManager->getServiceLocator();
return new GetEntity($container->get(EntityManager::class), $container->get(AuthorizationService::class));
}
示例8: __invoke
public function __invoke(PluginManager $pluginManager)
{
return new ValidateIncomingData($pluginManager->getServiceLocator()->get('inputFilterManager'));
}