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

Declare a separate ImagesUploadListener service #9310

Merged
merged 1 commit into from
Apr 19, 2018

Conversation

teohhanhui
Copy link
Contributor

@teohhanhui teohhanhui commented Apr 6, 2018

Q A
Branch? 1.1
Bug fix? no (docs improvement)
New feature? no
BC breaks? no
Deprecations? no
Related tickets N/A
License MIT

Don't override sylius.listener.images_upload, so that we don't have to duplicate tags that might change at anytime.

@Zales0123 Zales0123 added the Documentation Documentation related issues and PRs - requests, fixes, proposals. label Apr 6, 2018
class: Sylius\Bundle\CoreBundle\EventListener\ImagesUploadListener
decorates: sylius.listener.image_upload
arguments: ['@sylius.image_uploader']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we need @app.listener.image_upload.inner here now?

Copy link
Contributor Author

@teohhanhui teohhanhui Apr 6, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're not using it, because we're basically "abusing" service decoration. 😛

class: Sylius\Bundle\CoreBundle\EventListener\ImagesUploadListener
decorates: sylius.listener.image_upload
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I guess we should use parent: sylius.listener.image_upload here, then we can remove arguments (as they are inherited) and just include tags (as we're not really decorating the service).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tags are not inherited from the parent service. Or do you mean we should use decorates together with parent?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it'll work: symfony/symfony#14543

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC tags aren't inherited from the decorated service as well (for this PR, these product & taxon tags are still assigned to @app.listener.image_upload.inner and shipping method ones will be assigned to @app.listener.image_upload).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tags are copied over when decorating. See the referenced PR in the description. :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anyway, since we use decoration, anywhere sylius.listener.images_upload is used, it'll basically be replaced by app.listener.images_upload. The original service will not be used anymore. In fact, it will be automatically removed from the container if it's a private service and unused.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, and I just noticed the original typo in the service name (or it was changed). The free extra benefit we get by using decoration is that it'll fail if the service being decorated is not found. 😃

@teohhanhui teohhanhui force-pushed the docs/images-upload-listener-decorator branch from 566e9ec to 9b75032 Compare April 11, 2018 14:42
@teohhanhui
Copy link
Contributor Author

#9310 (comment):

Okay, I guess we should use parent: sylius.listener.image_upload here, then we can remove arguments (as they are inherited) and just include tags (as we're not really decorating the service).

I've just tried it, and using decorates and parent together seems to work fine. But do you think it's risky as it may be undocumented behaviour that could change at any time?

@teohhanhui
Copy link
Contributor Author

@pamil Any decision on this?

@pamil
Copy link
Contributor

pamil commented Apr 18, 2018

I just needed a while to test it out, it looks like decorates removes the tags from decorated service as well and parent works just fine.

Using decorates:
screen shot 2018-04-18 at 11 14 58
screen shot 2018-04-18 at 11 19 29

Using parent:
screen shot 2018-04-18 at 11 17 06

Don't override sylius.listener.images_upload
@teohhanhui teohhanhui changed the base branch from 1.0 to 1.1 April 18, 2018 17:18
@teohhanhui teohhanhui force-pushed the docs/images-upload-listener-decorator branch from 9b75032 to d24b2d4 Compare April 18, 2018 17:18
@teohhanhui teohhanhui changed the title Use decorator when overriding ImagesUploadListener service Declare a separate ImagesUploadListener service Apr 18, 2018
@teohhanhui
Copy link
Contributor Author

@pamil This should be good now. 😄

@pamil pamil merged commit d8d21da into Sylius:1.1 Apr 19, 2018
@pamil
Copy link
Contributor

pamil commented Apr 19, 2018

Thank you, Teoh! 🥇

@teohhanhui teohhanhui deleted the docs/images-upload-listener-decorator branch April 19, 2018 08:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation Documentation related issues and PRs - requests, fixes, proposals.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants