public function getModulosCarregados(Event $e)
 {
     echo $e->getName() . "<br>";
     echo get_class($e->getTarget());
     $moduleManager = $e->getTarget();
     print_r($moduleManager->getLoadedModules());
 }
Beispiel #2
0
 /**
  * {@inheritDoc}
  */
 public function onBootstrap(EventInterface $e)
 {
     /* @var $app \Zend\Mvc\ApplicationInterface */
     $app = $e->getTarget();
     $events = $app->getEventManager()->getSharedManager();
     // Attach to helper set event and load the entity manager helper.
     $events->attach('doctrine', 'loadCli.post', function (EventInterface $e) {
         /* @var $cli \Symfony\Component\Console\Application */
         $cli = $e->getTarget();
         ConsoleRunner::addCommands($cli);
         $cli->addCommands(array(new DiffCommand(), new ExecuteCommand(), new GenerateCommand(), new MigrateCommand(), new StatusCommand(), new VersionCommand()));
         /* @var $sm ServiceLocatorInterface */
         $sm = $e->getParam('ServiceManager');
         /* @var $em \Doctrine\ORM\EntityManager */
         $em = $sm->get('doctrine.entitymanager.orm_default');
         $helperSet = $cli->getHelperSet();
         $helperSet->set(new DialogHelper(), 'dialog');
         $helperSet->set(new ConnectionHelper($em->getConnection()), 'db');
         $helperSet->set(new EntityManagerHelper($em), 'em');
     });
     $config = $app->getServiceManager()->get('Config');
     $app->getServiceManager()->get('doctrine.entity_resolver.orm_default');
     if (isset($config['zenddevelopertools']['profiler']['enabled']) && $config['zenddevelopertools']['profiler']['enabled']) {
         $app->getServiceManager()->get('doctrine.sql_logger_collector.orm_default');
     }
 }
Beispiel #3
0
 public function onBootstrap(EventInterface $e)
 {
     $application = $e->getTarget();
     $eventManager = $application->getEventManager();
     $services = $application->getServiceManager();
     $services->get('Server');
     $e->getApplication()->getEventManager()->getSharedManager()->attach('Zend\\Mvc\\Controller\\AbstractController', 'dispatch', function ($e) {
         $controller = $e->getTarget();
         $controllerClass = get_class($controller);
         $moduleNamespace = substr($controllerClass, 0, strpos($controllerClass, '\\'));
         $config = $e->getApplication()->getServiceManager()->get('config');
         if (isset($config['module_layouts'][$moduleNamespace])) {
             $controller->layout($config['module_layouts'][$moduleNamespace]);
         }
     }, 100);
     $eventManager->attach('route', function ($event) {
         $sm = $event->getApplication()->getServiceManager();
         $config = $event->getApplication()->getServiceManager()->get('Config');
         $localesConfig = $config['locales'];
         $locales = $localesConfig['list'];
         $locale = $event->getRouteMatch()->getParam('locale', null);
         if (empty($locale)) {
             $locale = isset($_COOKIE['locale']) ? $_COOKIE['locale'] : $localesConfig['default']['code'];
         }
         if (in_array($locale, array_keys($locales))) {
             $locale = $locales[$locale]['code'];
         } else {
             $locale = $localesConfig['default']['code'];
         }
         $translator = $sm->get('translator');
         $translator->setLocale($locale);
         $httpServer = "";
         if (isset($_SERVER['HTTP_HOST'])) {
             $httpServer = $_SERVER['HTTP_HOST'];
         }
         setcookie('locale', $locale, time() + 3600, '/', $httpServer);
     }, -10);
     $moduleRouteListener = new ModuleRouteListener();
     $moduleRouteListener->attach($eventManager);
     $eventManager->attach('dispatch.error', function ($event) use($services) {
         $event->getResult()->setTerminal(TRUE);
         $exception = $event->getResult()->exception;
         $error = $event->getError();
         if (!$exception && !$error) {
             return;
         }
         $service = $services->get('Likerow\\ErrorHandler');
         if ($exception) {
             $service->logException($exception, $services->get('Mail'));
         }
         if ($error) {
             $service->logError('Dispatch ERROR: ' . $error, $services->get('Mail'));
         }
     });
 }
Beispiel #4
0
 public function onBootstrap(EventInterface $e)
 {
     $t = $e->getTarget();
     $t->getEventManager()->attach($t->getServiceManager()->get('ZfcRbac\\View\\Strategy\\UnauthorizedStrategy'));
     $events = $e->getApplication()->getEventManager()->getSharedManager();
     $events->attach('ZfcUser\\Form\\Login', 'init', function ($e) {
         $form = $e->getTarget();
         $form->get('identity')->setLabel("Nom d'utilisateur");
         $form->get('credential')->setLabel("Mot de passe");
         $form->get('submit')->setLabel("Se connecter");
     });
 }
Beispiel #5
0
 /**
  * {@inheritDoc}
  */
 public function onBootstrap(EventInterface $e)
 {
     $config = $e->getTarget()->getServiceManager()->get('Config');
     $config = isset($config['view_manager']) ? $config['view_manager'] : array();
     if ($e->getRequest() instanceof ConsoleRequest || empty($config['display_exceptions'])) {
         return;
     }
     $this->run = new Run();
     $this->run->register();
     // set up whoops config
     $prettyPageHandler = new PrettyPageHandler();
     if (isset($config['editor'])) {
         if ($config['editor'] == 'phpStorm') {
             $localPath = null;
             if (isset($config['local_path'])) {
                 $localPath = $config['local_path'];
             }
             $prettyPageHandler->setEditor(function ($file, $line) use($localPath) {
                 if ($localPath) {
                     // if your development server is not local it's good to map remote files to local
                     $translations = array('^' . __DIR__ => $config['editor_path']);
                     // change to your path
                     foreach ($translations as $from => $to) {
                         $file = preg_replace('#' . $from . '#', $to, $file, 1);
                     }
                 }
                 return "pstorm://{$file}:{$line}";
             });
         } else {
             $prettyPageHandler->setEditor($config['editor']);
         }
     }
     if (!empty($config['json_exceptions']['display'])) {
         $jsonHandler = new JsonResponseHandler();
         if (!empty($config['json_exceptions']['show_trace'])) {
             $jsonHandler->addTraceToOutput(true);
         }
         if (!empty($config['json_exceptions']['ajax_only'])) {
             $jsonHandler->onlyForAjaxRequests(true);
         }
         $this->run->pushHandler($jsonHandler);
     }
     if (!empty($config['whoops_no_catch'])) {
         $this->noCatchExceptions = $config['whoops_no_catch'];
     }
     $this->run->pushHandler($prettyPageHandler);
     $eventManager = $e->getTarget()->getEventManager();
     $eventManager->attach(MvcEvent::EVENT_RENDER_ERROR, array($this, 'prepareException'));
     $eventManager->attach(MvcEvent::EVENT_DISPATCH_ERROR, array($this, 'prepareException'));
 }
 public function onBootstrap(EventInterface $e)
 {
     /* @var $application \Zend\Mvc\Application */
     $application = $e->getTarget();
     $eventManager = $application->getEventManager();
     $moduleRouteListener = new ModuleRouteListener();
     $moduleRouteListener->attach($eventManager);
     //todo Delete this hack (avoid unit tests) after update BjyAuthorize module to 2.0
     if (\Zend\Console\Console::isConsole()) {
         return;
     }
     $sm = $e->getApplication()->getServiceManager();
     // Add ACL information to the Navigation view helper
     $authorize = $sm->get('BjyAuthorizeServiceAuthorize');
     $acl = $authorize->getAcl();
     $role = $authorize->getIdentity();
     ZendViewHelperNavigation::setDefaultAcl($acl);
     ZendViewHelperNavigation::setDefaultRole($role);
     $services = $application->getServiceManager();
     $zfcServiceEvents = $services->get('zfcuser_user_service')->getEventManager();
     $zfcServiceEvents->attach('register', function ($e) use($services) {
         $zfcUser = $e->getParam('user');
         $em = $services->get('doctrine.entitymanager.orm_default');
         $configAuth = $services->get('BjyAuthorize\\Config');
         $providerConfig = $configAuth['role_providers']['BjyAuthorize\\Provider\\Role\\ObjectRepositoryProvider'];
         $criteria = array('roleId' => $configAuth['authenticated_role']);
         $defaultUserRole = $em->getRepository($providerConfig['role_entity_class'])->findOneBy($criteria);
         if ($defaultUserRole !== null) {
             $zfcUser->addRole($defaultUserRole);
         }
     });
     $application->getEventManager()->getSharedManager()->attach('ZfcUserAdmin\\Form\\EditUser', 'init', function ($e) {
         // $form is a ZfcUser\Form\Register
         $form = $e->getTarget();
         $sm = $form->getServiceManager();
         $om = $sm->get('Doctrine\\ORM\\EntityManager');
         //$form->setHydrator(new \DoctrineORMModule\Stdlib\Hydrator\DoctrineEntity($om, 'OpsWay\TocatUser\Entity\User'));
         $form->add(array('name' => 'roles', 'type' => 'DoctrineModule\\Form\\Element\\ObjectMultiCheckbox', 'options' => array('label' => 'Assign Roles', 'object_manager' => $om, 'target_class' => Entity\Role::class, 'property' => 'roleId')));
         $form->add(array('name' => 'groups', 'type' => 'DoctrineModule\\Form\\Element\\ObjectSelect', 'options' => array('label' => 'Assign Groups', 'object_manager' => $om, 'target_class' => Entity\Group::class, 'property' => 'name'), 'attributes' => array('multiple' => true)));
     });
     $application->getEventManager()->getSharedManager()->attach('ZfcUserAdmin\\Service\\User', 'edit', function ($e) {
         $zfcUser = $e->getParam('user');
         $post = $e->getParam('data');
         $em = $e->getParam('form')->getServiceManager()->get('doctrine.entitymanager.orm_default');
         $listRoles = $em->getRepository(Entity\Role::class)->findBy(array('id' => $post['roles']));
         $zfcUser->updateRoles($listRoles);
         $listGroup = $em->getRepository(Entity\Group::class)->findBy(array('id' => $post['groups']));
         $zfcUser->updateGroups($listGroup);
     });
 }
