Skip to content

Ngstack 1017 iri template generation feature#2

Merged
emodric merged 9 commits into
masterfrom
NGSTACK-1017-iri-template-generation
Jan 19, 2026
Merged

Ngstack 1017 iri template generation feature#2
emodric merged 9 commits into
masterfrom
NGSTACK-1017-iri-template-generation

Conversation

@JakovKnezovicc

@JakovKnezovicc JakovKnezovicc commented Dec 17, 2025

Copy link
Copy Markdown
Contributor

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.

@JakovKnezovicc JakovKnezovicc self-assigned this Dec 17, 2025
@JakovKnezovicc JakovKnezovicc force-pushed the NGSTACK-1017-iri-template-generation branch from 7fa0502 to 892ad6a Compare January 15, 2026 09:52

try {
$content = json_encode($iriTemplates, JSON_THROW_ON_ERROR | JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
} catch (\JsonException) {

Copy link
Copy Markdown
Member

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);

Copy link
Copy Markdown
Member

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.

Comment thread src/Service/IriTemplatesService.php Outdated
) {}

/**
* @throws ResourceClassNotFoundException

Copy link
Copy Markdown
Member

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.

Comment thread src/Service/IriTemplatesService.php Outdated

use function preg_replace;

final readonly class IriTemplatesService

Copy link
Copy Markdown
Member

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.

Comment thread src/Service/IriTemplatesService.php Outdated
$iriTemplates = [];

foreach ($resourceClasses as $class) {
/** @var ApiResource $resourceMetadata */

Copy link
Copy Markdown
Member

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',

Copy link
Copy Markdown
Member

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(

Copy link
Copy Markdown
Member

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';

Copy link
Copy Markdown
Member

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.

@JakovKnezovicc JakovKnezovicc force-pushed the NGSTACK-1017-iri-template-generation branch from 892ad6a to 5845b9e Compare January 15, 2026 14:14
@JakovKnezovicc JakovKnezovicc force-pushed the NGSTACK-1017-iri-template-generation branch from 5845b9e to c4811ee Compare January 15, 2026 14:57
@JakovKnezovicc

Copy link
Copy Markdown
Contributor Author

prethodni komentari rijeseni u jednom commitu a36809a

Comment thread src/Service/IriTemplatesService.php Outdated
private ResourceMetadataCollectionFactoryInterface $resourceMetadataCollectionFactory,
private ResourceNameCollectionFactoryInterface $resourceExtractor,
private RouterInterface $router,
private readonly ResourceMetadataCollectionFactoryInterface $resourceMetadataCollectionFactory,

Copy link
Copy Markdown
Member

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.

Copy link
Copy Markdown
Contributor Author

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.

noted :) 6cb12a4

@emodric emodric merged commit a5a236c into master Jan 19, 2026
2 checks passed
@emodric emodric deleted the NGSTACK-1017-iri-template-generation branch January 19, 2026 12:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants