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

Symfony messenger support #62

Open
norkunas opened this issue Mar 8, 2021 · 7 comments
Open

Symfony messenger support #62

norkunas opened this issue Mar 8, 2021 · 7 comments
Labels
enhancement New feature or request

Comments

@norkunas
Copy link
Collaborator

norkunas commented Mar 8, 2021

As the title says, it would be good if Symfony messenger would be supported out of the box :)

Currently we are using a custom message and a message handler, but there's a slight problem that it doesn't properly work for the document removal part from the index. To do a reall ->remove call we use $objectManager->getReference().
But then the call is delegated to Engine and calls $entity->getSearchableArray(); but as the entity is already removed, doctrine throws error that the entity not found because proxy tries to load it's information to normalize the searchable array.

@curquiza curquiza added the enhancement New feature or request label Mar 20, 2021
@codedge
Copy link
Contributor

codedge commented Jun 11, 2021

Sorry for being late to the party 😄

I would really like to see that implemented or implement on my own but I am lacking a bit the uses cases.

  1. Can you point me a bit towards the point in code where you have problems with your current solution?
  2. So each of these three events, postPersist, postUpdate, preRemove, should dispatch a message that can be consumed by a custom handler, that can be speci, right?

@norkunas
Copy link
Collaborator Author

@codedge sorry, forgot to reply 🙂

  1. The problem is that the document removal should be called with postRemove event not preRemove, because if doctrine would fail to delete the document would be lost.
  2. Yes :)

@codedge
Copy link
Contributor

codedge commented Jun 16, 2021

Sound good. I'll implement that, as it would make to usage of the package more attractive and open for more custom events per project/user with custom handlers.

@curquiza
Copy link
Member

Awesome!

@codedge
Copy link
Contributor

codedge commented Jun 21, 2021

@norkunas Just added a small fix to the current situation: You can now enable the postRemove doctrine event (and disable the preRemove).

The next thing is the Messenger integration.

@94noni
Copy link
Contributor

94noni commented Jun 22, 2021

What about dispatching internal bundle event instead?
And let external code listen/subscribe and do the job

@norkunas
Copy link
Collaborator Author

I'd say by default listen on doctrine events and add an option to enable messenger :)

bors bot added a commit that referenced this issue Jul 1, 2021
96: Option to listen to postRemove event r=curquiza a=codedge

This PR adds the option to listen to Doctrines `postRemove`. This is a result of the discussion in #62, a first step.

You can know specify in `meili_search.yml`:

```
meili_search:
    # One, or multiple of postPersist, postUpdate, preRemove, postRemove
    doctrineSubscribedEvents: ['postPersist', 'postUpdate', 'preRemove', 'postRemove'] 
```

@curquiza When merging this, we need to update the [wiki - Indexing automaticlly via ...](https://github.com/meilisearch/meilisearch-symfony/wiki/index-data-into-meilisearch#indexing-automatically-via-doctrine-events) 



Co-authored-by: Holger Lösken <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants