Sets the discriminator map according to the config

@param LoadClassMetadataEventArgs $eventArgs
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);

        }
    }
23348
public function postLoad(LifecycleEventArgs $eventArgs)
    {
        $entityManager = $eventArgs->getEntityManager();
        $object = $eventArgs->getEntity();
        $uploadableMeta = $this->getObjectExtendedMetadata($entityManager, $object);

        if ($uploadableMeta->hasUploadableProperties()) {
            $this->loadFiles($entityManager, $object, $uploadableMeta);
        }
    }
915903
public function setEventManager(EventManagerInterface $events)
    {
        $identifiers = array(__CLASS__, get_called_class());
        if (isset($this->eventIdentifier)) {
            if ((is_string($this->eventIdentifier))
                || (is_array($this->eventIdentifier))
                || ($this->eventIdentifier instanceof Traversable)
            ) {
                $identifiers = array_unique(array_merge($identifiers, (array) $this->eventIdentifier));
            } elseif (is_object($this->eventIdentifier)) {
                $identifiers[] = $this->eventIdentifier;
            }
            // silently ignore invalid eventIdentifier types
        }
        $events->setIdentifiers($identifiers);
        $this->events = $events;
        return $this;
    }
1048525
public function setEventTrigger(EventTriggerInterface $eventTrigger)
    {
        $this->init();
        $eventService = new EventTriggerService();
        $eventService->registerEventDispatcher($eventTrigger);

        $this->container->instance(EventTriggerService::class, $eventService);
    }
1018746
public function postFlush(PostFlushEventArgs $eventArgs)
    {
        $em = $eventArgs->getEntityManager();
        $quoteStrategy = $em->getConfiguration()->getQuoteStrategy();
        $uow = $em->getUnitOfWork();

        foreach ($this->extraUpdates as $entity) {
            $className = \get_class($entity);
            $meta = $em->getClassMetadata($className);

            $persister = $uow->getEntityPersister($className);
            $updateData = $this->prepareUpdateData($persister, $entity);

            if (!isset($updateData[$meta->table['name']]) || !$updateData[$meta->table['name']]) {
                continue;
            }

            /** @var array $updateDataColumns */
            $updateDataColumns = $updateData[$meta->table['name']];

            foreach ($updateDataColumns as $column => $value) {
                $field = $meta->getFieldName($column);
                $fieldName = $meta->getFieldForColumn($column);
                $placeholder = '?';
                if ($meta->hasField($fieldName)) {
                    $field = $quoteStrategy->getColumnName($field, $meta, $this->platform);
                    $fieldType = $meta->getTypeOfField($field);
                    if (null !== $fieldType) {
                        $type = Type::getType($fieldType);
                        if ($type->canRequireSQLConversion()) {
                            $placeholder = $type->convertToDatabaseValueSQL('?', $this->platform);
                        }
                    }
                }

                $sql = 'UPDATE ' . $this->config->getTableName($meta) . ' ' .
                    'SET ' . $field . ' = ' . $placeholder . ' ' .
                    'WHERE ' . $this->config->getRevisionFieldName() . ' = ? ';

                $isIgnore = false;

                foreach ($this->config->getGlobalIgnoreColumns() as $columnName) {
                    if ($field === $columnName) {
                        $isIgnore = true;
                    }
                }

                if (isset($this->auditedEntitiesIgnoreColumns[$className])) {
                    /** @var array $auditedEntitiesIgnoreColumns */
                    $auditedEntitiesIgnoreColumns = $this->auditedEntitiesIgnoreColumns[$className];

                    foreach ($auditedEntitiesIgnoreColumns as $columnName) {
                        if ($field === $columnName) {
                            $isIgnore = true;
                        }
                    }
                }

                if ($isIgnore) {
                    continue;
                }

                $params = [$value, $this->getRevisionId()];

                $types = [];

                if (\in_array($column, $meta->getColumnNames(), true)) {
                    $types[] = $meta->getTypeOfField($fieldName);
                } else {
                    //try to find column in association mappings
                    $type = null;

                    foreach ($meta->associationMappings as $mapping) {
                        if (isset($mapping['joinColumns'])) {
                            /** @var array $joinColumns */
                            $joinColumns = $mapping['joinColumns'];

                            /** @var array $definition */
                            foreach ($joinColumns as $definition) {
                                if ($definition['name'] === $column) {
                                    $targetTable = $em->getClassMetadata($mapping['targetEntity']);
                                    $type = $targetTable->getTypeOfField($targetTable->getFieldName($definition['referencedColumnName']));
                                }
                            }
                        }
                    }

                    if (null === $type) {
                        throw new \RuntimeException(
                            sprintf('Could not resolve database type for column "%s" during extra updates', $column)
                        );
                    }

                    $types[] = $type;
                }

                $types[] = $this->config->getRevisionIdFieldType();

                foreach ($meta->identifier as $idField) {
                    if (isset($meta->fieldMappings[$idField])) {
                        $columnName = $meta->fieldMappings[$idField]['columnName'];
                        $types[] = $meta->fieldMappings[$idField]['type'];

                        $params[] = $meta->reflFields[$idField]->getValue($entity);

                        $sql .= 'AND ' . $columnName . ' = ?';
                    } elseif (isset($meta->associationMappings[$idField])) {
                        $columnName = $meta->associationMappings[$idField]['joinColumns'][0];
                        if (\is_array($columnName)) {
                            if (isset($columnName['name'])) {
                                $columnName = $columnName['name'];
                            } else {
                                // Not much we can do to recover this - we need a column name...
                                throw new MappingException('Column name not set within meta');
                            }
                        }
                        $types[] = $meta->associationMappings[$idField]['type'];

                        $params[] = $meta->reflFields[$idField]->getValue($entity);

                        $sql .= 'AND ' . $columnName . ' = ?';
                    }
                }

                $this->em->getConnection()->executeQuery($sql, $params, $types);
            }
        }
    }
