當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。