public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs) { $classMetadata = $eventArgs->getClassMetadata(); // add subclasses to node $subclasses = array_flip($this->contentTypes); if ($classMetadata->name == $subclasses['node']) { unset($subclasses['node']); $classMetadata->subClasses = $subclasses; switch ($this->inheritanceType) { case 'single_table': $classMetadata->setInheritanceType(ClassMetadataInfo::INHERITANCE_TYPE_SINGLE_TABLE); break; case 'table_per_class': $classMetadata->setInheritanceType(ClassMetadataInfo::INHERITANCE_TYPE_TABLE_PER_CLASS); break; default: $classMetadata->setInheritanceType(ClassMetadataInfo::INHERITANCE_TYPE_JOINED); break; } $classMetadata->setDiscriminatorColumn(array('name' => $this->discriminatorColumn, 'type' => 'string', 'length' => 50)); } // check if class is defined in config if (isset($this->contentTypes[$classMetadata->name])) { // set discriminator $classMetadata->discriminatorMap = array_flip($this->contentTypes); $classMetadata->discriminatorValue = $this->contentTypes[$classMetadata->name]; } }
public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs) { $classMetadata = $eventArgs->getClassMetadata(); $reflectionClass = $classMetadata->getReflectionClass(); if (null === $reflectionClass) { return; } if (ClassUtil::classUsesTrait($reflectionClass->getName(), __NAMESPACE__ . '\\Translatable')) { if (!$classMetadata->hasAssociation('translations')) { $classMetadata->mapOneToMany(['fieldName' => 'translations', 'mappedBy' => 'translatable', 'indexBy' => 'locale', 'cascade' => ['persist', 'merge', 'remove'], 'orphanRemoval' => true, 'targetEntity' => $classMetadata->getName() . 'Translation']); } } if (ClassUtil::classUsesTrait($reflectionClass->getName(), __NAMESPACE__ . '\\Translation')) { if (!$classMetadata->hasAssociation('translatable')) { $classMetadata->mapManyToOne(['fieldName' => 'translatable', 'inversedBy' => 'translations', 'joinColumns' => [['name' => 'translatable_id', 'referencedColumnName' => 'id', 'onDelete' => 'CASCADE']], 'targetEntity' => substr($classMetadata->getName(), 0, -11)]); } if (!$classMetadata->hasField('locale')) { $classMetadata->mapField(['fieldName' => 'locale', 'type' => 'string']); } $translationConstraint = $classMetadata->getTableName() . '_unique_translation'; if (!ClassMetadataUtil::hasUniqueConstraint($classMetadata, $translationConstraint)) { $classMetadata->setPrimaryTable(['uniqueConstraints' => [['name' => $translationConstraint, 'columns' => ['translatable_id', 'locale']]]]); } } }
public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs) { /** @var ClassMetadata $metadata */ $metadata = $eventArgs->getClassMetadata(); // Transform Librinfo entities only if (strpos($metadata->getName(), "Librinfo\\") !== 0) { return; } $this->logger->debug("[NamingListener] Entering NamingListener for « loadClassMetadata » event"); $namingStrategy = $eventArgs->getEntityManager()->getConfiguration()->getNamingStrategy(); // create a FQDN for the representing table if ($namingStrategy->classToTableName($metadata->getName()) == $metadata->table['name']) { $metadata->table['name'] = $this->buildTableName($metadata->name); } // create a FQDN for the ManyToMany induced tables foreach ($metadata->associationMappings as $field => $mapping) { if ($mapping['type'] == ClassMetadataInfo::MANY_TO_MANY && $mapping['isOwningSide']) { if ($namingStrategy->classToTableName($mapping['joinTable']['name']) == $mapping['joinTable']['name']) { $rc = new \ReflectionClass($mapping['targetEntity']); $fqdn = $mapping['sourceEntity'] . '__' . $rc->getShortName(); $metadata->associationMappings[$field]['joinTable']['name'] = $this->buildTableName($fqdn); } } } $this->logger->debug("[NamingListener] Added table naming strategy to Entity", ['class' => $metadata->getName()]); }
/** * @param LoadClassMetadataEventArgs $args */ public function loadClassMetadata(LoadClassMetadataEventArgs $args) { $this->em = $args->getEntityManager(); $this->meta = $args->getClassMetadata(); if (!$this->em->getConnection()->getWrappedConnection() instanceof AbstractConnection) { return; } if ($this->meta->customPersisterClassName === null) { $this->meta->setCustomPersisterClass(EntityPersister::class); } $this->markIndex(); foreach ($this->meta->fieldMappings as $property => &$mapping) { $this->remapIdentifier($property, $mapping); $this->remapVersion($property, $mapping); $this->markField($property, $mapping); } foreach ($this->meta->associationMappings as $property => &$mapping) { $this->remapAnyToOneAssociation($property, $mapping); $this->remapAnyToManyAssociation($property, $mapping); $this->remapManyToManyAssociation($property, $mapping); } if ($cache = $this->em->getMetadataFactory()->getCacheDriver()) { $cache->save($this->meta->name . '$CLASSMETADATA', $this->meta, null); } }
/** * define Addressable mapping at runtime * * @param LoadClassMetadataEventArgs $eventArgs */ public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs) { /** @var ClassMetadata $metadata */ $metadata = $eventArgs->getClassMetadata(); $reflectionClass = $metadata->getReflectionClass(); if (!$reflectionClass || !$this->hasTrait($reflectionClass, 'Librinfo\\DoctrineBundle\\Entity\\Traits\\Addressable')) { return; } // return if current entity doesn't use Addressable trait // Check if parents already have the Addressable trait foreach ($metadata->parentClasses as $parent) { if ($this->classAnalyzer->hasTrait($parent, 'Librinfo\\DoctrineBundle\\Entity\\Traits\\Addressable')) { return; } } $this->logger->debug("[AddressableListener] Entering AddressableListener for « loadClassMetadata » event"); // setting default mapping configuration for Traceable // address $metadata->mapField(['fieldName' => 'address', 'type' => 'string', 'nullable' => true]); // zip $metadata->mapField(['fieldName' => 'zip', 'type' => 'string', 'length' => 20, 'nullable' => true]); // city $metadata->mapField(['fieldName' => 'city', 'type' => 'string', 'nullable' => true]); // country $metadata->mapField(['fieldName' => 'country', 'type' => 'string', 'nullable' => true]); // npai $metadata->mapField(['fieldName' => 'npai', 'type' => 'boolean', 'nullable' => true]); // vcardUid $metadata->mapField(['fieldName' => 'vcardUid', 'type' => 'string', 'nullable' => true]); // confirmed $metadata->mapField(['fieldName' => 'confirmed', 'type' => 'boolean', 'default' => true]); $this->logger->debug("[AddressableListener] Added Addressable mapping metadata to Entity", ['class' => $metadata->getName()]); }
/** * Sets the discriminator maps on AbstractCharacteristics entity mappings. * * @param LoadClassMetadataEventArgs $eventArgs */ public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs) { $metadata = $eventArgs->getClassMetadata(); if ($metadata->getName() === self::ROOT_CHARACTERISTICS_CLASS) { $metadata->setDiscriminatorMap($this->characteristicsClassesMap); } }
public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs) { $metadata = $eventArgs->getClassMetadata(); if ($metadata->getName() === $this->profile) { $this->setupProfileDiscriminator($metadata); } }
public function loadClassMetadata(LoadClassMetadataEventArgs $args) { $classMetadata = $args->getClassMetadata(); // Get class annotations $classAnnotations = $this->annotatonReader->getClassAnnotations($classMetadata->getReflectionClass()); // Search for WordpressTable annotation $found = false; foreach ($classAnnotations as $classAnnotation) { if ($classAnnotation instanceof WordpressTable) { $found = true; break; } } // Only apply to classes having WPTable annotation if (!$found) { return; } // set table prefix $prefix = $this->getPrefix($classMetadata->name, $args->getEntityManager()); $classMetadata->setPrimaryTable(array('name' => $prefix . $classMetadata->getTableName())); // set table prefix to associated entity // TODO: make sure prefix won't apply to user table foreach ($classMetadata->associationMappings as &$mapping) { if (isset($mapping['joinTable']) && !empty($mapping['joinTable'])) { $mapping['joinTable']['name'] = $prefix . $mapping['joinTable']['name']; } } }
/** * define Emailable mapping at runtime * * @param LoadClassMetadataEventArgs $eventArgs */ public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs) { /** @var ClassMetadata $metadata */ $metadata = $eventArgs->getClassMetadata(); $reflectionClass = $metadata->getReflectionClass(); if (!$reflectionClass || !$this->hasTrait($reflectionClass, 'Librinfo\\DoctrineBundle\\Entity\\Traits\\Emailable')) { return; } // return if current entity doesn't use Emailable trait // Check if parents already have the Emailable trait foreach ($metadata->parentClasses as $parent) { if ($this->classAnalyzer->hasTrait($parent, 'Librinfo\\DoctrineBundle\\Entity\\Traits\\Emailable')) { return; } } $this->logger->debug("[EmailableListener] Entering EmailableListener for « loadClassMetadata » event"); // setting default mapping configuration for Traceable // email $metadata->mapField(['fieldName' => 'email', 'type' => 'string', 'nullable' => true]); // emailNpai $metadata->mapField(['fieldName' => 'emailNpai', 'type' => 'boolean', 'nullable' => true]); // emailNoNewsletter $metadata->mapField(['fieldName' => 'emailNoNewsletter', 'type' => 'boolean', 'nullable' => true]); $this->logger->debug("[EmailableListener] Added Emailable mapping metadata to Entity", ['class' => $metadata->getName()]); }
/** * @param LoadClassMetadataEventArgs $args */ public function loadClassMetadata(LoadClassMetadataEventArgs $args) { $meta = $args->getClassMetadata(); if ($this->_l) { if (Strings::endsWith($meta->associationMappings[$this->_lName]['targetEntity'], '::dynamic')) { $meta->associationMappings[$this->_lName]['targetEntity'] = $this->getTargetEntity($meta->name, $this->_l); } return; } foreach ($meta->getAssociationNames() as $name) { if (!Strings::endsWith($meta->associationMappings[$name]['targetEntity'], '::dynamic')) { continue; } $em = $args->getEntityManager(); $target = $this->getTargetEntity($meta, $name); $this->_l = $meta->name; $this->_lName = $meta->associationMappings[$name]['inversedBy']; if (!$this->_lName) { $this->_lName = $meta->associationMappings[$name]['mappedBy']; } if ($this->_lName) { $targetMeta = $em->getClassMetadata($target); } $this->_l = FALSE; $meta->associationMappings[$name]['targetEntity'] = $target; if ($this->_lName) { $targetMeta->associationMappings[$this->_lName]['targetEntity'] = $meta->name; } } }
public function loadClassMetadata(LoadClassMetadataEventArgs $args) { $metadata = $args->getClassMetadata(); $user = '******'; $basicProfile = 'FOM\\UserBundle\\Entity\\BasicProfile'; $profile = $this->container->getParameter('fom_user.profile_entity'); if ($user == $metadata->getName()) { $metadata->mapOneToOne(array('fieldName' => 'profile', 'targetEntity' => $profile, 'mappedBy' => 'uid', 'cascade' => array('persist'))); } $connection = $args->getEntityManager()->getConnection(); $platform = $connection->getDatabasePlatform(); $uidColname = $connection->quoteIdentifier('uid'); if ($platform instanceof OraclePlatform) { $uidColname = strtoupper($uidColname); } elseif ($platform instanceof MySqlPlatform) { $uidColname = 'uid'; } // need to add metadata for the basic profile, else doctrine // will whine in many situations if ($profile == $metadata->getName() || $basicProfile == $metadata->getName()) { $metadata->setIdentifier(array('uid')); $metadata->setIdGenerator(new AssignedGenerator()); $metadata->mapOneToOne(array('fieldName' => 'uid', 'targetEntity' => $user, 'inversedBy' => 'profile', 'id' => true, 'joinColumns' => array(array('name' => $uidColname, 'referencedColumnName' => 'id')))); } }
public function loadClassMetadata(LoadClassMetadataEventArgs $args) { $classMetadata = $args->getClassMetadata(); if ($classMetadata->isInheritanceTypeSingleTable() && !$classMetadata->isRootEntity()) { // if we are in an inheritance hierarchy, only apply this once return; } $classMetadata->setTableName($this->prefix . $classMetadata->getTableName()); 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; } } if ($classMetadata->isIdGeneratorSequence()) { $newDefinition = $classMetadata->sequenceGeneratorDefinition; $newDefinition['sequenceName'] = $this->prefix . $newDefinition['sequenceName']; $classMetadata->setSequenceGeneratorDefinition($newDefinition); $em = $args->getEntityManager(); if (isset($classMetadata->idGenerator)) { $sequenceGenerator = new \Doctrine\ORM\Id\SequenceGenerator($em->getConfiguration()->getQuoteStrategy()->getSequenceName($newDefinition, $classMetadata, $em->getConnection()->getDatabasePlatform()), $newDefinition['allocationSize']); $classMetadata->setIdGenerator($sequenceGenerator); } } }
/** * loadClassMetadata event * * Retrieves the discriminatorMap from the BlockManagar, so we can * add entities to the discriminatorMap without adjusting the annotations * in the Block entity. * * @param LoadClassMetadataEventArgs $args * * @return void */ public function loadClassMetadata(LoadClassMetadataEventArgs $args) { $metadata = $args->getClassMetadata(); if ($metadata->name == 'Opifer\\CmsBundle\\Entity\\Block') { $metadata->setDiscriminatorMap($this->getDiscriminatorMap()); } }
/** * @param LoadClassMetadataEventArgs $eventArgs */ public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs) { $metadata = $eventArgs->getClassMetadata(); $this->mapManyToMany($metadata); $this->mapOneToMany($metadata); $this->mapManyToOne($metadata); }
public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs) { /** @var ClassMetadata $metadata */ $metadata = $eventArgs->getClassMetadata(); // Do not generate id mapping twice for entities that extend a MappedSuperclass if ($metadata->isMappedSuperclass) { return; } // Do not generate id mapping twice for entities that use the SINGLE_TABLE inheritance mapping strategy. if ($metadata->isInheritanceTypeSingleTable() && !$metadata->subClasses) { return; } // Check if parents already have the Guidable trait foreach ($metadata->parentClasses as $parent) { if ($this->classAnalyzer->hasTrait($parent, 'Librinfo\\DoctrineBundle\\Entity\\Traits\\Guidable')) { return; } } $this->logger->debug("[GuidableListener] Entering GuidableListener for « loadClassMetadata » event"); $reflectionClass = $metadata->getReflectionClass(); // return if the current entity doesn't use Guidable trait if (!$reflectionClass || !$this->hasTrait($reflectionClass, 'Librinfo\\DoctrineBundle\\Entity\\Traits\\Guidable')) { return; } $metadata->mapField(['id' => true, 'fieldName' => "id", 'type' => "guid", 'columnName' => "id"]); $metadata->setIdGenerator(new UuidGenerator()); $this->logger->debug("[GuidableListener] Added Guidable mapping metadata to Entity", ['class' => $metadata->getName()]); }
/** * Load class meta data event * * @param LoadClassMetadataEventArgs $args * * @return void */ public function loadClassMetadata(LoadClassMetadataEventArgs $args) { /** @var ClassMetadata $classMetadata */ $classMetadata = $args->getClassMetadata(); if (empty($this->prefix)) { // Prefix is empty, we don't need to do anything; return; } if ($classMetadata->namespace == self::ENTITY_NAMESPACE && $classMetadata->name == self::ENTITY_NAME) { // Do not re-apply the prefix when the table is already prefixed 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']; // Do not re-apply the prefix when the association is already prefixed if (false !== strpos($mappedTableName, $this->prefix)) { continue; } $classMetadata->associationMappings[$fieldName]['joinTable']['name'] = $this->prefix . $mappedTableName; } } } }
/** * load class metadata. * * @todo [cms][db] add plugin hook if there is multi-site::multi-db module plugs enabled then it is no need site_id_prefix. * @param \Doctrine\ORM\Event\LoadClassMetadataEventArgs $eventArgs */ public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs) { $classMetadata = $eventArgs->getClassMetadata(); if (!$classMetadata->isInheritanceTypeSingleTable() || $classMetadata->getName() === $classMetadata->rootEntityName) { $table_name = $classMetadata->getTableName(); $table_name_with_prefixed = $this->prefix . $table_name; // if it is multi-site table, set table prefix with site_id prefix if (in_array($table_name, $this->multisite_tables)) { if ($this->site_id_prefix != null) { $table_name_with_prefixed = $this->prefix . $this->site_id_prefix . $table_name; } } $classMetadata->setTableName($table_name_with_prefixed); unset($table_name, $table_name_with_prefixed); } foreach ($classMetadata->getAssociationMappings() as $fieldName => $mapping) { if ($mapping['type'] == \Doctrine\ORM\Mapping\ClassMetadataInfo::MANY_TO_MANY && $mapping['isOwningSide']) { $mappedTableName = $mapping['joinTable']['name']; $table_name_with_prefixed = $this->prefix . $mappedTableName; // if it is multi-site table, set table prefix with site_id prefix if (in_array($mappedTableName, $this->multisite_tables)) { if ($this->site_id_prefix != null) { $table_name_with_prefixed = $this->prefix . $this->site_id_prefix . $mappedTableName; } } $classMetadata->associationMappings[$fieldName]['joinTable']['name'] = $table_name_with_prefixed; unset($mappedTableName, $table_name_with_prefixed); } } unset($fieldName, $mapping); }
public function loadClassMetadata(LoadClassMetadataEventArgs $args) { $em = $args->getEntityManager(); $meta = $args->getClassMetadata(); $class = $meta->name; $rootClass = $meta->rootEntityName; $info = Chalk::info($class); $parentClasses = array_merge([$class], $meta->parentClasses); $repositoryClasses = []; foreach ($parentClasses as $parentClass) { $parentInfo = Chalk::info($parentClass); $repositoryClasses[] = $parentInfo->module->class . '\\Repository\\' . $parentInfo->local->class; } $repositoryClasses[] = 'Chalk\\Repository'; foreach ($repositoryClasses as $repositoryClass) { if (class_exists($repositoryClass)) { $meta->setCustomRepositoryClass($repositoryClass); break; } } if ($meta->discriminatorMap) { $meta->discriminatorMap = [Chalk::info($rootClass)->name => $rootClass]; $allClasses = $em->getConfiguration()->getMetadataDriverImpl()->getAllClassNames(); foreach ($allClasses as $allClass) { if (is_subclass_of($allClass, $rootClass)) { $meta->discriminatorMap[Chalk::info($allClass)->name] = $allClass; } if (is_subclass_of($allClass, $class) && !in_array($allClass, $meta->subClasses)) { $meta->subClasses[] = $allClass; } } } }
/** * @param LoadClassMetadataEventArgs $args */ public function loadClassMetadata(LoadClassMetadataEventArgs $args) { $evm = $args->getEntityManager()->getEventManager(); $this->resolveTargetEntities->addResolveTargetEntity("Bigfish\\Bundle\\CoreBundle\\Model\\TemplateInterface", "Bigfish\\Bundle\\CoreBundle\\Entity\\Template", array()); $this->resolveTargetEntities->addResolveTargetEntity("Bigfish\\Bundle\\CoreBundle\\Model\\RouteInterface", "Bigfish\\Bundle\\CoreBundle\\Entity\\Route", array()); $evm->addEventListener(Events::loadClassMetadata, $this->resolveTargetEntities); }
/** * @param LoadClassMetadataEventArgs $event */ public function loadClassMetadata(LoadClassMetadataEventArgs $event) { // HOT FIX for PIM-3683, when using MongoDB with PIM some queries are executed before that the schema is created return; /** @var OroEntityManager $em */ $em = $event->getEntityManager(); $configProvider = $em->getExtendManager()->getConfigProvider(); $className = $event->getClassMetadata()->getName(); if ($configProvider->hasConfig($className)) { $config = $configProvider->getConfig($className); if ($config->is('is_extend')) { $cmBuilder = new ClassMetadataBuilder($event->getClassMetadata()); if ($config->is('index')) { foreach ($config->get('index') as $columnName => $enabled) { $fieldConfig = $configProvider->getConfig($className, $columnName); if ($enabled && !$fieldConfig->is('state', ExtendManager::STATE_NEW)) { $cmBuilder->addIndex(array(ExtendConfigDumper::FIELD_PREFIX . $columnName), 'oro_idx_' . $columnName); } } } $this->prepareRelations($config, $cmBuilder); } $em->getMetadataFactory()->setMetadataFor($className, $event->getClassMetadata()); } }
public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs) { /** @var ClassMetadata $metadata */ $metadata = $eventArgs->getClassMetadata(); $reflectionClass = $metadata->getReflectionClass(); if (!$reflectionClass) { return; } // Check if parents already have the Searchable trait foreach ($metadata->parentClasses as $parent) { if ($this->classAnalyzer->hasTrait($parent, 'Librinfo\\DoctrineBundle\\Entity\\Traits\\Searchable')) { return; } } // Add oneToMany mapping to entities that have the Searchable trait if ($this->hasTrait($reflectionClass, 'Librinfo\\DoctrineBundle\\Entity\\Traits\\Searchable')) { $this->logger->debug("[SearchableListener] Entering SearchableListener for « loadClassMetadata » event: entity " . $reflectionClass->getName()); $metadata->mapOneToMany(['targetEntity' => $reflectionClass->getShortName() . 'SearchIndex', 'fieldName' => 'searchIndexes', 'mappedBy' => 'object', 'cascade' => ['persist']]); } // Add manyToOne mapping to entities that exetend SearchIndexEntity (first parent only) $parentClass = $reflectionClass->getParentClass(); if ($parentClass && $parentClass->getName() == 'Librinfo\\DoctrineBundle\\Entity\\SearchIndexEntity') { $this->logger->debug("[SearchableListener] Entering SearchableListener for « loadClassMetadata » event: entity " . $reflectionClass->getName()); $metadata->mapManyToOne(['targetEntity' => str_replace('SearchIndex', '', $reflectionClass->getName()), 'fieldName' => 'object', 'inversedBy' => 'searchIndexes', 'cascade' => ['persist']]); } }
/** * Adds doctrine point type * * @param LoadClassMetadataEventArgs $eventArgs */ public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs) { $classMetadata = $eventArgs->getClassMetadata(); if (null === $classMetadata->reflClass) { return; } if ($this->isGeocodable($classMetadata)) { if (!Type::hasType('point')) { Type::addType('point', 'Knp\\DoctrineBehaviors\\DBAL\\Types\\PointType'); } $em = $eventArgs->getEntityManager(); $con = $em->getConnection(); // skip non-postgres platforms if (!$con->getDatabasePlatform() instanceof PostgreSqlPlatform && !$con->getDatabasePlatform() instanceof MySqlPlatform) { return; } // skip platforms with registerd stuff if (!$con->getDatabasePlatform()->hasDoctrineTypeMappingFor('point')) { $con->getDatabasePlatform()->registerDoctrineTypeMapping('point', 'point'); if ($con->getDatabasePlatform() instanceof PostgreSqlPlatform) { $em->getConfiguration()->addCustomNumericFunction('DISTANCE', 'Knp\\DoctrineBehaviors\\ORM\\Geocodable\\Query\\AST\\Functions\\DistanceFunction'); } } $classMetadata->mapField(['fieldName' => 'location', 'type' => 'point', 'nullable' => true]); } }
/** * loadClassMetadata event * * @param LoadClassMetadataEventArgs $args * * @return void */ public function loadClassMetadata(LoadClassMetadataEventArgs $args) { $metadata = $args->getClassMetadata(); if (strpos($metadata->name, 'Revisions') !== false) { $point = true; } }
public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs) { $classMetadata = $eventArgs->getClassMetadata(); /** * Problem: when visiting subclass with Single_Table inheritance type, * then table name was overwritten in parent class. * * Two solutions: */ if ($classMetadata->parentClasses && $classMetadata->isInheritanceTypeSingleTable()) { return; } /*if (strpos($classMetadata->getTableName(), $this->prefix) === 0) { return; }*/ $classMetadata->setTableName($this->prefix . $classMetadata->getTableName()); foreach ($classMetadata->getAssociationMappings() as $fieldName => $mapping) { if ($mapping['type'] == \Doctrine\ORM\Mapping\ClassMetadataInfo::MANY_TO_MANY && isset($classMetadata->associationMappings[$fieldName]['joinTable'])) { $mappedTableName = $classMetadata->associationMappings[$fieldName]['joinTable']['name']; // prevent double-prefix in meny-to-many inherited associations if (strpos($mappedTableName, $this->prefix) !== 0) { $classMetadata->associationMappings[$fieldName]['joinTable']['name'] = $this->prefix . $mappedTableName; } } } }
function it_skips_the_lcm_event_on_default_entity(LoadClassMetadataEventArgs $eventArgs, ClassMetadata $classMetadata) { $this->beConstructedWith(UserEntityListener::DEFAULT_ENTITY); $eventArgs->getClassMetadata()->willReturn($classMetadata); $classMetadata->getName()->shouldNotBeCalled(); $this->loadClassMetadata($eventArgs); }
/** * @param LoadClassMetadataEventArgs $args */ public function loadClassMetadata(LoadClassMetadataEventArgs $args) { $evm = $args->getEntityManager()->getEventManager(); $this->resolveTargetEntities->addResolveTargetEntity("Bigfish\\Bundle\\EavBundle\\Model\\ModuleInterface", "Bigfish\\Bundle\\EavBundle\\Entity\\Module", array()); $this->resolveTargetEntities->addResolveTargetEntity("Bigfish\\Bundle\\EavBundle\\Model\\ContainerInterface", "Bigfish\\Bundle\\EavBundle\\Entity\\Container", array()); $this->resolveTargetEntities->addResolveTargetEntity("Bigfish\\Bundle\\EavBundle\\Model\\FieldInterface", "Bigfish\\Bundle\\EavBundle\\Entity\\Field", array()); $evm->addEventListener(Events::loadClassMetadata, $this->resolveTargetEntities); }
/** * @param LoadClassMetadataEventArgs $event */ public function loadClassMetadata(LoadClassMetadataEventArgs $event) { $classMetadata = $event->getClassMetadata(); if (($resource = $this->resolveResource($classMetadata->getName())) !== null) { $classMetadata->isMappedSuperclass = false; $classMetadata->setCustomRepositoryClass($resource->getRepository()); } }
/** * Insert enabled widgets in base widget DiscriminatorMap. * * @param LoadClassMetadataEventArgs $eventArgs */ public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs) { $metadatas = $eventArgs->getClassMetadata(); //Add author relation on BrowseEvent if ($this->userClass && $metadatas->name === 'Victoire\\Bundle\\AnalyticsBundle\\Entity\\BrowseEvent') { $metadatas->mapManyToOne(['fieldName' => 'author', 'targetEntity' => $this->userClass, 'cascade' => ['persist'], 'joinColumns' => [['name' => 'author_id', 'referencedColumnName' => 'id', 'onDelete' => 'SET NULL']]]); } }
public function loadClassMetadata(LoadClassMetadataEventArgs $event) { if (!$this->metadataService instanceof Tx_Doctrine2_Mapping_MetadataService) { throw new \RuntimeException("Cannot load Typo3 Metadata without Tx_Doctrine2_Mapping_MetadataService being set on metadata listener."); } $metadata = $event->getClassMetadata(); $this->addTypo3Metadata($metadata); }
/** * @param LoadClassMetadataEventArgs $eventArgs */ public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs) { $metadata = $eventArgs->getClassMetadata(); if (!isset($this->classes[$metadata->getName()])) { return; } $metadata->setCustomRepositoryClass($this->classes[$metadata->getName()]); }