当前位置: 首页>>代码示例>>PHP>>正文


PHP ClassMetadata::getIdentifierFieldNames方法代码示例

本文整理汇总了PHP中Doctrine\ORM\Mapping\ClassMetadata::getIdentifierFieldNames方法的典型用法代码示例。如果您正苦于以下问题:PHP ClassMetadata::getIdentifierFieldNames方法的具体用法?PHP ClassMetadata::getIdentifierFieldNames怎么用?PHP ClassMetadata::getIdentifierFieldNames使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Doctrine\ORM\Mapping\ClassMetadata的用法示例。


在下文中一共展示了ClassMetadata::getIdentifierFieldNames方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: createEntityMetadata

 /**
  * @param ClassMetadata $classMetadata
  *
  * @return EntityMetadata
  */
 public function createEntityMetadata(ClassMetadata $classMetadata)
 {
     $entityMetadata = new EntityMetadata();
     $entityMetadata->setClassName($classMetadata->name);
     $entityMetadata->setIdentifierFieldNames($classMetadata->getIdentifierFieldNames());
     return $entityMetadata;
 }
开发者ID:Maksold,项目名称:platform,代码行数:12,代码来源:EntityMetadataFactory.php

示例2: writeClearedProperties

 /**
  * @param AbstractFile     $file
  * @param ClassMetadata $metadata
  * @param object        $entity
  * @param array         $properties
  */
 protected function writeClearedProperties(AbstractFile $file, ClassMetadata $metadata, $entity, array $properties)
 {
     $cleared = $this->entityToArray($entity, $properties);
     if ($cleared) {
         $file->writeObject(['identifiers' => $this->entityToArray($entity, $metadata->getIdentifierFieldNames()), 'cleared' => $cleared]);
     }
 }
开发者ID:vend,项目名称:doxport,代码行数:13,代码来源:QueryAction.php

示例3: addDoctrineFields

 /**
  * @param EntityMetadata $entityMetadata
  * @param ClassMetadata $classMetadata
  */
 protected function addDoctrineFields(EntityMetadata $entityMetadata, ClassMetadata $classMetadata)
 {
     $fields = array_diff($classMetadata->getFieldNames(), $classMetadata->getIdentifierFieldNames(), $this->getDeletedFields($classMetadata->name));
     foreach ($fields as $fieldName) {
         $fieldMetadata = $this->metadataFactory->createFieldMetadata(array('field_name' => $fieldName), $classMetadata->getFieldMapping($fieldName));
         $entityMetadata->addFieldMetadata($fieldMetadata);
     }
 }
开发者ID:startupz,项目名称:platform-1,代码行数:12,代码来源:MetadataBuilder.php

示例4: getNamePrimaryKeyField

 /**
  * @param ClassMetadata $metadata
  * @return mixed
  */
 public function getNamePrimaryKeyField(ClassMetadata $metadata)
 {
     $idNames = $metadata->getIdentifierFieldNames();
     if (count($idNames) !== 1) {
         throw new Exception('Primary key for this entity is absent or contains few fields');
     }
     return $idNames[0];
 }
开发者ID:northdakota,项目名称:platform,代码行数:12,代码来源:DictionaryHelper.php

示例5: createEntityMetadata

 /**
  * @param ClassMetadata $classMetadata
  *
  * @return EntityMetadata
  */
 public function createEntityMetadata(ClassMetadata $classMetadata)
 {
     $entityMetadata = new EntityMetadata();
     $entityMetadata->setClassName($classMetadata->name);
     $entityMetadata->setIdentifierFieldNames($classMetadata->getIdentifierFieldNames());
     $entityMetadata->setInheritedType($classMetadata->inheritanceType !== ClassMetadata::INHERITANCE_TYPE_NONE);
     return $entityMetadata;
 }
开发者ID:startupz,项目名称:platform-1,代码行数:13,代码来源:EntityMetadataFactory.php

示例6: getNamePrimaryKeyField

 /**
  * @param ClassMetadata $metadata
  * @return mixed
  */
 public function getNamePrimaryKeyField(ClassMetadata $metadata)
 {
     $idNames = $metadata->getIdentifierFieldNames();
     if (count($idNames) !== 1) {
         throw new RuntimeException(sprintf('Primary key for entity %s is absent or contains more than one field', $metadata->getName()));
     }
     return $idNames[0];
 }
开发者ID:sagikazarmark,项目名称:platform,代码行数:12,代码来源:DictionaryHelper.php

