File tree Expand file tree Collapse file tree 4 files changed +19
-2
lines changed Expand file tree Collapse file tree 4 files changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -536,6 +536,7 @@ protected function getPersistenceNode()
536536 ->scalarNode ('update ' )->defaultTrue ()->end ()
537537 ->scalarNode ('delete ' )->defaultTrue ()->end ()
538538 ->scalarNode ('flush ' )->defaultTrue ()->end ()
539+ ->booleanNode ('immediate ' )->defaultFalse ()->end ()
539540 ->scalarNode ('logger ' )
540541 ->defaultFalse ()
541542 ->treatNullLike ('fos_elastica.logger ' )
Original file line number Diff line number Diff line change @@ -581,7 +581,7 @@ private function getDoctrineEvents(array $typeConfig)
581581 'insert ' => array (constant ($ eventsClass .'::postPersist ' )),
582582 'update ' => array (constant ($ eventsClass .'::postUpdate ' )),
583583 'delete ' => array (constant ($ eventsClass .'::preRemove ' )),
584- 'flush ' => array (constant ($ eventsClass .'::postFlush ' )),
584+ 'flush ' => array ($ typeConfig [ ' listener ' ][ ' immediate ' ] ? constant ( $ eventsClass . ' ::preFlush ' ) : constant ($ eventsClass .'::postFlush ' )),
585585 );
586586
587587 foreach ($ eventMapping as $ event => $ doctrineEvents ) {
Original file line number Diff line number Diff line change @@ -127,7 +127,8 @@ Below is an example for the Doctrine ORM.
127127 driver: orm
128128 model: Acme\A pplicationBundle\E ntity\U ser
129129 provider: ~
130- listener: ~
130+ listener:
131+ immediate: ~
131132 finder: ~
132133` ` `
133134
Original file line number Diff line number Diff line change @@ -325,6 +325,21 @@ You can also choose to only listen for some of the events:
325325
326326> **Propel** doesn't support this feature yet.
327327
328+ Flushing Method
329+ ---------------
330+
331+ FOSElasticaBundle, since 3.0.0 performs its indexing in the postFlush Doctrine event
332+ instead of prePersist and preUpdate which means that indexing will only occur when there
333+ has been a successful flush. This new default makes more sense but in the instance where
334+ you want to perform indexing before the flush is confirmed you may set the `immediate`
335+ option on a type persistence configuration to `true`.
336+
337+ ` ` ` yaml
338+ persistence:
339+ listener:
340+ immediate: true
341+ ` ` `
342+
328343Logging Errors
329344--------------
330345
You can’t perform that action at this time.
0 commit comments