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


PHP EntityManager::getClassMetadata方法代码示例

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


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

示例1: getEntityPrimaryKeyName

 /**
  * Primary key name in entity
  *
  * @param object|string $entity
  * @return string
  * @throws \Doctrine\ORM\Mapping\MappingException
  */
 protected function getEntityPrimaryKeyName($entity)
 {
     if (is_object($entity)) {
         $entity = ClassUtils::getClass($entity);
     }
     $meta = $this->entityManager->getClassMetadata($entity);
     return $meta->getSingleIdentifierFieldName();
 }
开发者ID:pecinaon,项目名称:doctrine-mapper,代码行数:15,代码来源:BaseMapper.php

示例2: isEntity

 /**
  * @param string
  * @return bool
  */
 private function isEntity($className)
 {
     try {
         $this->em->getClassMetadata($className);
         return TRUE;
     } catch (Doctrine\Common\Persistence\Mapping\MappingException $e) {
         return FALSE;
     }
 }
开发者ID:Olicek,项目名称:DoctrineMethodsHydrator,代码行数:13,代码来源:ParametersToEntitiesConvertor.php

示例3: setIdentity

 /**
  * Sets the user identity.
  * @return UserStorage Provides a fluent interface
  */
 public function setIdentity(IIdentity $identity = null)
 {
     if ($identity !== NULL) {
         $class = get_class($identity);
         // we want to convert identity entities into fake identity
         // so only the identifier fields are stored,
         // but we are only interested in identities which are correctly
         // mapped as doctrine entities
         if ($this->entityManager->getMetadataFactory()->hasMetadataFor($class)) {
             $cm = $this->entityManager->getClassMetadata($class);
             $identifier = $cm->getIdentifierValues($identity);
             $identity = new FakeIdentity($identifier, $class);
         }
     }
     return parent::setIdentity($identity);
 }
开发者ID:blitzik,项目名称:vycetky-doctrine,代码行数:20,代码来源:UserStorage.php

示例4: detectPrimaryKey

 /**
  * @param \Kdyby\Doctrine\Entities\BaseEntity $object
  * @return string
  */
 private function detectPrimaryKey(BaseEntity $object)
 {
     if ($object instanceof BaseEntity) {
         $meta = $this->entityManager->getClassMetadata(get_class($object));
         $name = $meta->getSingleIdentifierFieldName();
         return $meta->getFieldValue($object, $name);
     }
 }
开发者ID:venne,项目名称:venne,代码行数:12,代码来源:NotificationManager.php

示例5: create

 /**
  * @param object|string
  * @param bool|null
  */
 public function create($entity, $createMapper = self::AUTO)
 {
     $className = is_string($entity) ? $entity : get_class($entity);
     $classMetadata = $this->entityManager->getClassMetadata($className);
     /** @var FormBuilder $builder */
     $builder = $this->configuration->getHandler()->handle(NULL, [], $classMetadata, $this->configuration);
     if (!$builder instanceof FormBuilder) {
         throw new UnexpectedValueException("Builder created by root handler must be an instance of FormBuilder");
     }
     if ($createMapper === TRUE || $createMapper === self::AUTO && is_object($entity)) {
         if (!is_object($entity)) {
             throw new InvalidArgumentException("If you want to create mapper, you have to pass an entity.");
         }
         if (!$this->mapperFactory) {
             throw new InvalidStateException("MapperFactory has not been injected.");
         }
         $form = $builder->getForm();
         if (!$form instanceof IFormWithMapper) {
             throw new InvalidStateException("Form does not implement \\Librette\\Forms\\IFormWithMapper");
         }
         $form->setMapper($this->mapperFactory->create($entity));
     }
     return $builder;
 }
开发者ID:librette,项目名称:doctrine-forms,代码行数:28,代码来源:FormBuilderFactory.php

示例6: buildSelectForUpdateQuery

 /**
  * @param EntityRepository $repository
  * @param ORMMetadata $class
  * @return \Doctrine\ORM\QueryBuilder
  */
 protected function buildSelectForUpdateQuery(EntityRepository $repository, ORMMetadata $class)
 {
     $qb = $repository->createQueryBuilder('e', 'e.id');
     $i = 0;
     foreach ($class->getAssociationMappings() as $assocMapping) {
         if (!$class->isSingleValuedAssociation($assocMapping['fieldName'])) {
             continue;
         }
         $targetClass = $this->entityManager->getClassMetadata($assocMapping['targetEntity']);
         $alias = substr($assocMapping['fieldName'], 0, 1) . $i++;
         $qb->leftJoin('e.' . $assocMapping['fieldName'], $alias)->addSelect($alias);
         // todo: deeper!
     }
     return $qb;
 }
开发者ID:rohlikcz,项目名称:DoctrineSearch,代码行数:20,代码来源:DefaultEntityRiver.php

示例7: getUniqueAndRequiredAssociations

 private function getUniqueAndRequiredAssociations(ClassMetadata $meta, $entity)
 {
     $associations = array();
     foreach ($meta->getAssociationNames() as $associationName) {
         $mapping = $meta->getAssociationMapping($associationName);
         if (!empty($mapping['id']) && $meta->usesIdGenerator()) {
             // autogenerated id
             continue;
         }
         if (!($mapping['type'] & ClassMetadata::TO_ONE)) {
             // is not to one relation
             continue;
         }
         if (empty($mapping['isOwningSide'])) {
             // is not owning side
             continue;
         }
         foreach ($mapping['joinColumns'] as $joinColumn) {
             if (!empty($joinColumn['nullable']) && empty($joinColumn['unique'])) {
                 // is nullable and is not unique
                 continue;
             }
             $targetColumn = $joinColumn['referencedColumnName'];
             $targetClass = $this->em->getClassMetadata($mapping['targetEntity']);
             $newVal = $meta->getFieldValue($entity, $associationName);
             if ($newVal !== NULL) {
                 $newValId = $this->uow->getEntityIdentifier($newVal);
             }
             switch (TRUE) {
                 case $newVal === NULL:
                     $value = NULL;
                     break;
                 case $targetClass->containsForeignIdentifier:
                     $value = $newValId[$targetClass->getFieldForColumn($targetColumn)];
                     break;
                 default:
                     $value = $newValId[$targetClass->fieldNames[$targetColumn]];
                     break;
             }
             $sourceColumn = $joinColumn['name'];
             $quotedColumn = $this->quotes->getJoinColumnName($joinColumn, $meta, $this->platform);
             $associations[$sourceColumn]['value'] = $value;
             $associations[$sourceColumn]['quotedColumn'] = $quotedColumn;
             $associations[$sourceColumn]['type'] = $targetClass->getTypeOfColumn($targetColumn);
         }
     }
     return $associations;
 }
开发者ID:peterkrejci,项目名称:music-collection,代码行数:48,代码来源:NonLockingUniqueInserter.php

示例8: renderDefault

 public function renderDefault()
 {
     $this->em->getClassMetadata(\Entities\ITag::class);
     $this->template->anyVariable = 'any value';
 }
开发者ID:jirinapravnik,项目名称:doctrine-rtel,代码行数:5,代码来源:HomepagePresenter.php

示例9: getPrimaryKeyByObject

 /**
  * @param mixed $object
  * @return string[]
  */
 public function getPrimaryKeyByObject($object)
 {
     return array(self::ENTITY_CLASS => $this->entityManager->getClassMetadata(get_class($object))->name, self::PRIMARY_KEY => $this->entityManager->getUnitOfWork()->getSingleIdentifierValue($object));
 }
开发者ID:venne,项目名称:data-transfer,代码行数:8,代码来源:EntityDriver.php

示例10: addScope

 /**
  * @param EntityManager
  * @param ISortableScope
  * @param QueryBuilder
  */
 private function addScope(EntityManager $em, ISortableScope $sortable, QueryBuilder $qb)
 {
     $meta = $em->getClassMetadata(get_class($sortable));
     $rc = new \ReflectionClass($sortable);
     foreach ($sortable->getSortableScope() as $field) {
         if ($meta->hasField($field) || $meta->hasAssociation($field)) {
             $rp = $rc->getProperty($field);
             $rp->setAccessible(TRUE);
             $qb->andWhere($qb->expr()->eq('e.' . $field, ':p_' . $field));
             $qb->setParameter('p_' . $field, $rp->getValue($sortable));
         } elseif ($meta->discriminatorColumn['name'] === $field) {
             if (($type = array_search(get_class($sortable), $meta->discriminatorMap)) === FALSE) {
                 $type = get_class($sortable);
             }
             $qb->andWhere('e INSTANCE OF :discr_type')->setParameter('discr_type', $type);
         } else {
             throw new InvalidScopeException("Scope field {$field} is neither field, association nor discriminator");
         }
     }
 }
开发者ID:librette,项目名称:doctrine-sortable,代码行数:25,代码来源:SortableListener.php


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