/**
  * @inheritDoc
  */
 public function handle(EventInterface $event)
 {
     if ($event instanceof MissingCallbackEvent) {
         $fff = self::fff();
         //! log
         self::dispatchEvent(new LogEvent(LoggerLevelEnum::ERROR(), LoggerTemplate::LOGGER_MESSAGE_JSONP_MISSING_CALLBACK, ['callback' => Utility::instance()->jsonpCallback(), 'verb' => $fff->get('VERB'), 'uri' => $fff->get('URI')]));
         //! error
         self::dispatchEvent(new ErrorEvent(ErrorEnum::ERROR500()));
     }
 }
 /**
  * @inheritDoc
  */
 public function handle(EventInterface $event)
 {
     if ($event instanceof VerbNotAllowedEvent) {
         $fff = self::fff();
         //! log
         self::dispatchEvent(new LogEvent(LoggerLevelEnum::ERROR(), LoggerTemplate::LOGGER_MESSAGE_VERB_NOT_ALLOWED, ['verb' => $fff->get('VERB'), 'pattern' => $fff->get('PATTERN')]));
         //! error
         self::dispatchEvent(new ErrorEvent(ErrorEnum::ERROR405()));
     }
 }
 /**
  * @param ErrorEnum $code
  * @return $this
  */
 public function setCode(ErrorEnum $code)
 {
     $this->code = (int) $code->getValue();
     return $this;
 }
 private function respond()
 {
     $data = $this->getData();
     if (!is_null($data)) {
         /** @var AbstractResponder $responder */
         $responder = !!$this->responder ? $this->responder : $this->getResponder();
         if ($responder instanceof ResponderInterface) {
             //! we set the rest serializable object to the responder
             $responder->setData($data);
             //! we flush output buffer; prevents messy outputs
             //! runs only in production environment which is defined
             //! by FatFreeFramework 'DEBUG' configuration property
             $this->flushOutputBuffer();
             //! emit the response
             $responder->respond($this->getEncoder());
         } else {
             /** todo Need to create own event */
             $this->dispatchEvent(new ErrorEvent(ErrorEnum::ERROR500()));
         }
     }
 }
 /**
  * @return ErrorEvent
  */
 public function getErrorEvent()
 {
     return new ErrorEvent(ErrorEnum::ERROR403());
 }