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

Add getSection at ResourceControllerEvent #109

Open
igormukhingmailcom opened this issue Sep 17, 2019 · 6 comments
Open

Add getSection at ResourceControllerEvent #109

igormukhingmailcom opened this issue Sep 17, 2019 · 6 comments

Comments

@igormukhingmailcom
Copy link

Describe the proposed solution
Add setSection to ResourceControllerEvent and pass section from request configuration:

        // sylius/resource-bundle/src/Bundle/Controller/EventDispatcher.php
        // ...
        $event = new ResourceControllerEvent($resource);
        $event->setSection($requestConfiguration->getSection());

Alternative solution
Add whole requestConfiguration to event.

Additional context
When we subscribe to (for example) sylius.product.show event to embed some tracker html code like Google tag manager - we don't want to embed it at admin area. So we should somehow know what section (shop, admin, admin_api, etc) we're at to skip non-shop sections.

I will provide PR if this idea looks good for core team.

@lchrusciel lchrusciel transferred this issue from Sylius/Sylius Sep 26, 2019
@lchrusciel
Copy link
Member

Adding a section may be a good starting point, but whole RequestConfiguration makes a lot of sense as well.

@stefandoorn
Copy link
Contributor

I would say it's best to sends in the whole requestConfiguration - makes it more flexible and it's strongly typed anyway. If someone wants to know other things besides the section, it can also be used.

@vvasiloi
Copy link
Contributor

vvasiloi commented Sep 27, 2019

@stefandoorn @lchrusciel I find it quite annoying that a lot of resource layer services require the request configuration, even though they often only need 1-3 parameters to do their job.
It makes it hard to reuse these services outside of the standard workflow which starts in a resource controller.
But in this case it kind of make sense.

@lchrusciel
Copy link
Member

lchrusciel commented Sep 27, 2019

@vvasiloi I totally can understand your point. Maybe this configuration should not be a part of an event, but easily available through container?

Forced coupling of logic to ResourceController is something that we should totally work on and improve in the future.

@vvasiloi
Copy link
Contributor

It's kind of already available through the container: @sylius.resource_controller.request_configuration_factory + @sylius.resource_registry

@loevgaard
Copy link
Contributor

I still think the initial idea is good, but for people having the problem I fixed this like this here: https://github.com/Setono/SyliusFacebookTrackingPlugin/blob/master/src/EventListener/TagSubscriber.php#L69

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

5 participants