diff --git a/module/ApiBundle/Component/Controller/ActionController/ApiController.php b/module/ApiBundle/Component/Controller/ActionController/ApiController.php index 10851eff3..7ab1e2ee5 100644 --- a/module/ApiBundle/Component/Controller/ActionController/ApiController.php +++ b/module/ApiBundle/Component/Controller/ActionController/ApiController.php @@ -101,14 +101,18 @@ public function onDispatch(MvcEvent $e) ) ) { $error = $this->error(401, 'You do not have sufficient permissions to access this resource'); - $error->setOptions($result->getOptions()); + if ($result instanceof \Laminas\View\Model\ViewModel) { + $error->setOptions($result->getOptions()); + } $e->setResult($error); return $error; } } else { $error = $this->error(401, 'No key or OAuth token was provided or the token was invalid'); - $error->setOptions($result->getOptions()); + if ($result instanceof \Laminas\View\Model\ViewModel) { + $error->setOptions($result->getOptions()); + } $e->setResult($error); return $error;