示例7: addDoctrineFields

 /**
  * @param EntityMetadata $entityMetadata
  * @param ClassMetadata $classMetadata
  */
 protected function addDoctrineFields(EntityMetadata $entityMetadata, ClassMetadata $classMetadata)
 {
     $identifierFields = $classMetadata->getIdentifierFieldNames();
     foreach ($classMetadata->getFieldNames() as $fieldName) {
         if (in_array($fieldName, $identifierFields)) {
             continue;
         }
         $fieldMetadata = $this->metadataFactory->createFieldMetadata(array('field_name' => $fieldName), $classMetadata->getFieldMapping($fieldName));
         $entityMetadata->addFieldMetadata($fieldMetadata);
     }
 }
开发者ID:ramunasd,项目名称:platform,代码行数:15,代码来源:MetadataBuilder.php

示例8: dispatchPostCreateEntityEvent

 /**
  * @param ClassMetadata $classMetaData
  * @param array $data
  * @return $this
  */
 protected function dispatchPostCreateEntityEvent(ClassMetadata $classMetaData, array $data)
 {
     $identifiers = [];
     foreach ($classMetaData->getIdentifierFieldNames() as $identifier) {
         if (array_key_exists($identifier, $data)) {
             $identifiers[$identifier] = $data[$identifier];
         }
     }
     $eventArgs = new PostCreateEntityEventArgs(get_class($this), $classMetaData->name, $identifiers);
     $this->getEntityManager()->getEventManager()->dispatchEvent(PostCreateEntityEventArgs::EVENT_NAME, $eventArgs);
     return $this;
 }
开发者ID:steevanb,项目名称:doctrine-stats,代码行数:17,代码来源:HydrationEventsTrait.php

示例9: getDefiningClass

 /**
  * Get the class metadata that is responsible for the definition of the referenced column name.
  *
  * Previously this was a simple task, but with DDC-117 this problem is actually recursive. If its
  * not a simple field, go through all identifier field names that are associations recursivly and
  * find that referenced column name.
  *
  * TODO: Is there any way to make this code more pleasing?
  *
  * @param ClassMetadata $class
  * @param string $referencedColumnName
  * @return array(ClassMetadata, referencedFieldName)
  */
 private function getDefiningClass($class, $referencedColumnName)
 {
     $referencedFieldName = $class->getFieldName($referencedColumnName);
     if ($class->hasField($referencedFieldName)) {
         return array($class, $referencedFieldName);
     } else {
         if (in_array($referencedColumnName, $class->getIdentifierColumnNames())) {
             // it seems to be an entity as foreign key
             foreach ($class->getIdentifierFieldNames() as $fieldName) {
                 if ($class->hasAssociation($fieldName) && $class->getSingleAssociationJoinColumnName($fieldName) == $referencedColumnName) {
                     return $this->getDefiningClass($this->em->getClassMetadata($class->associationMappings[$fieldName]['targetEntity']), $class->getSingleAssociationReferencedJoinColumnName($fieldName));
                 }
             }
         }
     }
     return null;
 }
开发者ID:Herriniaina,项目名称:iVarotra,代码行数:30,代码来源:SchemaTool.php

示例10: delete

 /**
  * Deletes an entity.
  *
  * @param object $entity The entity to delete.
  */
 public function delete($entity)
 {
     $id = array_combine($this->_class->getIdentifierFieldNames(), $this->_em->getUnitOfWork()->getEntityIdentifier($entity));
     $this->_conn->delete($this->_class->primaryTable['name'], $id);
 }
开发者ID:jackbravo,项目名称:doctrine,代码行数:10,代码来源:StandardEntityPersister.php

示例11: isAutogeneratedIdField

 /**
  * @param $field
  * @param $meta
  * @return bool
  */
 protected function isAutogeneratedIdField($field, ClassMetadata $meta)
 {
     $isIdentifierField = in_array($field, $meta->getIdentifierFieldNames());
     $isAutoGenerated = $meta->generatorType !== ClassMetadata::GENERATOR_TYPE_NONE;
     return $isIdentifierField && $isAutoGenerated;
 }
开发者ID:bitecodes,项目名称:factrine-bundle,代码行数:11,代码来源:EntityBuilder.php

示例12: getIdentifier

 /**
  * Get identifier.
  *
  * @param ClassMetadata $metadata
  *
  * @return mixed
  */
 private function getIdentifier(ClassMetadata $metadata)
 {
     $identifiers = $metadata->getIdentifierFieldNames();
     return array_shift($identifiers);
 }