719399
public function prePersist(EventArgs $eventArgs)
    {
        if (method_exists($eventArgs, 'getEntity')) {
            $this->_triggerEvent(Events::prePersist, $eventArgs->getEntity(), $eventArgs);
        }
    }
152868
public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs)
    {
        $classMetadata = $eventArgs->getClassMetadata();
        if (MetadataLayer::isAlreadyProcessed($classMetadata)) {
            // we can skip it
            return;
        }

        $fieldNames = array_flip($classMetadata->getFieldNames());
        $reflectionClass = $classMetadata->getReflectionClass();

        foreach ($reflectionClass->getProperties() as $reflectionProperty) {
            if (isset($fieldNames[$reflectionProperty->getName()])) {
                $this->loadHubProperty($reflectionProperty, $classMetadata);
            } else {
                $this->loadMaskProperty($reflectionProperty, $classMetadata);
            }
        }
    }
838855
public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs)
    {
        /** @var ClassMetadata $metadata */
        $metadata = $eventArgs->getClassMetadata();

        /** @var \ReflectionClass $reflectionClass */
        $reflectionClass = $metadata->getReflectionClass();

        if ($reflectionClass->getName() !== Payment::class) {
            return;
        }

        $this->logger->debug(
            '[PaymentListener] Entering PaymentListener for « loadClassMetadata » event',
            [$metadata->getReflectionClass()->getName()]
        );

        unset($metadata->fieldMappings['details']);
        unset($metadata->fieldNames['details']);
        unset($metadata->columnNames['details']);

        $metadata->mapField([
            'fieldName' => 'details',
            'type'      => 'array',
        ]);
    }
753603
public function postRemove(EventArgs $eventArgs)
    {
        if (method_exists($eventArgs, 'getEntity')) {
            $this->_triggerEvent(Events::postRemove, $eventArgs->getEntity(), $eventArgs);
        }
    }
225883
public function loadClassMetadata(LoadClassMetadataEventArgs $args)
    {
        /* @var $cm \Doctrine\ORM\Mapping\ClassMetadata */
        $cm = $args->getClassMetadata();

        foreach ($cm->associationMappings as $mapping) {
            if (isset($this->resolveTargetEntities[$mapping['targetEntity']])) {
                $this->remapAssociation($cm, $mapping);
            }
        }

        foreach ($this->resolveTargetEntities as $interface => $data) {
            if ($data['targetEntity'] == $cm->getName()) {
                $args->getEntityManager()->getMetadataFactory()->setMetadataFor($interface, $cm);
            }
        }
    }