Beispiel #7
0
 public function onBootstrap(EventInterface $e)
 {
     $this->serviceLocator = $e->getTarget()->getServiceManager();
     $config = $e->getTarget()->getServiceManager()->get('Config');
     $this->whoopsConfig = $config['arilas']['whoops'];
     if ($this->whoopsConfig['disabled']) {
         return;
     }
     $this->run = new Run();
     $this->run->register();
     $this->run->pushHandler($this->getHandler());
     $eventManager = $e->getTarget()->getEventManager();
     $eventManager->attach(MvcEvent::EVENT_RENDER_ERROR, array($this, 'prepareException'));
     $eventManager->attach(MvcEvent::EVENT_DISPATCH_ERROR, array($this, 'prepareException'));
 }
Beispiel #8
0
 /**
  * {@inheritdoc}
  */
 public function onBootstrap(EventInterface $e)
 {
     /** @var ApplicationInterface $app */
     $app = $e->getTarget();
     $serviceManager = $app->getServiceManager();
     /** @var Options $options */
     $options = $serviceManager->get('BuggymanOptions');
     if ($options->getEnabled() && $options->getToken()) {
         Buggyman::setToken($options->getToken());
         Buggyman::setErrorLevel($options->getErrorLevel());
         Buggyman::setRoot(getcwd());
         Buggyman::init();
         $app->getEventManager()->attach([MvcEvent::EVENT_DISPATCH_ERROR, MvcEvent::EVENT_RENDER_ERROR], function (MvcEvent $event) use($serviceManager) {
             if ($event->getParam('exception') instanceof Exception) {
                 Buggyman::reportException($event->getParam('exception'));
             }
         });
         if ($options->getPublicToken() && !isset($_SERVER['HTTPS'])) {
             /** @var HelperPluginManager $pluginManager */
             $pluginManager = $serviceManager->get('ViewHelperManager');
             /** @var InlineScript $inline */
             $inline = $pluginManager->get('InlineScript');
             $inline($inline::FILE, 'http://cdn.buggyman.io/v1/js/' . $options->getPublicToken() . '/collector.js');
         }
     }
 }
Beispiel #9
0
 public function onBootstrap(EventInterface $e)
 {
     // Récupération des erreurs en ajoutant un callback qui affiche l'erreur coté serveur
     $application = $e->getTarget();
     $event = $application->getEventManager();
     $event->attach(MvcEvent::EVENT_DISPATCH_ERROR, function (MvcEvent $e) {
         error_log('DISPATCH_ERROR : ' . $e->getError());
         error_log($e->getControllerClass() . ' ' . $e->getController());
     });
     $event->attach(MvcEvent::EVENT_RENDER_ERROR, function (MvcEvent $e) {
         error_log('RENDER_ERROR : ' . $e->getError());
     });
     $event->attach(MvcEvent::EVENT_RENDER, function (MvcEvent $e) {
         $services = $e->getApplication()->getServiceManager();
         $session = $services->get('session');
         $rightViewModel = new ViewModel();
         if (!isset($session->user)) {
             $form = $services->get('MiniModule\\Form\\Authentification');
             $formUser = $services->get('MiniModule\\Form\\NewUser');
             $rightViewModel->setVariables(array('form' => $form, 'newUserForm' => $formUser));
             $rightViewModel->setTemplate('layout/form-auth');
         } else {
             $rightViewModel->setVariables(array('user' => $session->user));
             $rightViewModel->setTemplate('layout/info-auth');
         }
         $view = $e->getViewModel();
         // c'est le viewModel qui contient le layout (top viewModel)
         $view->addChild($rightViewModel, 'formulaireAuth');
     });
 }
Beispiel #10
0
 public function onBootstrap(EventInterface $e)
 {
     /** @var \Zend\Mvc\Application $app */
     $app = $e->getTarget();
     $config = $app->getConfig();
     $sessionConfig = new SessionConfig();
     if (isset($config['session']['options'])) {
         $options = $config['session']['options'];
         if (isset($options['cookie_domain']) && strpos($_SERVER['SERVER_NAME'], $options['cookie_domain']) === false) {
             $options['cookie_domain'] = $_SERVER['SERVER_NAME'];
         }
         $sessionConfig->setOptions($options);
     }
     $serviceManager = $app->getServiceManager();
     $storage = null;
     $saveHandler = null;
     if ($serviceManager->has('Session\\Service\\Storage', false)) {
         /** @var \Zend\Session\Storage\StorageInterface $storage */
         $storage = $serviceManager->get('Session\\Service\\Storage');
     }
     if ($serviceManager->has('Session\\Service\\SaveHandler', false)) {
         /** @var \Zend\Session\SaveHandler\SaveHandlerInterface $saveHandler */
         $saveHandler = $serviceManager->get('Session\\Service\\SaveHandler');
     }
     Container::setDefaultManager(new SessionManager($sessionConfig, $storage, $saveHandler));
 }
 /**
  * On bootstrap.
  * 
  * @param MvcEvent $e
  * @return void
  */
 public function onBootstrap(EventInterface $e)
 {
     $application = $e->getTarget();
     $events = $application->getEventManager();
     $moduleRouteListener = new ModuleRouteListener();
     $moduleRouteListener->attach($events);
 }
Beispiel #12
0
 /**
  * {@inheritDoc}
  */
 public function onBootstrap(EventInterface $event)
 {
     /**
      * @var ModuleOptions $moduleOptions
      */
     $moduleOptions = $event->getTarget()->getServiceManager()->get('LemoTracy\\Options\\ModuleOptions');
     if (true === $moduleOptions->getEnabled()) {
         if (null !== $moduleOptions->getMode()) {
             Debugger::enable($moduleOptions->getMode());
         }
         if (null !== $moduleOptions->getLogDirectory()) {
             Debugger::$logDirectory = $moduleOptions->getLogDirectory();
         }
         if (null !== $moduleOptions->getLogSeverity()) {
             Debugger::$logSeverity = $moduleOptions->getLogSeverity();
         }
         if (null !== $moduleOptions->getMaxDepth()) {
             Debugger::$maxDepth = $moduleOptions->getMaxDepth();
         }
         if (null !== $moduleOptions->getMaxLen()) {
             Debugger::$maxLen = $moduleOptions->getMaxLen();
         }
         if (null !== $moduleOptions->getShowBar()) {
             Debugger::$showBar = $moduleOptions->getShowBar();
         }
         if (null !== $moduleOptions->getStrict()) {
             Debugger::$strictMode = $moduleOptions->getStrict();
         }
     }
 }
