/** * @param LifecycleEventArgs $args */ public function postUpdate(LifecycleEventArgs $args) { $document = $args->getDocument(); try { $doctrineChangeSet = $args->getDocumentManager()->getUnitOfWork()->getDocumentChangeSet($document); if (count($this->solr->computeChangeSet($doctrineChangeSet, $document)) === 0) { return; } $this->solr->updateDocument($document); } catch (\RuntimeException $e) { $this->logger->debug($e->getMessage()); } }
/** * @param LifecycleEventArgs $args * * @return bool */ private function hasChanged(LifecycleEventArgs $args) { $entity = $args->getEntity(); $doctrineChangeSet = $args->getEntityManager()->getUnitOfWork()->getEntityChangeSet($entity); return count($this->solr->computeChangeSet($doctrineChangeSet, $entity)) > 0; }