Ngstack 1017 iri template generation feature#2
Conversation
7fa0502 to
892ad6a
Compare
|
|
||
| try { | ||
| $content = json_encode($iriTemplates, JSON_THROW_ON_ERROR | JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); | ||
| } catch (\JsonException) { |
There was a problem hiding this comment.
Root classes like these should also be imported with use JsonException.
| IriTemplatesService::class, | ||
| new Definition(IriTemplatesService::class), | ||
| ) | ||
| ->setAutowired(true); |
There was a problem hiding this comment.
In general, autowiring should not be used in vendor libraries because autowiring should always be opt-in for project developers.
src/Service/IriTemplatesService.php
Outdated
| ) {} | ||
|
|
||
| /** | ||
| * @throws ResourceClassNotFoundException |
There was a problem hiding this comment.
The method does not actually throw anything.
src/Service/IriTemplatesService.php
Outdated
|
|
||
| use function preg_replace; | ||
|
|
||
| final readonly class IriTemplatesService |
src/Service/IriTemplatesService.php
Outdated
| $iriTemplates = []; | ||
|
|
||
| foreach ($resourceClasses as $class) { | ||
| /** @var ApiResource $resourceMetadata */ |
| use const JSON_UNESCAPED_SLASHES; | ||
|
|
||
| #[AsCommand( | ||
| name: 'api-platform-extras:generate-iri-templates', |
There was a problem hiding this comment.
Prefix command names with netgen:
| use const JSON_THROW_ON_ERROR; | ||
| use const JSON_UNESCAPED_SLASHES; | ||
|
|
||
| #[AsCommand( |
There was a problem hiding this comment.
This will almost certainly clash with service definition in compiler pass.
|
|
||
| final class IriTemplateGeneratorCompilerPass implements CompilerPassInterface | ||
| { | ||
| private const FEATURE_ENABLED_PARAMETER = 'netgen_api_platform_extras.features.iri_template_generator.enabled'; |
There was a problem hiding this comment.
private const string can be used.
892ad6a to
5845b9e
Compare
…ature compiler pass
5845b9e to
c4811ee
Compare
|
prethodni komentari rijeseni u jednom commitu a36809a |
src/Service/IriTemplatesService.php
Outdated
| private ResourceMetadataCollectionFactoryInterface $resourceMetadataCollectionFactory, | ||
| private ResourceNameCollectionFactoryInterface $resourceExtractor, | ||
| private RouterInterface $router, | ||
| private readonly ResourceMetadataCollectionFactoryInterface $resourceMetadataCollectionFactory, |
There was a problem hiding this comment.
When I meant we don't need readonly, I meant at all :D It's just unnecessary noise.
There was a problem hiding this comment.
When I meant we don't need readonly, I meant at all :D It's just unnecessary noise.
noted :) 6cb12a4
Adds command and service for generating iri templates in json format using dumper.
Included to container build if enabled as a feature in config passed via container parameter.