Beispiel #13
0
 public function onBootstrap(EventInterface $event)
 {
     /*$eventManager        = $e->getApplication()->getEventManager();
       $moduleRouteListener = new ModuleRouteListener();
       $moduleRouteListener->attach($eventManager);*/
     $application = $event->getTarget();
     $serviceManager = $application->getServiceManager();
     $translator = $serviceManager->get('translator');
     $translator->setLocale(\Locale::acceptFromHttp($_SERVER['HTTP_ACCEPT_LANGUAGE']))->setFallbackLocale('en_US');
     $application->getEventManager()->attach(MvcEvent::EVENT_DISPATCH, function (MvcEvent $event) use($serviceManager) {
         $request = $event->getRequest();
         $response = $event->getResponse();
         if (!($request instanceof HttpRequest && $response instanceof HttpResponse)) {
             return;
             // CLI application maybe?
         }
         $authAdapter = $serviceManager->get('AuthenticationAdapter');
         $authAdapter->setRequest($request);
         $authAdapter->setResponse($response);
         $result = $authAdapter->authenticate();
         if ($result->isValid()) {
             return;
             // OK
         }
         $response->setContent('Access denied');
         $response->setStatusCode(HttpResponse::STATUS_CODE_401);
         $event->setResult($response);
         // to end
         return false;
         // event propagation stop
     });
 }
Beispiel #14
0
 public function onBootstrap(EventInterface $e)
 {
     /* @var \Zend\Mvc\Application $application */
     $application = $e->getTarget();
     $serviceManager = $application->getServiceManager();
     $eventManager = $application->getEventManager();
 }
 /**
  * Set up spelling parameters.
  *
  * @param EventInterface $event Event
  *
  * @return EventInterface
  */
 public function onSearchPre(EventInterface $event)
 {
     $backend = $event->getTarget();
     if ($backend === $this->backend) {
         $params = $event->getParam('params');
         if ($params) {
             // Set spelling parameters unless explicitly disabled:
             $sc = $params->get('swissbibspellcheck');
             if (!empty($sc) && $sc[0] != 'false') {
                 //remove the homegrown parameter only needed to activate
                 // the spellchecker in case of zero hits
                 $params->remove("swissbibspellcheck");
                 $this->active = true;
                 if (empty($this->dictionaries)) {
                     throw new \Exception('Spellcheck requested but no dictionary configured');
                 }
                 // Set relevant Solr parameters:
                 reset($this->dictionaries);
                 $params->set('spellcheck', 'true');
                 $params->set('spellcheck.dictionary', current($this->dictionaries));
                 // Turn on spellcheck.q generation in query builder:
                 $this->backend->getQueryBuilder()->setCreateSpellingQuery(true);
             }
         }
     }
     return $event;
 }
Beispiel #16
0
 public function onAfterSimpleMailerSend(EventInterface $event)
 {
     /** @var \Detail\Mail\Service\MailerInterface $mailer */
     $mailer = $event->getTarget();
     $message = $event->getParam('message');
     if ($message === null) {
         throw new RuntimeException(sprintf('Event "%s" is missing param "message"', $event->getName()));
     } elseif (!$message instanceof MessageInterface) {
         throw new RuntimeException(sprintf('Event "%s" has invalid value for param "message"; ' . 'expected Detail\\Mail\\Message\\MessageInterface object but got ' . is_object($message) ? get_class($message) : gettype($message), $event->getName()));
     }
     $headersText = preg_replace('/\\s+/', ' ', str_replace(PHP_EOL, ' ', var_export($message->getHeaders(), true)));
     if ($mailer instanceof SimpleMailer) {
         /** @var \Detail\Mail\Service\SimpleMailer $mailer */
         $driverClass = get_class($mailer->getDriver());
         switch ($driverClass) {
             case 'Detail\\Mail\\Driver\\Bernard\\BernardDriver':
                 $text = 'Queued email message "%s" of type "%s" (headers: "%s", driver: %s)';
                 break;
             default:
                 $text = 'Sent email message "%s" of type "%s" (headers: "%s", driver: %s)';
                 break;
         }
         $text = sprintf($text, $message->getId(), $message->getName(), $headersText, $driverClass);
     } else {
         $text = sprintf('Sent email message "%s" of type "%s" (headers: "%s")', $message->getId(), $message->getName(), $headersText);
     }
     $this->log($text);
 }
 /**
  * On BootStrap Listener for Book List Module
  * @param EventInterface $event Event Manager Object 
  */
 public function onBootstrap(EventInterface $event)
 {
     $appliaction = $event->getTarget();
     $serviceManager = $appliaction->getServiceManager();
     $appliaction->getEventManager()->attach(MvcEvent::EVENT_DISPATCH, function (MvcEvent $e) use($serviceManager) {
         $request = $e->getRequest();
         $response = $e->getResponse();
         if (!($request instanceof HttpRequest && $response instanceof HttpResponse)) {
             return;
             // we are not in HTTP context - CLI application?
         }
         $authAdapter = $serviceManager->get('AuthenticationAdapter');
         $authAdapter->setRequest($request);
         $authAdapter->setResponse($response);
         $result = $authAdapter->authenticate();
         // Then check the result of basic Http authentication
         if ($result->isValid()) {
             return;
             // erverything OK
         }
         // Otherwise return Access Denaid to Book List Site
         $response->setContent('Access Denied');
         $response->setStatusCode(HttpResponse::STATUS_CODE_401);
         $e->setResult($response);
         // short-circuit to application to end
         return false;
         // stop event propagation
     });
 }
