/** * Collect changes that were done * Generates tags and store in protected variable * * @param OnFlushEventArgs $event */ public function onFlush(OnFlushEventArgs $event) { if (!$this->isApplicationInstalled) { return; } $em = $event->getEntityManager(); $uow = $em->getUnitOfWork(); $entities = array_merge($uow->getScheduledEntityDeletions(), $uow->getScheduledEntityInsertions(), $uow->getScheduledEntityUpdates()); $collections = array_merge($uow->getScheduledCollectionUpdates(), $uow->getScheduledCollectionDeletions()); foreach ($collections as $collection) { $owner = $collection->getOwner(); if (!in_array($owner, $entities, true)) { $entities[] = $owner; } } $generator = $this->sender->getGenerator(); foreach ($entities as $entity) { if (!in_array(ClassUtils::getClass($entity), $this->skipTrackingFor)) { // invalidate collection view pages only when entity has been added or removed $includeCollectionTag = $uow->isScheduledForInsert($entity) || $uow->isScheduledForDelete($entity); $this->collectedTags = array_merge($this->collectedTags, $generator->generate($entity, $includeCollectionTag)); } } $this->collectedTags = array_unique($this->collectedTags); }
public function testGetGenerator() { $this->assertSame($this->generator, $this->sender->getGenerator(), 'Should return generator chain object'); }