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

[MongoDB] Mercure support #3290

Merged
merged 3 commits into from Dec 20, 2019
Merged

Conversation

alanpoulain
Copy link
Member

Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? ye
Tickets N/A
License MIT
Doc PR N/A

Not really a new feature nor a bug fix. Mercure was not supported with MongoDB. This PR fixes it.
It seems it's also the case for the PurgeHttpCacheListener.

Copy link
Member

@dunglas dunglas left a comment

Choose a reason for hiding this comment

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

Nice one! This PR should target master as it's a new feature.


$uow = $eventArgs->getEntityManager()->getUnitOfWork();

foreach ($uow->getScheduledEntityInsertions() as $entity) {
Copy link
Member

@dunglas dunglas Nov 29, 2019

Choose a reason for hiding this comment

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

If the only difference between ODM and ORM is the method name, maybe could we merge all classes and do something like:

$methodName = eventArgs instanceof OdmOnFlushEventArgs ? getScheduledDocumentInsertions : getScheduledEntityInsertions;

foreach ($uow->$methodName() //...

WDYT?

Copy link
Member Author

Choose a reason for hiding this comment

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

I've no strong opinion about this. Calling a method dynamically is often considered a bad practice. And having a separate class allows to customize things easily without adding conditional statements.
But on the other hand it multiplies the number of classes and adds a complexity by having an inherited abstract class.

@alanpoulain
Copy link
Member Author

You think it should target master? I thought we could consider it like a bug fix since we didn't say that Mercure was only for ORM.

@dunglas
Copy link
Member

dunglas commented Nov 29, 2019

It's definitely a new feature :)
Regarding the dynamic call vs having 3 classes, I have no strong opinions either. I feel like having only one class will make the maintenance easier and the evolvability better, especially if we add new features at some points, such as JSON Patch support (partial updates).

@alanpoulain alanpoulain changed the base branch from 2.5 to master November 30, 2019 13:44
@alanpoulain alanpoulain force-pushed the mongodb-mercure branch 4 times, most recently from a3c29f7 to 6a2a4f4 Compare November 30, 2019 14:23
@alanpoulain
Copy link
Member Author

It targets master now. The code is merged inside one class too. I've added another commit in case we want to go back to the previous version (I think I prefer it).

@alanpoulain
Copy link
Member Author

@dunglas are you OK with the current implementation?

Copy link
Member

@dunglas dunglas left a comment

Choose a reason for hiding this comment

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

When the BC break will be handled! Nice one!!

@@ -8,7 +8,7 @@

<!-- Event listener -->

<service id="api_platform.doctrine.listener.mercure.publish" class="ApiPlatform\Core\Bridge\Doctrine\EventListener\PublishMercureUpdatesListener">
<service id="api_platform.doctrine.orm.listener.mercure.publish" class="ApiPlatform\Core\Bridge\Doctrine\EventListener\PublishMercureUpdatesListener">
Copy link
Member

Choose a reason for hiding this comment

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

It's a BC break isn't it? We should at least add a (deprecated) alias to the old service name.

Copy link
Member Author

Choose a reason for hiding this comment

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

Even if it's experimental?

Copy link
Contributor

Choose a reason for hiding this comment

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

Please, yes. The class is marked as experimental but not the definition, and I know that Arte rely on this for their doctrine-less implementation.

Copy link
Member

Choose a reason for hiding this comment

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

And it doesn't hurt. It's just one line to add, that will be dropped in 3.0.

@alanpoulain alanpoulain merged commit e773104 into api-platform:master Dec 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants