-
Notifications
You must be signed in to change notification settings - Fork 0
Ngstack 1017 iri template generation feature #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method does not actually throw anything.
src/Service/IriTemplatesService.php
Outdated
|
|
||
| use function preg_replace; | ||
|
|
||
| final readonly class IriTemplatesService |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need readonly.
src/Service/IriTemplatesService.php
Outdated
| $iriTemplates = []; | ||
|
|
||
| foreach ($resourceClasses as $class) { | ||
| /** @var ApiResource $resourceMetadata */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All PHPDoc should have FQCN.
| use const JSON_UNESCAPED_SLASHES; | ||
|
|
||
| #[AsCommand( | ||
| name: 'api-platform-extras:generate-iri-templates', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefix command names with netgen:
| use const JSON_THROW_ON_ERROR; | ||
| use const JSON_UNESCAPED_SLASHES; | ||
|
|
||
| #[AsCommand( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private const string can be used.
892ad6a to
5845b9e
Compare
…ature compiler pass
5845b9e to
c4811ee
Compare
|
prethodni komentari rijeseni u jednom commitu a36809a |
| private ResourceMetadataCollectionFactoryInterface $resourceMetadataCollectionFactory, | ||
| private ResourceNameCollectionFactoryInterface $resourceExtractor, | ||
| private RouterInterface $router, | ||
| private readonly ResourceMetadataCollectionFactoryInterface $resourceMetadataCollectionFactory, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I meant we don't need readonly, I meant at all :D It's just unnecessary noise.
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.