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


PHP UnitOfWork::registerManaged方法代码示例

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


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

示例1: loadCacheEntry

 /**
  * {@inheritdoc}
  */
 public function loadCacheEntry(ClassMetadata $metadata, EntityCacheKey $key, EntityCacheEntry $entry, $entity = null)
 {
     $data = $entry->data;
     $hints = self::$hints;
     if ($entity !== null) {
         $hints[Query::HINT_REFRESH] = true;
         $hints[Query::HINT_REFRESH_ENTITY] = $entity;
     }
     foreach ($metadata->associationMappings as $name => $assoc) {
         if (!isset($assoc['cache']) || !isset($data[$name])) {
             continue;
         }
         $assocClass = $data[$name]->class;
         $assocId = $data[$name]->identifier;
         $isEagerLoad = $assoc['fetch'] === ClassMetadata::FETCH_EAGER || $assoc['type'] === ClassMetadata::ONE_TO_ONE && !$assoc['isOwningSide'];
         if (!$isEagerLoad) {
             $data[$name] = $this->em->getReference($assocClass, $assocId);
             continue;
         }
         $assocKey = new EntityCacheKey($assoc['targetEntity'], $assocId);
         $assocPersister = $this->uow->getEntityPersister($assoc['targetEntity']);
         $assocRegion = $assocPersister->getCacheRegion();
         $assocEntry = $assocRegion->get($assocKey);
         if ($assocEntry === null) {
             return null;
         }
         $data[$name] = $this->uow->createEntity($assocEntry->class, $assocEntry->resolveAssociationEntries($this->em), $hints);
     }
     if ($entity !== null) {
         $this->uow->registerManaged($entity, $key->identifier, $data);
     }
     $result = $this->uow->createEntity($entry->class, $data, $hints);
     $this->uow->hydrationComplete();
     return $result;
 }
开发者ID:AdactiveSAS,项目名称:doctrine2,代码行数:38,代码来源:DefaultEntityHydrator.php

示例2: getPartialReference

 /**
  * Gets a partial reference to the entity identified by the given type and identifier
  * without actually loading it, if the entity is not yet loaded.
  *
  * The returned reference may be a partial object if the entity is not yet loaded/managed.
  * If it is a partial object it will not initialize the rest of the entity state on access.
  * Thus you can only ever safely access the identifier of an entity obtained through
  * this method.
  *
  * The use-cases for partial references involve maintaining bidirectional associations
  * without loading one side of the association or to update an entity without loading it.
  * Note, however, that in the latter case the original (persistent) entity data will
  * never be visible to the application (especially not event listeners) as it will
  * never be loaded in the first place.
  *
  * @param string $entityName The name of the entity type.
  * @param mixed $identifier The entity identifier.
  * @return object The (partial) entity reference.
  */
 public function getPartialReference($entityName, $identifier)
 {
     $class = $this->metadataFactory->getMetadataFor(ltrim($entityName, '\\'));
     // Check identity map first, if its already in there just return it.
     if ($entity = $this->unitOfWork->tryGetById($identifier, $class->rootEntityName)) {
         return $entity instanceof $class->name ? $entity : null;
     }
     if (!is_array($identifier)) {
         $identifier = array($class->identifier[0] => $identifier);
     }
     $entity = $class->newInstance();
     $class->setIdentifierValues($entity, $identifier);
     $this->unitOfWork->registerManaged($entity, $identifier, array());
     $this->unitOfWork->markReadOnly($entity);
     return $entity;
 }
开发者ID:pollux1er,项目名称:dlawebdev2,代码行数:35,代码来源:EntityManager.php


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