You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description
I have a custom ULID converter to add prefixes to routes, similar to Stripe's ID system. I have it working with URIs using api_platform.uri_variables.transformer which allows me to read using a prefixed ULID. However, the IRI still stays the same.
A normalizer for individual ULIDs, PrefixedUlidNormalizer hooked via serializer.normalizerserializer.denormalizer and serializer.normalizer.uid
A transformer for URI variables PrefixedUlidUriVariableTransformer (implements UriVariableTransformerInterface) using api_platform.uri_variables.transformer
Both of these work for the URLs to get individual resources, but do not affect the @id IRI.
How to reproduce
Any object with a prefix in extraProperties and a registered Uri Variable Transformer
#[ApiResource([
...
extraProperties: [
'prefix' => 'que'
]
)]
class Question
{
#[ORM\Id]
#[ORM\Column(type: UlidType::NAME, unique: true)]
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
#[ORM\CustomIdGenerator(class: UlidGenerator::class)]
#[Context(['prefix' => 'que'])] // This is for the individual property, not the IRI
#[Groups('question:read:basic')]
public ?Ulid$ulid = null;
}
Possible Solution
Having looked through the source code, I couldn't find the correct place for this to go. Potentially normalizing inside the IdentifiersExtractor::resolveIdentifierValue() method.
Additional Context N/A
Any help on this is greatly appreciated.
The text was updated successfully, but these errors were encountered:
@soyuka is this more of an issue of the transformers not being used for the IRI converter? Such as I already have my URI varible transformer, but this isn't used for the @id property.
Would you be able to link to me to an example of how to do this?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
API Platform version(s) affected: 4.0.0
Description
I have a custom ULID converter to add prefixes to routes, similar to Stripe's ID system. I have it working with URIs using
api_platform.uri_variables.transformer
which allows me to read using a prefixed ULID. However, the IRI still stays the same.returns
Currently I have two files for this:
PrefixedUlidNormalizer
hooked viaserializer.normalizer
serializer.denormalizer
andserializer.normalizer.uid
PrefixedUlidUriVariableTransformer
(implementsUriVariableTransformerInterface
) usingapi_platform.uri_variables.transformer
Both of these work for the URLs to get individual resources, but do not affect the
@id
IRI.How to reproduce
Any object with a prefix in extraProperties and a registered Uri Variable Transformer
Possible Solution
Having looked through the source code, I couldn't find the correct place for this to go. Potentially normalizing inside the
IdentifiersExtractor::resolveIdentifierValue()
method.Additional Context
N/A
Any help on this is greatly appreciated.
The text was updated successfully, but these errors were encountered: