/** * @covers Imbo\Model\Error::getDate * @covers Imbo\Model\Error::setDate */ public function testCanSetAndGetDate() { $date = new DateTime(); $this->assertNull($this->model->getDate()); $this->assertSame($this->model, $this->model->setDate($date)); $this->assertSame($date, $this->model->getDate()); }
/** * Set an error model and update some parts of the response object * * @param Model\Error $error An error model instance * @return Response */ public function setError(Model\Error $error) { $errorMessage = $error->getErrorMessage(); $this->headers->add(array('X-Imbo-Error-Message' => $errorMessage, 'X-Imbo-Error-InternalCode' => $error->getImboErrorCode(), 'X-Imbo-Error-Date' => $error->getDate()->format('D, d M Y H:i:s') . ' GMT')); $this->setStatusCode($error->getHttpCode(), $errorMessage)->setEtag(null)->setLastModified(null); $this->setModel($error); return $this; }
/** * {@inheritdoc} */ public function formatError(Model\Error $model) { $data = array('error' => array('code' => $model->getHttpCode(), 'message' => $model->getErrorMessage(), 'date' => $this->dateFormatter->formatDate($model->getDate()), 'imboErrorCode' => $model->getImboErrorCode())); if ($imageIdentifier = $model->getImageIdentifier()) { $data['imageIdentifier'] = $imageIdentifier; } return $this->encode($data); }
/** * {@inheritdoc} */ public function formatError(Model\Error $model) { $imageIdentifierXml = ''; if ($imageIdentifier = $model->getImageIdentifier()) { $imageIdentifierXml = '<imageIdentifier>' . $imageIdentifier . '</imageIdentifier>'; } return <<<ERROR <?xml version="1.0" encoding="UTF-8"?> <imbo> <error> <code>{$model->getHttpCode()}</code> <message>{$model->getErrorMessage()}</message> <date>{$this->dateFormatter->formatDate($model->getDate())}</date> <imboErrorCode>{$model->getImboErrorCode()}</imboErrorCode> </error> {$imageIdentifierXml} </imbo> ERROR; }