Beispiel #18
0
 /**
  * Handle event. Add config values
  *
  * @param    EventInterface    $event
  * @return    EventInterface
  */
 public function onSearchPre(EventInterface $event)
 {
     $backend = $event->getTarget();
     if ($backend === $this->backend) {
         $params = $event->getParam('params');
         if ($params) {
             // Set highlighting parameters unless explicitly disabled:
             $hl = $params->get('hl');
             if (!isset($hl[0]) || $hl[0] != 'false') {
                 // Add hl.q for non query events
                 if (!$event->getParam('query', false)) {
                     $lastSearch = $this->memory->retrieve();
                     if ($lastSearch) {
                         $urlParams = parse_url($lastSearch);
                         parse_str($urlParams['query'], $queryParams);
                         if (isset($queryParams['lookfor'])) {
                             $params->set('hl.q', '*:"' . addslashes($queryParams['lookfor']) . '"');
                         }
                     }
                 }
                 // All all highlight config fields
                 foreach ($this->config as $key => $value) {
                     $params->set('hl.' . $key, $value);
                 }
             }
         }
     }
     return $event;
 }
Beispiel #19
0
 /**
  * {@inheritDoc}
  */
 public function onBootstrap(EventInterface $e)
 {
     $app = $e->getApplication();
     $sm = $app->getServiceManager();
     $config = $app->getConfig();
     // Set configuration options
     if ($phpSettings = $config['php_ini']) {
         foreach ($phpSettings as $key => $value) {
             ini_set($key, $value);
         }
     }
     $sharedEventManager = $sm->get('SharedEventManager');
     // Hook into comments
     $sharedEventManager->attach('theme', 'post.post', function ($e) use($sm) {
         $viewRenderer = $sm->get('ViewRenderer');
         return $viewRenderer->partial('socialog/comment/post', $e->getParams());
     });
     // Hook into comments
     $sharedEventManager->attach('view', 'navigation.render', function ($e) use($sm) {
         /* @var $pageMapper \Socialog\Mapper\PageMapper */
         $pageMapper = $sm->get('socialog_page_mapper');
         $result = "";
         foreach ($pageMapper->findAllPages() as $page) {
             $result .= new Theme\Menuitem($page->getTitle(), $e->getTarget()->url('socialog-page', array('id' => $page->getId())));
         }
         return $result;
     });
 }
 /**
  * {@inheritDoc}
  */
 public function onBootstrap(EventInterface $event)
 {
     /* @var \Zend\Mvc\Application $application */
     $application = $event->getTarget();
     $eventManager = $application->getEventManager();
     $eventManager->attach(new AuthorizationVaryListener());
 }