22318
public function preRemove(EventArgs $eventArgs)
    {
        if (method_exists($eventArgs, 'getEntity')) {
            $this->_triggerEvent(Events::preRemove, $eventArgs->getEntity(), $eventArgs);
        }
    }
346213
public function loadClassMetadata(LoadClassMetadataEventArgs $event)
    {
        /** @var ClassMetadata $metadata */
        $metadata = $event->getClassMetadata();

        if (! isset($this->entityListeners[$metadata->getClassName()])) {
            return;
        }

        foreach ($this->entityListeners[$metadata->getClassName()] as $listener) {
            $listenerClassName = $listener['class'];

            $metadata->addEntityListener($listener['event'], $listenerClassName, $listener['method']);
        }

        unset($this->entityListeners[$metadata->getClassName()]);
    }
360352
public function preUpdate(EventArgs $eventArgs)
    {
        if (method_exists($eventArgs, 'getEntity')) {
            $this->_triggerEvent(Events::preUpdate, $eventArgs->getEntity(), $eventArgs);
        }
    }
885808
public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs)
    {
        $classMetadata = $eventArgs->getClassMetadata();
        $classMetadata->setTableName($this->prefix . $classMetadata->getTableName());

        //if we use sequences, also prefix the sequence name
        if($classMetadata->isIdGeneratorSequence()) {
        
            $sequenceDefinition = $classMetadata->sequenceGeneratorDefinition;
            $sequenceDefinition['sequenceName'] = $this->prefix . $sequenceDefinition['sequenceName'];

            $classMetadata->setSequenceGeneratorDefinition($sequenceDefinition);
        }

        foreach ($classMetadata->getAssociationMappings() as $fieldName => $mapping) {
            if ($mapping['type'] == \Doctrine\ORM\Mapping\ClassMetadataInfo::MANY_TO_MANY) {
                $mappedTableName = $classMetadata->associationMappings[$fieldName]['joinTable']['name'];
                $classMetadata->associationMappings[$fieldName]['joinTable']['name'] = $this->prefix . $mappedTableName;
            }
        }
    }
1252020
public function loadClassMetadata(LoadClassMetadataEventArgs $event)
    {
        $metadata = $event->getClassMetadata();
        $reflection = $metadata->getReflectionClass();

        if (null !== $reflection && $reflection->implementsInterface('Sulu\Component\Persistence\Model\UserBlameInterface')) {
            if (!$metadata->hasAssociation(self::CREATOR_FIELD)) {
                $metadata->mapManyToOne([
                    'fieldName' => self::CREATOR_FIELD,
                    'targetEntity' => $this->userClass,
                    'joinColumns' => [
                        [
                            'name' => 'idUsersCreator',
                            'onDelete' => 'SET NULL',
                            'referencedColumnName' => 'id',
                            'nullable' => true,
                        ],
                    ],
                ]);
            }

            if (!$metadata->hasAssociation(self::CHANGER_FIELD)) {
                $metadata->mapManyToOne([
                    'fieldName' => self::CHANGER_FIELD,
                    'targetEntity' => $this->userClass,
                    'joinColumns' => [
                        [
                            'name' => 'idUsersChanger',
                            'onDelete' => 'SET NULL',
                            'referencedColumnName' => 'id',
                            'nullable' => true,
                        ],
                    ],
                ]);
            }
        }
    }
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;
            }
        }
    }
458707
public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs)
    {
        $metadata = $eventArgs->getClassMetadata();

        //set a relation between Page and User to define the page author
        $metaBuilder = new ClassMetadataBuilder($metadata);

        //Add author relation on view
        if ($this->userClass && $metadata->name === 'Victoire\Bundle\CoreBundle\Entity\View') {
            $metadata->mapManyToOne([
                'fieldName'    => 'author',
                'targetEntity' => $this->userClass,
                'cascade'      => ['persist'],
                'inversedBy'   => 'pages',
                'joinColumns'  => [
                    [
                        'name'                 => 'author_id',
                        'referencedColumnName' => 'id',
                        'onDelete'             => 'SET NULL',
                    ],
                ],
            ]);
        }

        // if $pages property exists, add the inversed side on User
        if ($metadata->name === $this->userClass && property_exists($this->userClass, 'pages')) {
            $metaBuilder->addOneToMany('pages', 'Victoire\Bundle\CoreBundle\Entity\View', 'author');
        }
    }