/** * @param Relationship $relationship * * @return array */ protected function processRelationshipLinks($primaryObject, Relationship $relationship, $relationshipPayloadKey) { /** @var ClassMetadata $relationshipMetadata */ $primaryMetadata = $this->hateoasMetadataFactory->getMetadataForClass(get_class($primaryObject)); $primaryId = $this->getId($primaryMetadata, $primaryObject); $links = array(); // TODO: Improve this if ($relationship->getShowLinkSelf()) { $links['self'] = $this->baseUrl . '/' . $primaryMetadata->getResource()->getType() . '/' . $primaryId . '/relationships/' . $relationshipPayloadKey; } if ($relationship->getShowLinkRelated()) { $links['related'] = $this->baseUrl . '/' . $primaryMetadata->getResource()->getType() . '/' . $primaryId . '/' . $relationshipPayloadKey; } return $links; }
/** * @param Relationship $relationship * @return array */ protected function processRelationshipLinks($primaryObject, Relationship $relationship, $relationshipPayloadKey) { $propertyAccessor = PropertyAccess::createPropertyAccessor(); $primaryId = $propertyAccessor->getValue($primaryObject, 'id'); /** @var ClassMetadata $relationshipMetadata */ $primaryMetadata = $this->hateoasMetadataFactory->getMetadataForClass(get_class($primaryObject)); $links = array(); // TODO: Improve this if ($relationship->getShowLinkSelf()) { $links['self'] = '/' . $primaryMetadata->getResource()->getType() . '/' . $primaryId . '/relationships/' . $relationshipPayloadKey; } if ($relationship->getShowLinkRelated()) { $links['related'] = '/' . $primaryMetadata->getResource()->getType() . '/' . $primaryId . '/' . $relationshipPayloadKey; } return $links; }