开发者ID:bigz,项目名称:datatablesbundle,代码行数:12,代码来源:DatatableQuery.php

示例13: getIdentifierFieldNames

 /**
  * Returns names of entity identifier fields
  *
  * @return string[]
  */
 public function getIdentifierFieldNames()
 {
     return $this->metadata->getIdentifierFieldNames();
 }
开发者ID:nmallare,项目名称:platform,代码行数:9,代码来源:EntityMetadata.php

示例14: _gatherColumn

 /**
  * Creates a column definition as required by the DBAL from an ORM field mapping definition.
  *
  * @param ClassMetadata $class The class that owns the field mapping.
  * @param array $mapping The field mapping.
  * @param Table $table
  * @return array The portable column definition as required by the DBAL.
  */
 private function _gatherColumn($class, array $mapping, $table)
 {
     $columnName = $class->getQuotedColumnName($mapping['fieldName'], $this->_platform);
     $columnType = $mapping['type'];
     $options = array();
     $options['length'] = isset($mapping['length']) ? $mapping['length'] : null;
     $options['notnull'] = isset($mapping['nullable']) ? !$mapping['nullable'] : true;
     if ($class->isInheritanceTypeSingleTable() && count($class->parentClasses) > 0) {
         $options['notnull'] = false;
     }
     $options['platformOptions'] = array();
     $options['platformOptions']['version'] = $class->isVersioned && $class->versionField == $mapping['fieldName'] ? true : false;
     if (strtolower($columnType) == 'string' && $options['length'] === null) {
         $options['length'] = 255;
     }
     if (isset($mapping['precision'])) {
         $options['precision'] = $mapping['precision'];
     }
     if (isset($mapping['scale'])) {
         $options['scale'] = $mapping['scale'];
     }
     if (isset($mapping['default'])) {
         $options['default'] = $mapping['default'];
     }
     if (isset($mapping['columnDefinition'])) {
         $options['columnDefinition'] = $mapping['columnDefinition'];
     }
     if ($class->isIdGeneratorIdentity() && $class->getIdentifierFieldNames() == array($mapping['fieldName'])) {
         $options['autoincrement'] = true;
     }
     if ($class->isInheritanceTypeJoined() && $class->name != $class->rootEntityName) {
         $options['autoincrement'] = false;
     }
     if ($table->hasColumn($columnName)) {
         // required in some inheritance scenarios
         $table->changeColumn($columnName, $options);
     } else {
         $table->addColumn($columnName, $columnType, $options);
     }
     $isUnique = isset($mapping['unique']) ? $mapping['unique'] : false;
     if ($isUnique) {
         $table->addUniqueIndex(array($columnName));
     }
 }
开发者ID:jackbravo,项目名称:symfony-sandbox,代码行数:52,代码来源:SchemaTool.php

示例15: getIndexedFields

 /**
  * Gets a list of all indexed fields
  *
  * @param ClassMetadata $metadata
  *
  * @return array [field name => field data-type, ...]
  */
 public function getIndexedFields(ClassMetadata $metadata)
 {
     $indexedColumns = [];
     $idFieldNames = $metadata->getIdentifierFieldNames();
     if (count($idFieldNames) > 0) {
         $indexedColumns[reset($idFieldNames)] = true;
     }
     if (isset($metadata->table['indexes'])) {
         foreach ($metadata->table['indexes'] as $index) {
             $firstFieldName = reset($index['columns']);
             if (!isset($indexedColumns[$firstFieldName])) {
                 $indexedColumns[$firstFieldName] = true;
             }
         }
     }
     $fields = [];
     $fieldNames = $metadata->getFieldNames();
     foreach ($fieldNames as $fieldName) {
         $mapping = $metadata->getFieldMapping($fieldName);
         $hasIndex = false;
         if (isset($mapping['unique']) && true === $mapping['unique']) {
             $hasIndex = true;
         } elseif (array_key_exists($mapping['columnName'], $indexedColumns)) {
             $hasIndex = true;
         }
         if ($hasIndex) {
             $fields[$fieldName] = $mapping['type'];
         }
     }
     return $fields;
 }
开发者ID:Maksold,项目名称:platform,代码行数:38,代码来源:DoctrineHelper.php


注:本文中的Doctrine\ORM\Mapping\ClassMetadata::getIdentifierFieldNames方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。