This is called for public schema when structure is changed in draft schema
@param NestedSetEventArgs $eventArgs
541545
public function nestedSetPostMove(NestedSetEventArgs $eventArgs)
	{
		$entity = $eventArgs->getEntity();
		$this->em = $eventArgs->getEntityManager();
		$this->unitOfWork = $this->em->getUnitOfWork();

		if ($entity instanceof Page) {
			$changedLocalizations = $this->pageChange($entity, true);

			foreach ($changedLocalizations as $changedLocalization) {
				$this->em->flush($changedLocalization);
			}
		}
	}
327575
public function postRemoveEntity(LifecycleEventArgs $eventArgs)
    {
        $file = $eventArgs->getDocument();
        if (!$file instanceof Attachment) {
            return;
        }
        
        $dm     = $eventArgs->getDocumentManager();
        //$repo   = $dm->getRepository('Applications\Entity\Application');

        $fileId = new \MongoId($file->id);
        
        $dm->createQueryBuilder('Applications\Entity\Application')
           ->update()->multiple(true)
           ->field('attachments')->equals($fileId)->pull($fileId)
           ->getQuery()->execute();
        
        
        $dm->createQueryBuilder('Applications\Entity\Application')
           ->update()->multiple(true)
           ->field('contact.image')->equals($fileId)->set(null)
           ->getQuery()->execute();
    }
985486
public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs)
    {
        $metadata = $eventArgs->getClassMetadata();

        if ($metadata->getName() === self::ROOT_CHARACTERISTICS_CLASS) {
            $metadata->setDiscriminatorMap($this->characteristicsClassesMap);
        }
    }
1061951
public function preUpdate(LifecycleEventArgs $eventArgs)
    {
        $entity = $eventArgs->getObject();

        if (!$this->hasTrait($entity, 'Blast\BaseEntitiesBundle\Entity\Traits\Timestampable')) {
            return;
        }

        $this->logger->debug(
            '[TimestampableListener] Entering TimestampableListener for « preUpdate » event'
        );

        $now = new DateTime('NOW');
        $entity->setUpdatedAt($now);
    }
78693
public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs)
    {
        /** @var ClassMetadata $metadata */
        $metadata = $eventArgs->getClassMetadata();

        $reflectionClass = $metadata->getReflectionClass();

        if (!$reflectionClass || !$this->hasTrait($reflectionClass, 'Blast\BaseEntitiesBundle\Entity\Traits\Timestampable')) {
            return;
        } // return if current entity doesn't use Timestampable trait

        // Check if parents already have the Timestampable trait
        foreach ($metadata->parentClasses as $parent) {
            if ($this->classAnalyzer->hasTrait($parent, 'Blast\BaseEntitiesBundle\Entity\Traits\Timestampable')) {
                return;
            }
        }

        $this->logger->debug(
            '[TimestampableListener] Entering TimestampableListener for « loadClassMetadata » event'
        );

        // setting default mapping configuration for Timestampable

        // createdAt
        $metadata->mapField([
            'fieldName' => 'createdAt',
            'type'      => 'datetime',
        ]);

        // updatedAt
        $metadata->mapField([
            'fieldName' => 'updatedAt',
            'type'      => 'datetime',
        ]);

        $this->logger->debug(
            '[TimestampableListener] Added Timestampable mapping metadata to Entity',
            ['class' => $metadata->getName()]
        );
    }
767852
public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs)
    {
        $metadata = $eventArgs->getClassMetadata();
        $class = $metadata->getReflectionClass();

        if ($class === null) {
            $class = new \ReflectionClass($metadata->getName());
        }

        if ($this->className && $class->getName() == "Hexmedia\\UserBundle\\Entity\\User") {
            $reader = new AnnotationReader();
            $discriminatorMap = [];
            $discriminatorMapAnnotation = $reader->getClassAnnotation($class, 'Doctrine\ORM\Mapping\DiscriminatorMap');

            if ($discriminatorMapAnnotation) {
                $discriminatorMap = $discriminatorMapAnnotation->value;
            }

            $discriminatorMap['users'] = $this->className;
            $discriminatorMap['users_base'] = "Hexmedia\\UserBundle\\Entity\\User";

            $metadata->setDiscriminatorColumn(["name" => "type", "length" => 255]);
            $metadata->setInheritanceType(ClassMetadataInfo::INHERITANCE_TYPE_SINGLE_TABLE);
            $metadata->setDiscriminatorMap($discriminatorMap);

        }
    }