Beispiel #21
0
 /**
  * {@inheritDoc}
  */
 public function onBootstrap(EventInterface $event)
 {
     $config = $event->getTarget()->getServiceManager()->get('Config');
     $config = isset($config['airbrake']) ? $config['airbrake'] : array();
     /** @var Client $airbrake */
     $airbrake = $event->getTarget()->getServiceManager()->get('zf2_airbrake');
     $handler = new EventHandler($airbrake, $config['notifyOnWarning']);
     $handler->setInstance($handler);
     if (null !== $airbrake->getConfiguration()->get('errorReportingLevel')) {
         $handler->addErrorFilter(new ErrorReporting($airbrake->getConfiguration()));
     }
     $handler->addExceptionFilter(new AirbrakeExceptionFilter());
     set_error_handler(array($handler, 'onError'));
     set_exception_handler(array($handler, 'onException'));
     register_shutdown_function(array($handler, 'onShutdown'));
 }
Beispiel #22
0
 /**
  * Actually do the logging.
  *
  * @param EventInterface $event
  */
 public function log(EventInterface $event)
 {
     $params = $event->getParams();
     $method = '?';
     $exception = isset($params['exception']) ? $params['exception'] : '';
     $sql = isset($params['sql']) ? $params['sql'] : array();
     $this->logger->critical(get_class($event->getTarget()) . "::{$method} - {$exception}", $sql);
 }
 public function onBootstrap(EventInterface $e)
 {
     /* @var $application \Zend\Mvc\Application */
     $application = $e->getTarget();
     $eventManager = $application->getEventManager();
     $moduleRouteListener = new ModuleRouteListener();
     $moduleRouteListener->attach($eventManager);
 }
Beispiel #24
0
 /**
  * {@inheritDoc}
  */
 public function onBootstrap(EventInterface $event)
 {
     /* @var $application \Zend\Mvc\Application */
     $application = $event->getTarget();
     $serviceManager = $application->getServiceManager();
     $eventManager = $application->getEventManager();
     $eventManager->attach($serviceManager->get('ZfrCors\\Mvc\\CorsRequestListener'));
 }
 /**
  * Triggered on sendAction.
  *
  * @param EventInterface $event The triggered event
  */
 public function onSendAction(EventInterface $event)
 {
     if (!$this->connected) {
         /** @var \PamiModule\Service\Client $client */
         $client = $event->getTarget();
         $client->connect();
     }
 }
 /**
  * onFailure
  *
  * Event listener to handle unsuccessful authentication.
  *
  * @param EventInterface  $event  The authentication event.
  *
  * @return Request
  */
 public function onFailure(EventInterface $event)
 {
     /** @var  LoginControllerInterface $controller */
     $controller = $event->getTarget();
     //$controller->flashMessenger()->addErrorMessage('The username or password was incorrect.');
     $route = $controller->getRouteProvider()->getRoute('authentication.failure');
     $event->stopPropagation(true);
     return $controller->redirect()->toRoute($route);
 }
Beispiel #27
0
 public function onBootstrap(EventInterface $e)
 {
     $eventManager = $e->getApplication()->getEventManager();
     $moduleRouteListener = new ModuleRouteListener();
     $moduleRouteListener->attach($eventManager);
     $application = $e->getTarget();
     $serviceManager = $application->getServiceManager();
     $eventManager->attachAggregate($serviceManager->get('EventLogger\\Log\\Listener\\ListenerAggregate'));
 }
Beispiel #28
0
 private function setKey(EventInterface $e)
 {
     $params = $e->getParams();
     if (is_array($params) && array_key_exists('__RESULT__', $params)) {
         $this->_cache_result = $params['__RESULT__'];
         unset($params['__RESULT__']);
     }
     $this->_key = crc32(get_class($e->getTarget()) . '-' . json_encode($params));
 }
Beispiel #29
0
 public function onBootstrap(EventInterface $e)
 {
     $application = $e->getTarget();
     $eventManager = $application->getEventManager();
     $strategy = new RedirectionStrategy();
     $eventManager->attach($strategy);
     $moduleRouteListener = new ModuleRouteListener();
     $moduleRouteListener->attach($eventManager);
 }
Beispiel #30
0
 public function onReceivedNodeReceipt(EventInterface $e)
 {
     /** @var NodeInterface $node */
     $node = $e->getParam('node');
     /** @var Client $client */
     $client = $e->getTarget();
     $params = ['id' => $node->getAttribute('id'), 'node' => $node];
     $client->getEventManager()->trigger('onReceiptClient', $client, $params);
 }