Skip to content
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

Working without sensio extra framework #90

Open
phillamarmotte opened this issue Jun 30, 2023 · 3 comments
Open

Working without sensio extra framework #90

phillamarmotte opened this issue Jun 30, 2023 · 3 comments

Comments

@phillamarmotte
Copy link

Hi,
I find an issue when we removed the deprecated sensioExtraFramework.
The $request->attributes does not have the entity name ($varName) property.
So it can't resolve the title like {user.username}.

I think i can decorate an event to fix add it but it seems a bad solution.

Best regards

@rvanlaak
Copy link
Collaborator

FYI: The annotations you refer to were added to the symfony core a while back, but with this bundle some of the older Symfony versions that did not have the annotations in core are still supported. So, dropping that dependency on sensio-framework-extra-bundle would require bumping the requirements.

@phillamarmotte
Copy link
Author

OK. thank you for the answer.

@phillamarmotte
Copy link
Author

phillamarmotte commented Jul 5, 2023

Hi,
For information and if it can help anyone, I find a way to make it work without bumping the requirement.
But it can work only in changing the event listening in the apiBreadcrumbTrailBundle service.xml

kernel.controller => kernel.controller_argument

edit : You can overide the event in the app service.yaml this way.

  APY\BreadcrumbTrailBundle\EventListener\BreadcrumbListener:
    tags:
      - { name: kernel.event_listener, event: kernel.controller_arguments, method: onKernelController, priority: -1 }


and decorate the ValueResolverInterface in my code to simulate the old sensio-framework-extra-bundle behavior

<?php

namespace App\ArgumentResolver;

#[AsDecorator('doctrine.orm.entity_value_resolver')]
class SensioExtraFrameworkBehaviorEntityValueResolver implements ValueResolverInterface
{
    public function __construct(
        #[AutowireDecorated] private readonly EntityValueResolver $inner
    ) {
    }

    public function resolve(Request $request, ArgumentMetadata $argument): array
    {
        $object = $this->inner->resolve($request, $argument);

        if (!empty($object)) {
            $request->attributes->set($argument->getName(), $object[0]);
        }

        return $object;
    }
}

this way the $request->attributes contain the resolved entity and everything works like before

Best regards

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

No branches or pull requests

2 participants