/** * @param MvcEvent $event */ public function __construct(MvcEvent $event) { $this->application = $event->getApplication(); $this->serviceManager = $this->application->getServiceManager(); $this->config = $this->serviceManager->get('VuFind\\Config')->get('config'); $this->event = $event; $this->events = $this->application->getEventManager(); }
public function _before(\Codeception\TestCase $test) { $this->application = Application::init($this->applicationConfig); $events = $this->application->getEventManager(); $events->detach($this->application->getServiceManager()->get('SendResponseListener')); $this->client->setApplication($this->application); $_SERVER['REQUEST_URI'] = ''; }
/** * @param \Zend\Mvc\MvcEvent $e The MvcEvent instance * @return void */ public function onBootstrap($e) { $this->application = $e->getApplication(); $eventeManager = $this->application->getEventManager(); $moduleRouteListener = new ModuleRouteListener(); $moduleRouteListener->attach($eventeManager); $eventeManager->attach(MvcEvent::EVENT_ROUTE, [$this, 'checkAuthentication']); }
public function _before(TestInterface $test) { $this->client = new ZF2Connector(); $this->application = Application::init($this->applicationConfig); $events = $this->application->getEventManager(); $events->detach($this->application->getServiceManager()->get('SendResponseListener')); $this->client->setApplication($this->application); $_SERVER['REQUEST_URI'] = ''; }
public function _before(\Codeception\TestCase $test) { $applicationConfig = (require \Codeception\Configuration::projectDir() . $this->config['config']); if (isset($applicationConfig['module_listener_options']['config_cache_enabled'])) { $applicationConfig['module_listener_options']['config_cache_enabled'] = false; } Console::overrideIsConsole(false); $this->application = Application::init($applicationConfig); $events = $this->application->getEventManager(); $events->detach($this->application->getServiceManager()->get('SendResponseListener')); $this->client->setApplication($this->application); }
private function createApplication() { $this->application = Application::init($this->applicationConfig); $serviceManager = $this->application->getServiceManager(); if (isset($this->doctrineServiceManager)) { $serviceManager->addPeeringServiceManager($this->doctrineServiceManager); $serviceManager->setRetrieveFromPeeringManagerFirst(true); } $events = $this->application->getEventManager(); $events->detach($serviceManager->get('SendResponseListener')); }
/** * Get the application object * @return \Zend\Mvc\ApplicationInterface */ public function getApplication() { if ($this->application) { return $this->application; } $appConfig = $this->applicationConfig; Console::overrideIsConsole($this->getUseConsoleRequest()); $this->application = Application::init($appConfig); $events = $this->application->getEventManager(); $events->detach($this->application->getServiceManager()->get('SendResponseListener')); return $this->application; }
/** * @param ModuleManager $moduleManager * @param ApplicationInterface $app */ public function bootstrap(ModuleManager $moduleManager, ApplicationInterface $app) { /* @var SharedEventManager $em */ $em = $app->getEventManager()->getSharedManager(); $sm = $app->getServiceManager(); /* @var GitHub\LoginListener $loginListener */ $loginListener = $sm->get(GitHub\LoginListener::class); $em->attachAggregate($loginListener); $em->attach('EdpGithub\\Client', 'api', function ($e) use($sm) { $hybridAuth = $sm->get('HybridAuth'); $adapter = $hybridAuth->getAdapter('github'); if ($adapter->isUserConnected()) { $token = $adapter->getAccessToken(); $client = $e->getTarget(); $client->authenticate('url_token', $token['access_token']); } }); }
private function createApplication() { $this->application = Application::init($this->applicationConfig); $serviceManager = $this->application->getServiceManager(); if (isset($this->persistentServiceManager)) { $serviceManager->addPeeringServiceManager($this->persistentServiceManager); $serviceManager->setRetrieveFromPeeringManagerFirst(true); } $sendResponseListener = $serviceManager->get('SendResponseListener'); $events = $this->application->getEventManager(); if (class_exists('Zend\\EventManager\\StaticEventManager')) { $events->detach($sendResponseListener); //ZF2 } else { $events->detach([$sendResponseListener, 'sendResponse']); //ZF3 } }
/** * Get the application object * @return \Zend\Mvc\ApplicationInterface */ public function getApplication() { if ($this->application) { return $this->application; } $appConfig = $this->applicationConfig; if (!$this->useConsoleRequest) { $consoleServiceConfig = array('service_manager' => array('factories' => array('ServiceListener' => 'Zend\\Test\\PHPUnit\\Mvc\\Service\\ServiceListenerFactory'))); $appConfig = array_replace_recursive($appConfig, $consoleServiceConfig); } $this->application = Application::init($appConfig); $events = $this->application->getEventManager(); foreach ($events->getListeners(MvcEvent::EVENT_FINISH) as $listener) { $callback = $listener->getCallback(); if (is_array($callback) && $callback[0] instanceof SendResponseListener) { $events->detach($listener); } } return $this->application; }
public function bootstrap(ModuleManager $moduleManager, ApplicationInterface $app) { $em = $app->getEventManager()->getSharedManager(); $sm = $app->getServiceManager(); $em->attach('ScnSocialAuth\\Authentication\\Adapter\\HybridAuth', 'githubToLocalUser', function ($e) { $localUser = $e->getTarget(); $userProfile = $e->getParam('userProfile'); $nickname = substr($userProfile->profileURL, strrpos($userProfile->profileURL, "/") + 1); $localUser->setUsername($nickname); $localUser->setPhotoUrl($userProfile->photoURL); }); $em->attach('EdpGithub\\Client', 'api', function ($e) use($sm) { $hybridAuth = $sm->get('HybridAuth'); $adapter = $hybridAuth->getAdapter('github'); if ($adapter->isUserConnected()) { $token = $adapter->getAccessToken(); $client = $e->getTarget(); $client->authenticate('url_token', $token['access_token']); } }); }
public function bootstrap(ModuleManager $moduleManager, ApplicationInterface $app) { $em = $app->getEventManager()->getSharedManager(); $sm = $app->getServiceManager(); }