514094
public function postPersist(EventArgs $eventArgs)
    {
        if (method_exists($eventArgs, 'getEntity')) {
            $this->_triggerEvent(Events::postPersist, $eventArgs->getEntity(), $eventArgs);
        }
    }
796321
public function onFlush(OnFlushEventArgs $eventArgs)
    {
        if (!$this->eventEmittingService->isEnabled()) {
            return;
        }

        $entityManager = $eventArgs->getEntityManager();
        $unitOfWork = $entityManager->getUnitOfWork();

        foreach ($unitOfWork->getScheduledEntityInsertions() as $entity) {
            $className = get_class($entity);
            if (isset($this->monitorEntitiesSetting[$className])) {
                $entityMonitoringConfiguration = $this->monitorEntitiesSetting[$className];

                if (isset($entityMonitoringConfiguration['events']['created'])) {
                    $data = [];
                    foreach ($entityMonitoringConfiguration['data'] as $key => $eelExpression) {
                        $data[$key] = Utility::evaluateEelExpression($eelExpression, $this->eelEvaluator, ['entity' => $entity]);
                    }

                    $event = $this->eventEmittingService->emit($entityMonitoringConfiguration['events']['created'], $data);
                    $unitOfWork->computeChangeSet($entityManager->getClassMetadata(Event::class), $event);
                }
            }
        }

        foreach ($unitOfWork->getScheduledEntityDeletions() as $entity) {
            $className = get_class($entity);
            if (isset($this->monitorEntitiesSetting[$className])) {
                $entityMonitoringConfiguration = $this->monitorEntitiesSetting[$className];

                if (isset($entityMonitoringConfiguration['events']['deleted'])) {
                    $data = [];
                    foreach ($entityMonitoringConfiguration['data'] as $key => $eelExpression) {
                        $data[$key] = Utility::evaluateEelExpression($eelExpression, $this->eelEvaluator, ['entity' => $entity]);
                    }

                    $event = $this->eventEmittingService->emit($entityMonitoringConfiguration['events']['deleted'], $data);
                    $unitOfWork->computeChangeSet($entityManager->getClassMetadata(Event::class), $event);
                }
            }
        }
    }
1321363
public function loadClassMetadata(LoadClassMetadataEventArgs $args)
    {
        if (empty($this->prefix)) {
            return;
        }

        /** @var ClassMetadata $classMetadata */
        $classMetadata = $args->getClassMetadata();

        if (false === strpos($classMetadata->getTableName(), $this->prefix)) {
            $tableName = $this->prefix . $classMetadata->getTableName();
            $classMetadata->setPrimaryTable(['name' => $tableName]);
        }

        foreach ($classMetadata->getAssociationMappings() as $fieldName => $mapping) {
            if ($mapping['type'] == ClassMetadataInfo::MANY_TO_MANY && $mapping['isOwningSide'] === true) {
                $mappedTableName = $classMetadata->associationMappings[$fieldName]['joinTable']['name'];

                if (false !== strpos($mappedTableName, $this->prefix)) {
                    continue;
                }

                $classMetadata->associationMappings[$fieldName]['joinTable']['name'] = $this->prefix . $mappedTableName;
            }
        }
    }
593000
private static function combineEventCollectionArgs(array $args)
    {
        $formattedArgs = array();

        if (isset($args[0]) && is_string($args[0])) {
            $formattedArgs['event_collection'] = $args[0];

            if (isset($args[1]) && is_array($args[1])) {
                $formattedArgs = array_merge($formattedArgs, $args[1]);
            }
        } elseif (isset($args[0]) && is_array($args[0])) {
            $formattedArgs = $args[0];
        }

        return $formattedArgs;
    }
1281594
public function preRemove($eventArgs)
    {
        $entity = $eventArgs->getEntity();
        foreach ($this->metadata->getManagedFields($entity) as $field) {
            $file = PropertyHelper::getValue($entity, $field);

            if ($file) {
                $filepath = $this->fileManager->getFilePath($entity, $field, $file);

                $this->unitOfWork[spl_object_hash($entity)][$field]['delete'] = function (FileManager $fm) use ($filepath) {
                    $fm->delete($filepath);
                };
            }
        }
    }
