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

Emit an event when a ContentWorkflow transition is flushed #129

Open
alexander-schranz opened this issue Mar 25, 2020 · 2 comments · May be fixed by #188
Open

Emit an event when a ContentWorkflow transition is flushed #129

alexander-schranz opened this issue Mar 25, 2020 · 2 comments · May be fixed by #188
Labels
DX Only affecting the end developer

Comments

@alexander-schranz
Copy link
Member

alexander-schranz commented Mar 25, 2020

The ContentWorkflow service allows to apply a transition on a contentRichEntity and given dimensionAttributes. For example, publishing the content of a specific language is possible by applying the publish transition of the ContentWorkflow.

The ContentWorkflow service builds upon the Symfony Workflow component. Therefore, the service already emits various events when a transition is applied. These allow to execute additional logic when a specific transition is executed inside of a project.

The existing events emitted by the ContentWorkflow service already cover a lot of cases. But in some cases it makes sense to execute the additional logic only if the changes of the transition are flushed to the database. For example, this makes sense when building a search index for some entity.

Executing something only if a transition is flushed is a tricky problem because the SuluContentBundle does not flush anything to the database by itself, but relies on the project to flush changes at an appropriate time. Unfortunately, this makes it hard to use the events of the ContentWorkflow service in the cases described above.

To solve this problem, we should implement a doctrine flush subscriber that listens to transition events and emits a new workflow event after the changes are flushed to the database (not sure about the naming.

@alexander-schranz alexander-schranz added the DX Only affecting the end developer label Mar 25, 2020
@niklasnatter niklasnatter changed the title Add post flush event for transitions Emit an event when a ContentWorkflow transition is flushed Mar 25, 2020
@niklasnatter
Copy link
Contributor

niklasnatter commented Mar 25, 2020

I would propose to implement a TransitionFlushListener (not sure about this name) that collects all workflow.[content workflow name].completed.[transition name] events.

When doctrine emits a postFlush event, we should emit a workflow.[content workflow name].flushed.[transition name] event for each collected event.

This would allow projects to listen on the workflow.[content workflow name].flushed.[transition name] event in the cases described in the issue.

@luca-rath
Copy link
Contributor

just want to raise some attention for this issue, because that nearly stumbled us again ... @sulu/core-team do you agree on @nnatter's suggestion? I think it would be a good solution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DX Only affecting the end developer
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants