public function preFlush(PreFlushEventArgs $event)
    {
        $em = $event->getEntityManager();
        $uow = $em->getUnitOfWork();

        /*
         * We need to use the IdentityMap, because the update and persist collection stores entities, that have
         * computed changes, but translation data might have changed without changing it underlying model!
         */
        foreach($uow->getIdentityMap() as $className) {
            foreach($className as $object) {
                $this->translator->storeTranslationData($object);
            }
        }
    }
public function preFlush(PreFlushEventArgs $event)
    {
        $em = $event->getEntityManager();
        $uow = $em->getUnitOfWork();

        /*
         * We need to use the IdentityMap, because the update and persist collection stores entities, that have
         * computed changes, but translation data might have changed without changing it underlying model!
         */
        foreach($uow->getIdentityMap() as $className) {
            foreach($className as $object) {
                $this->translator->storeTranslationData($object);
            }
        }
    }
public function preFlush ( PreFlushEventArgs $ event ) { $ em = $ event -> getEntityManager ( ) ; $ uow = $ em -> getUnitOfWork ( ) ; /*
         * We need to use the IdentityMap, because the update and persist collection stores entities, that have
         * computed changes, but translation data might have changed without changing it underlying model!
         */ foreach ( $ uow -> getIdentityMap ( ) as $ className ) { foreach ( $ className as $ object ) { $ this -> translator -> storeTranslationData ( $ object ) ; } } }
Before flushing the data, we have to check if some translation data was stored for an object.

@param PreFlushEventArgs $event
Before flushing the data we have to check if some translation data was stored for an object .