158545
public static function create( $eventName, $eventArgs = null ) {
			
			if ( !is_string( $eventName ) ) {
				throw new \browserfs\Exception('Invalid argument $eventName: string expected!');
			}
			
			if ( null !== $eventArgs && !is_array( $eventArgs ) ) {
				throw new \browserfs\Exception('Invalid argument $eventArgs: any[] | null expected');
			}

			return new static( $eventName, null === $eventArgs ? [] : array_values( $eventArgs ) );
		}
216717
public function postGenerateSchemaTable(GenerateSchemaTableEventArgs $eventArgs)
    {
        $cm = $eventArgs->getClassMetadata();

        if (!$this->annotationReader->isRevised($cm->name)) {
            $revised = false;
            if ($cm->isInheritanceTypeJoined() && $cm->rootEntityName == $cm->name) {
                foreach ($cm->subClasses as $subClass) {
                    if ($this->annotationReader->isRevised($subClass)) {
                        $revised = true;
                    }
                }
            }

            if (!$revised) {
                return;
            }
        }

        if (!in_array($cm->inheritanceType, array(ClassMetadataInfo::INHERITANCE_TYPE_NONE, ClassMetadataInfo::INHERITANCE_TYPE_SINGLE_TABLE))) {
            throw new \Exception(sprintf('Inheritance type "%s" is not yet supported', $cm->inheritanceType));
        }

        $schema = $eventArgs->getSchema();
        $entityTable = $eventArgs->getClassTable();
        $revisionTable = $schema->createTable(
            $entityTable->getName() . '_revisions'
        );
        $revisionTable->addColumn('revision_id', 'integer');
        $revisionTable->addColumn('rev_type', 'string', array('length' => 4));

        foreach ($entityTable->getColumns() as $column) {
            if (!in_array($column->getName(), $cm->identifier) && !$this->isColumnRevised($cm, $column->getName())) {
                continue;
            }

            /* @var Column $column */
            $revisionTable->addColumn($column->getName(), $column->getType()->getName(), array_merge(
                $column->toArray(),
                array('notnull' => false, 'autoincrement' => false)
            ));
        }

        $pkColumns = $entityTable->getPrimaryKey()->getColumns();
        $pkColumns[] = 'revision_id';
        $revisionTable->setPrimaryKey($pkColumns);
    }
1033386
public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs)
    {
        $classMetadata = $eventArgs->getClassMetadata();

        if (null === $classMetadata->reflClass) {
            return;
        }

        if ($this->isTranslatable($classMetadata)) {
            $this->mapTranslatable($classMetadata);
        }

        if ($this->isTranslation($classMetadata)) {
            $this->mapTranslation($classMetadata);
            $this->mapId(
                $classMetadata,
                $eventArgs->getEntityManager()
            );
        }
    }
1284218
public function onClear($eventArgs)
    {
        parent::onClear($eventArgs);

        $aliases             = array_keys($this->identifierMap);
        $this->identifierMap = array();

        foreach ($aliases as $alias) {
            $this->identifierMap[$alias] = array();
        }
    }
95597
public function preFlush(EventArgs $eventArgs)
    {
        $em = $eventArgs->getEntityManager();
        $uow = $em->getUnitOfWork();

        foreach ($uow->getScheduledEntityInsertions() as $entity) {
            $this->_triggerEvent(Events::preFlush, $entity, $eventArgs);
        }

        foreach ($uow->getScheduledEntityUpdates() as $entity) {
            $this->_triggerEvent(Events::preFlush, $entity, $eventArgs);
        }

        foreach ($uow->getScheduledEntityDeletions() as $entity) {
            $this->_triggerEvent(Events::preFlush, $entity, $eventArgs);
        }
    }
1188834
public function onFlush(OnFlushEventArgs $eventArgs)
    {
        $this->pages = new ArrayCollection();

        $this->manager = $eventArgs->getEntityManager();
        $uow = $this->manager->getUnitOfWork();

        foreach ($uow->getScheduledEntityUpdates() as $entity) {
            $this->handleEntity($entity);
        }
        /** @var \Doctrine\Common\Collections\ArrayCollection $col */
        foreach ($uow->getScheduledCollectionUpdates() as $col) {
            foreach ($col as $entity) {
                $this->handleEntity($entity);
            }
        }

        if (0 < $this->pages->count()) {
            $this->persister->replaceMany($this->pages->toArray());
        }
    }