Ejemplo n.º 1
0
 /**
  * @return ServiceLocatorInterface
  */
 public function getServiceManager()
 {
     if ($this->serviceManager == null) {
         $this->serviceManager = $this->application->getServiceManager();
     }
     return $this->serviceManager;
 }
Ejemplo n.º 2
0
 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'] = '';
 }
Ejemplo n.º 3
0
 /**
  * @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();
 }
Ejemplo n.º 4
0
 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);
 }
Ejemplo n.º 5
0
 protected function getInternalDomains()
 {
     /**
      * @var Zend\Mvc\Router\Http\TreeRouteStack
      */
     $router = $this->application->getServiceManager()->get('router');
     $this->domainCollector = [];
     $this->addInternalDomainsFromRoutes($router->getRoutes());
     return array_unique($this->domainCollector);
 }
Ejemplo n.º 6
0
 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;
 }
Ejemplo n.º 8
0
 public function bootstrap(ModuleManager $moduleManager, ApplicationInterface $app)
 {
     $this->application = $app;
     $locator = $app->getServiceManager();
     if ($this->getOption('enable_guards.route', true)) {
         $routeProtector = $locator->get('ZfcAcl\\Guard\\Route');
         $app->events()->attach('route', array($routeProtector, 'onRoute'), -1000);
     }
     if ($this->getOption('enable_guards.event', true)) {
         $guard = $locator->get('ZfcAcl\\Guard\\Event');
         $guard->bootstrap();
     }
     if ($this->getOption('enable_guards.dispatch', true)) {
         $guard = $locator->get('ZfcAcl\\Guard\\Dispatch');
         $app->events()->attach('dispatch', array($guard, 'dispatch'), 1000);
     }
 }
 /**
  * @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']);
         }
     });
 }
Ejemplo n.º 10
0
 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
     }
 }
Ejemplo n.º 11
0
 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']);
         }
     });
 }
Ejemplo n.º 12
0
 /**
  * Checks that current url matches route.
  *
  * ``` php
  * <?php
  * $I->seeCurrentRouteIs('posts.index');
  * $I->seeCurrentRouteIs('posts.show', ['id' => 8]));
  * ?>
  * ```
  *
  * @param $routeName
  * @param array $params
  */
 public function seeCurrentRouteIs($routeName, array $params = [])
 {
     $router = $this->application->getServiceManager()->get('router');
     $url = $router->assemble($params, ['name' => $routeName]);
     $this->seeCurrentUrlEquals($url);
 }
Ejemplo n.º 13
0
 public function bootstrap(ModuleManager $moduleManager, ApplicationInterface $app)
 {
     $em = $app->getEventManager()->getSharedManager();
     $sm = $app->getServiceManager();
 }