/** * @return void */ public function init() { $this->addEventListener(Event\Type\Http\Request::toType(), function ($event) { if ($event->getPhase() == Event\PHASE_DOWN) { return $this->onBeforeExecution($event); } else { if ($event->getPhase() == Event\PHASE_UP) { return $this->onAfterExecution($event); } } }); }
/** * @return void */ public function init() { parent::init(); $this->addEventListener(Event\Type\Http\Request::toType(), function ($event) { $this->onHttpRequest($event); }); $this->addEventListener(Event\Type\Http\Response200::toType(), function ($event) { $requestEvent = $event->getLastDispatchedEvent(); $execResult = $requestEvent->getResult(); return $this->onResponse200($event, $execResult); }); $extendable = $this->getExtendableInstance(); if ($extendable) { $routeAnnot = $extendable->getRouteAnnotation(); $ctrlMethodAnnot = $extendable->getControllerMethodAnnotation(); $this->setControllerMethod($ctrlMethodAnnot->getMethodName()); $this->setAllowedHttpMethods($routeAnnot->getAllowedHttpMethods()); $this->setURIMatchRegExp($routeAnnot->getURIMatchRegExp()); $this->setURIMatchPattern($routeAnnot->getMatchPattern()); $validator = $this->instantiateValidator(); $this->setValidator($validator); } }