| @@ 103-133 (lines=31) @@ | ||
| 100 | /** |
|
| 101 | * {@inheritdoc} |
|
| 102 | */ |
|
| 103 | public function getResourceContext(string $resourceClass, int $referenceType = UrlGeneratorInterface::ABS_PATH) : array |
|
| 104 | { |
|
| 105 | $context = $this->getBaseContext($referenceType, $referenceType); |
|
| 106 | $resourceMetadata = $this->resourceMetadataFactory->create($resourceClass); |
|
| 107 | $prefixedShortName = sprintf('#%s', $resourceMetadata->getShortName()); |
|
| 108 | ||
| 109 | foreach ($this->propertyNameCollectionFactory->create($resourceClass) as $propertyName) { |
|
| 110 | $propertyMetadata = $this->propertyMetadataFactory->create($resourceClass, $propertyName); |
|
| 111 | ||
| 112 | if ($propertyMetadata->isIdentifier() && !$propertyMetadata->isWritable()) { |
|
| 113 | continue; |
|
| 114 | } |
|
| 115 | ||
| 116 | $convertedName = $this->nameConverter ? $this->nameConverter->normalize($propertyName) : $propertyName; |
|
| 117 | ||
| 118 | if (!$id = $propertyMetadata->getIri()) { |
|
| 119 | $id = sprintf('%s/%s', $prefixedShortName, $convertedName); |
|
| 120 | } |
|
| 121 | ||
| 122 | if (!$propertyMetadata->isReadableLink()) { |
|
| 123 | $context[$convertedName] = [ |
|
| 124 | '@id' => $id, |
|
| 125 | '@type' => '@id', |
|
| 126 | ]; |
|
| 127 | } else { |
|
| 128 | $context[$convertedName] = $id; |
|
| 129 | } |
|
| 130 | } |
|
| 131 | ||
| 132 | return $context; |
|
| 133 | } |
|
| 134 | ||
| 135 | public function getResourceContextUri(string $resourceClass, int $referenceType = UrlGeneratorInterface::ABS_PATH) : string |
|
| 136 | { |
|
| @@ 87-117 (lines=31) @@ | ||
| 84 | /** |
|
| 85 | * {@inheritdoc} |
|
| 86 | */ |
|
| 87 | public function getResourceContext(string $resourceClass, int $referenceType = UrlGeneratorInterface::ABS_PATH) : array |
|
| 88 | { |
|
| 89 | $context = $this->getBaseContext($referenceType, $referenceType); |
|
| 90 | $resourceMetadata = $this->resourceMetadataFactory->create($resourceClass); |
|
| 91 | $prefixedShortName = sprintf('#%s', $resourceMetadata->getShortName()); |
|
| 92 | ||
| 93 | foreach ($this->propertyNameCollectionFactory->create($resourceClass) as $propertyName) { |
|
| 94 | $propertyMetadata = $this->propertyMetadataFactory->create($resourceClass, $propertyName); |
|
| 95 | ||
| 96 | if ($propertyMetadata->isIdentifier() && !$propertyMetadata->isWritable()) { |
|
| 97 | continue; |
|
| 98 | } |
|
| 99 | ||
| 100 | $convertedName = $this->nameConverter ? $this->nameConverter->normalize($propertyName) : $propertyName; |
|
| 101 | ||
| 102 | if (!$id = $propertyMetadata->getIri()) { |
|
| 103 | $id = sprintf('%s/%s', $prefixedShortName, $convertedName); |
|
| 104 | } |
|
| 105 | ||
| 106 | if (!$propertyMetadata->isReadableLink()) { |
|
| 107 | $context[$convertedName] = [ |
|
| 108 | '@id' => $id, |
|
| 109 | '@type' => '@id', |
|
| 110 | ]; |
|
| 111 | } else { |
|
| 112 | $context[$convertedName] = $id; |
|
| 113 | } |
|
| 114 | } |
|
| 115 | ||
| 116 | return $context; |
|
| 117 | } |
|
| 118 | ||
| 119 | public function getResourceContextUri(string $resourceClass, int $referenceType = UrlGeneratorInterface::ABS_PATH) : string |
|
| 120 | { |
|