Example #1
0
 /**
  * @param  object $object
  * @param  Metadata $metadata
  * @return Collection
  */
 public function createCollectionFromMetadata($object, Metadata $metadata)
 {
     $halCollection = new Collection($object);
     $halCollection->setCollectionName($metadata->getCollectionName());
     $halCollection->setCollectionRoute($metadata->getRoute());
     $halCollection->setEntityRoute($metadata->getEntityRoute());
     $halCollection->setRouteIdentifierName($metadata->getRouteIdentifierName());
     $halCollection->setEntityIdentifierName($metadata->getEntityIdentifierName());
     $links = $halCollection->getLinks();
     $this->marshalMetadataLinks($metadata, $links);
     $forceSelfLink = $metadata->getForceSelfLink();
     if ($forceSelfLink && !$links->has('self') && ($metadata->hasUrl() || $metadata->hasRoute())) {
         $link = $this->marshalLinkFromMetadata($metadata, $object);
         $links->add($link);
     }
     return $halCollection;
 }