Zend\Mvc\MvcEvent::isError PHP Method

isError() public method

Does the event represent an error response?
public isError ( ) : boolean
return boolean
    public function isError()
    {
        return (bool) $this->getParam('error', false);
    }

Usage Example

コード例 #1
0
 /**
  * Listen to the render event
  *
  * @param MvcEvent $e
  */
 public static function onRender(MvcEvent $e)
 {
     if (!$e->isError()) {
         return;
     }
     if (self::$acceptFilter != '*') {
         $headers = $e->getRequest()->getHeaders();
         if (!$headers->has('Accept')) {
             return;
         }
         $match = $headers->get('Accept')->match(self::$acceptFilter);
         if (!$match || $match->getTypeString() == '*/*') {
             return;
         }
     }
     $model = $e->getResult();
     if (!$model instanceof ModelInterface) {
         return;
     }
     $exception = $model->getVariable('exception');
     if (!$exception instanceof Exception) {
         return;
     }
     $jsonModel = new JsonModel(array('api-problem' => new ApiProblem($exception->getCode(), $exception)));
     $e->setResult($jsonModel);
     $e->setViewModel($jsonModel);
 }
All Usage Examples Of Zend\Mvc\MvcEvent::isError