Exemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function toArray()
 {
     $array = $this->toIdentifier();
     if (!$this->isIdentifier()) {
         $array['attributes'] = $this->getAttributes();
     }
     $relationships = $this->getRelationshipsAsArray();
     if (count($relationships)) {
         $array['relationships'] = $relationships;
     }
     $links = [];
     if (!empty($this->links)) {
         $links = $this->links;
     }
     $serializerLinks = $this->serializer->getLinks($this->data);
     if (!empty($serializerLinks)) {
         $links = array_merge($serializerLinks, $links);
     }
     if (!empty($links)) {
         $array['links'] = $links;
     }
     $meta = [];
     if (!empty($this->meta)) {
         $meta = $this->meta;
     }
     $serializerMeta = $this->serializer->getMeta($this->data);
     if (!empty($serializerMeta)) {
         $meta = array_merge($serializerMeta, $meta);
     }
     if (!empty($meta)) {
         $array['meta'] = $meta;
     }
     return $array;
 }