| 1 | <?php |
||
| 36 | final class IriConverter implements IriConverterInterface |
||
| 37 | { |
||
| 38 | use ClassInfoTrait; |
||
| 39 | |||
| 40 | private $propertyNameCollectionFactory; |
||
| 41 | private $propertyMetadataFactory; |
||
| 42 | private $itemDataProvider; |
||
| 43 | private $routeNameResolver; |
||
| 44 | private $router; |
||
| 45 | private $propertyAccessor; |
||
| 46 | private $identifiersExtractor; |
||
| 47 | |||
| 48 | public function __construct(PropertyNameCollectionFactoryInterface $propertyNameCollectionFactory, PropertyMetadataFactoryInterface $propertyMetadataFactory, ItemDataProviderInterface $itemDataProvider, RouteNameResolverInterface $routeNameResolver, RouterInterface $router, PropertyAccessorInterface $propertyAccessor = null, IdentifiersExtractorInterface $identifiersExtractor = null) |
||
| 49 | { |
||
| 50 | $this->propertyNameCollectionFactory = $propertyNameCollectionFactory; |
||
| 51 | $this->propertyMetadataFactory = $propertyMetadataFactory; |
||
| 52 | $this->itemDataProvider = $itemDataProvider; |
||
| 53 | $this->routeNameResolver = $routeNameResolver; |
||
| 54 | $this->router = $router; |
||
| 55 | $this->propertyAccessor = $propertyAccessor ?? PropertyAccess::createPropertyAccessor(); |
||
| 56 | |||
| 57 | if (null === $identifiersExtractor) { |
||
| 58 | @trigger_error('Not injecting ItemIdentifiersExtractor is deprecated since API Platform 2.1 and will not be possible anymore in API Platform 3'); |
||
|
1 ignored issue
–
show
|
|||
| 59 | $this->identifiersExtractor = new IdentifiersExtractor($this->propertyNameCollectionFactory, $this->propertyMetadataFactory, $this->propertyAccessor); |
||
| 60 | } else { |
||
| 61 | $this->identifiersExtractor = $identifiersExtractor; |
||
| 62 | } |
||
| 63 | } |
||
| 64 | |||
| 65 | /** |
||
| 66 | * {@inheritdoc} |
||
| 67 | */ |
||
| 68 | public function getItemFromIri(string $iri, array $context = []) |
||
| 86 | |||
| 87 | /** |
||
| 88 | * {@inheritdoc} |
||
| 89 | */ |
||
| 90 | public function getIriFromItem($item, int $referenceType = UrlGeneratorInterface::ABS_PATH): string |
||
| 99 | |||
| 100 | /** |
||
| 101 | * {@inheritdoc} |
||
| 102 | */ |
||
| 103 | public function getIriFromResourceClass(string $resourceClass, int $referenceType = UrlGeneratorInterface::ABS_PATH): string |
||
| 111 | |||
| 112 | /** |
||
| 113 | * Generate the identifier url. |
||
| 114 | * |
||
| 115 | * @param array $identifiers |
||
| 116 | * |
||
| 117 | * @return string[] |
||
| 118 | */ |
||
| 119 | private function generateIdentifiersUrl(array $identifiers): array |
||
| 131 | } |
||
| 132 |
If you suppress an error, we recommend checking for the error condition explicitly: