コード例 #1
0
ファイル: Document.php プロジェクト: brzuchal/json-api
 /**
  * @inheritdoc
  */
 public function addError(ErrorInterface $error)
 {
     $errorId = ($errorId = $error->getId()) === null ? null : (string) $errorId;
     $representation = array_filter([self::KEYWORD_ERRORS_ID => $errorId, self::KEYWORD_ERRORS_LINKS => $this->presenter->getLinksRepresentation($this->urlPrefix, $error->getLinks()), self::KEYWORD_ERRORS_STATUS => $error->getStatus(), self::KEYWORD_ERRORS_CODE => $error->getCode(), self::KEYWORD_ERRORS_TITLE => $error->getTitle(), self::KEYWORD_ERRORS_DETAIL => $error->getDetail(), self::KEYWORD_ERRORS_SOURCE => $error->getSource(), self::KEYWORD_ERRORS_META => $error->getMeta()], function ($value) {
         return $value !== null;
     });
     $this->errors[] = (object) $representation;
 }
コード例 #2
0
ファイル: Error.php プロジェクト: cloudcreativity/json-api
 /**
  * @inheritdoc
  */
 public function merge(ErrorInterface $error)
 {
     // Id
     if ($error->getId()) {
         $this->setId($error->getId());
     }
     // Links
     if ($error->getLinks()) {
         $this->addLinks($error->getLinks());
     }
     // Status
     if ($error->getStatus()) {
         $this->setStatus($error->getStatus());
     }
     // Code
     if ($error->getCode()) {
         $this->setCode($error->getCode());
     }
     // Title
     if ($error->getTitle()) {
         $this->setTitle($error->getTitle());
     }
     // Detail
     if ($error->getDetail()) {
         $this->setDetail($error->getDetail());
     }
     // Source
     if ($error->getSource()) {
         $this->setSource($error->getSource());
     }
     // Meta
     if ($error->getMeta()) {
         $this->addMeta($error->getMeta());
     }
     return $this;
 }