/**
  * __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);
 }
Example #2
0
 /**
  * @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);
 }
 public function __construct(PluginManager $pluginManager)
 {
     $this->serviceLocator = $pluginManager->getServiceLocator();
 }
Example #4
0
 /**
  * @param ControllerManager $controllerManager
  * @return Mailer
  */
 public static function factory(ControllerManager $controllerManager)
 {
     return new static($controllerManager->getServiceLocator());
 }
Example #5
0
 /**
  * @param ControllerManager $controllerManager
  * @return \Auth\Controller\Plugin\LoginFilter
  */
 public static function factory(ControllerManager $controllerManager)
 {
     return new static($controllerManager->getServiceLocator()->get('Auth/LoginFilter'));
 }
Example #6
0
 /**
  * @return ServiceLocatorInterface
  */
 public function getServiceLocator()
 {
     return $this->serviceLocator->getServiceLocator();
 }
 /**
  * @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));
 }
 public function __invoke(PluginManager $pluginManager)
 {
     return new ValidateIncomingData($pluginManager->getServiceLocator()->get('inputFilterManager'));
 }