Пример #1
0
 public function canBeConstructedWithOnlyAnEmbed()
 {
     $relation = new Relation('self', null, 'foo');
     $this->assertSame('self', $relation->getName());
     $this->assertNull($relation->getHref());
     $this->assertEmpty($relation->getAttributes());
     $this->assertInstanceOf('Hateoas\\Configuration\\Embed', $relation->getEmbedded());
     $this->assertSame('foo', $relation->getEmbedded()->getContent());
 }
Пример #2
0
 public function shouldSkipEmbedded($object, Relation $relation, SerializationContext $context)
 {
     if (null === $relation->getEmbedded()) {
         return true;
     }
     if (null === $relation->getEmbedded()->getExclusion()) {
         return $this->shouldSkipRelation($object, $relation, $context);
     }
     return $this->shouldSkip($object, $relation->getEmbedded()->getExclusion(), $context);
 }
Пример #3
0
 private function patchAbsolute(Relation $relation, $absolute)
 {
     $href = $relation->getHref();
     if ($href instanceof Route) {
         $href = new Route($href->getName(), $href->getParameters(), $absolute, $href->getGenerator());
     }
     return new Relation($relation->getName(), $href, $relation->getEmbedded(), $relation->getAttributes(), $relation->getExclusion());
 }
 /**
  * @param Relation $relation
  * @return Relation
  */
 private function transformRelation(Relation $relation)
 {
     return new Relation($relation->getName(), $relation->getHref(), $relation->getEmbedded(), $relation->getAttributes(), $this->transformExclusion($relation->getExclusion()));
 }