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

[Example] Add trash functionality to custom entity #98

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

niklasnatter
Copy link
Contributor

What's in this PR?

This PR demonstrates how to integrate a custom entity with the SuluTrashBundle.

Screenshot 2021-12-21 at 12 37 09

@niklasnatter niklasnatter added the Example Example implementations label Dec 21, 2021
@niklasnatter niklasnatter force-pushed the example/custom-entity-trash branch from b65af15 to 7284179 Compare December 21, 2021 11:54
@niklasnatter niklasnatter force-pushed the example/custom-entity-trash branch from 7284179 to 4f1bcfe Compare January 13, 2022 12:59
@TheCadien
Copy link
Member

Did I do something wrong with my plementation or is something missing in the example.

I had to add the following tags to my TrashItemHandler.
sulu_trash.store_trash_item_handler , sulu_trash.restore_trash_item_handler, sulu_trash.restore_configuration_provider

@alexander-schranz
Copy link
Member

@TheCadien If you are in a bundle and not in a project you need to add the tags. In a project like here in the sulu demo the tags are automatically added because symfony uses autoconfigure for this in projects.

Which we did define here: https://github.com/sulu/sulu/blob/822b843b51ed99e0d8f90702c3da7f25fc4490c0/src/Sulu/Bundle/TrashBundle/Infrastructure/Symfony/DependencyInjection/SuluTrashExtension.php#L112
And is enabled here in symfony and sulu skeletons: https://github.com/sulu/skeleton/blob/2cb154888d20fd71022b8636a46015649cf05166/config/services.yaml#L10

For bundles it is normal that you don't use autowire or autoconfigure and need to define them manually (see also bundle best practices).

Why the tags are not required we still should add info box about them to the trash bundle documentation: https://docs.sulu.io/en/2.4/bundles/trash.html. Symfony it self is doing that a lot also in there cases. Like

When no autoconfigure is used the following ... tag need to be added to the service definition.

@TheCadien do you want to create a PR for the trash docs?

@TheCadien
Copy link
Member

Ahhhh I see.
Yes its for a Bundle :D !

Sure, I'll add an info box to the docs.
Thanks for the explanation @alexander-schranz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Example Example implementations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants