Skip to content

ParameterTransformer : populate a given parameter from another #28

@azurams

Description

@azurams

Given the following README.md documentation :

    #[Route(methods: ['GET'], pattern: 'user/{user}')]
    #[Transformer(
        transformer: UserEntityTransfomer::class),
        parameters: ['user' => User::class],  // changed from the documentation, @see #27
    )]
    public function userAction($request, $response, $user): ResponseInterface {}

I understand that the {user} placeholder name, the parameters key ['user => User::class]in #[Transformer attribute and the $user parameter name in the userActionmethod must be the same.

Is there a way, given the example beside, to have the UserEntityTransfomer populate into $user the entity the userAction method the retrieved entity from the {user_slug} placeholder parameter ?

    #[Route(methods: ['GET'], pattern: 'user/{user_slug}', placeholders: ['user_slug' => 'slug'])]
    #[Transformer(
        transformer: UserEntityTransfomer::class),
        parameters: ['user' => User::class],
    )]
    public function userAction($request, $response, User $user): ResponseInterface {}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions