| @@ 122-156 (lines=35) @@ | ||
| 119 | // do nothing |
|
| 120 | } |
|
| 121 | ||
| 122 | foreach ($this->propertyNameCollectionFactory->create($resourceClass) as $propertyName) { |
|
| 123 | $propertyMetadata = $this->propertyMetadataFactory->create($resourceClass, $propertyName); |
|
| 124 | ||
| 125 | $identifier = $propertyMetadata->isIdentifier(); |
|
| 126 | if (null === $identifier || false === $identifier) { |
|
| 127 | continue; |
|
| 128 | } |
|
| 129 | ||
| 130 | $identifiers[$propertyName] = $this->propertyAccessor->getValue($item, $propertyName); |
|
| 131 | ||
| 132 | if (!is_object($identifiers[$propertyName])) { |
|
| 133 | continue; |
|
| 134 | } |
|
| 135 | ||
| 136 | $relatedResourceClass = $this->getObjectClass($identifiers[$propertyName]); |
|
| 137 | $relatedItem = $identifiers[$propertyName]; |
|
| 138 | ||
| 139 | unset($identifiers[$propertyName]); |
|
| 140 | ||
| 141 | foreach ($this->propertyNameCollectionFactory->create($relatedResourceClass) as $relatedPropertyName) { |
|
| 142 | $propertyMetadata = $this->propertyMetadataFactory->create($relatedResourceClass, $relatedPropertyName); |
|
| 143 | ||
| 144 | if ($propertyMetadata->isIdentifier()) { |
|
| 145 | if (isset($identifiers[$propertyName])) { |
|
| 146 | throw new RuntimeException(sprintf('Composite identifiers not supported in "%s" through relation "%s" of "%s" used as identifier', $relatedResourceClass, $propertyName, $resourceClass)); |
|
| 147 | } |
|
| 148 | ||
| 149 | $identifiers[$propertyName] = $this->propertyAccessor->getValue($relatedItem, $relatedPropertyName); |
|
| 150 | } |
|
| 151 | } |
|
| 152 | ||
| 153 | if (!isset($identifiers[$propertyName])) { |
|
| 154 | throw new RuntimeException(sprintf('No identifier found in "%s" through relation "%s" of "%s" used as identifier', $relatedResourceClass, $propertyName, $resourceClass)); |
|
| 155 | } |
|
| 156 | } |
|
| 157 | ||
| 158 | if (isset($cacheItem)) { |
|
| 159 | try { |
|
| @@ 116-150 (lines=35) @@ | ||
| 113 | $identifiers = []; |
|
| 114 | $resourceClass = $this->getObjectClass($item); |
|
| 115 | ||
| 116 | foreach ($this->propertyNameCollectionFactory->create($resourceClass) as $propertyName) { |
|
| 117 | $propertyMetadata = $this->propertyMetadataFactory->create($resourceClass, $propertyName); |
|
| 118 | ||
| 119 | $identifier = $propertyMetadata->isIdentifier(); |
|
| 120 | if (null === $identifier || false === $identifier) { |
|
| 121 | continue; |
|
| 122 | } |
|
| 123 | ||
| 124 | $identifiers[$propertyName] = $this->propertyAccessor->getValue($item, $propertyName); |
|
| 125 | ||
| 126 | if (!is_object($identifiers[$propertyName])) { |
|
| 127 | continue; |
|
| 128 | } |
|
| 129 | ||
| 130 | $relatedResourceClass = $this->getObjectClass($identifiers[$propertyName]); |
|
| 131 | $relatedItem = $identifiers[$propertyName]; |
|
| 132 | ||
| 133 | unset($identifiers[$propertyName]); |
|
| 134 | ||
| 135 | foreach ($this->propertyNameCollectionFactory->create($relatedResourceClass) as $relatedPropertyName) { |
|
| 136 | $propertyMetadata = $this->propertyMetadataFactory->create($relatedResourceClass, $relatedPropertyName); |
|
| 137 | ||
| 138 | if ($propertyMetadata->isIdentifier()) { |
|
| 139 | if (isset($identifiers[$propertyName])) { |
|
| 140 | throw new RuntimeException(sprintf('Composite identifiers not supported in "%s" through relation "%s" of "%s" used as identifier', $relatedResourceClass, $propertyName, $resourceClass)); |
|
| 141 | } |
|
| 142 | ||
| 143 | $identifiers[$propertyName] = $this->propertyAccessor->getValue($relatedItem, $relatedPropertyName); |
|
| 144 | } |
|
| 145 | } |
|
| 146 | ||
| 147 | if (!isset($identifiers[$propertyName])) { |
|
| 148 | throw new RuntimeException(sprintf('No identifier found in "%s" through relation "%s" of "%s" used as identifier', $relatedResourceClass, $propertyName, $resourceClass)); |
|
| 149 | } |
|
| 150 | } |
|
| 151 | ||
| 152 | return $identifiers; |
|
| 153 | } |
|