Beispiel #1
0
 /**
  * @internal
  */
 public function onRoute(\Zend\EventManager\EventInterface $e)
 {
     // Validate loglevel value. Invalid content will cause the route to fail
     // and trigger the usage message.
     if (!preg_match('/^(emerg|alert|crit|err|warn|notice|info|debug)?$/', $e->getRouteMatch()->getParam('loglevel'))) {
         $e->setError(\Zend\Mvc\Application::ERROR_ROUTER_NO_MATCH);
         $e->getTarget()->getEventManager()->trigger(\Zend\Mvc\MvcEvent::EVENT_DISPATCH_ERROR, $e);
     }
 }
Beispiel #2
0
 /**
  * @internal
  */
 public function onRoute(\Zend\EventManager\EventInterface $e)
 {
     // Validate loglevel value. Invalid content will cause the route to fail
     // and trigger the usage message.
     $logLevel = $e->getRouteMatch()->getParam('loglevel');
     if ($logLevel != '' and !\Zend\Validator\StaticValidator::execute($logLevel, 'Library\\LogLevel')) {
         $e->setError(\Zend\Mvc\Application::ERROR_ROUTER_NO_MATCH);
         $e->setName(\Zend\Mvc\MvcEvent::EVENT_DISPATCH_ERROR);
         $e->getTarget()->getEventManager()->triggerEvent($e);
     }
 }
Beispiel #3
0
 public static function flush(EventInterface $e)
 {
     try {
         if ($e->getTarget() instanceof EntityManager) {
             $em = $e->getTarget();
         } elseif ($e instanceof MvcEvent) {
             $em = $e->getApplication()->getServiceManager()->get('EntityManager');
         } else {
             throw new Exception\RuntimeException('No EntityManager instance available');
         }
         if (null !== $e->getParam('entity')) {
             $em->flush($e->getParam('entity'));
         } else {
             $em->flush();
         }
     } catch (\Exception $ex) {
         if (!$e instanceof MvcEvent) {
             throw $ex;
         }
         $e->setError(self::ERROR_FLUSH)->setParam('exception', $ex);
         $e->getApplication()->getEventManager()->trigger(MvcEvent::EVENT_DISPATCH_ERROR, $e);
     }
 }