FriendsOfSymfony/FOSElasticaBundle — pull request #681 by zarathustra323 (2014-08-05 20:52:56+00:00)
Title: Ensure Doctrine objects with collection (ReferenceMany) changes are updated in Elasticsearch

This PR adds support to the Doctrine Listener to ensure that when a Collection (e.g. ReferenceMany) is modified on an Object (Entity/Document) it is updated in Elasticsearch.

Use case:
- If Object A has a ReferenceMany that is modified (added to or removed from) it currently doesn't schedule an Elasticsearch update for Object A.
- This is because the UnitOfWork does not fire a postUpdate event on changes to collections, but rather must be processed postFlush as a Collection Update or Removal.

The update and insertion logic for scheduling an Object was moved into their own methods for reusability. These methods also now key the scheduled Object by its spl_object_hash. This was done to ensure that if an Object has multiple collection changes it is only sent to the ObjectPersister once.

Similar to @solocommand's getDoctrineObject, the getObjectManager, getUnitOfWork, and getCollectionChanges methods ensure that the appropriate getter is used to retrieve the corresponding service. These utilize method_exists checks since the interfaces don't define the methods (though they exist in both the ORM and ODM versions). Please view in-line docblocks for more information.