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


PHP ObjectManager::contains方法代码示例

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


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

示例1: doUpdate

 /**
  * {@inheritdoc}
  */
 protected function doUpdate($object, $flush = true)
 {
     if (!$this->manager->contains($object)) {
         $this->manager->persist($object);
     }
     if ($flush) {
         $this->flush($object);
     }
 }
开发者ID:php-lug,项目名称:lug,代码行数:12,代码来源:DomainManager.php

示例2: handle

 /**
  * {@inheritdoc}
  */
 public function handle(ApiCallInterface $apiCall)
 {
     if (!$this->objectManager->contains($apiCall)) {
         if ($apiCall->getId() === null) {
             $this->objectManager->persist($apiCall);
         } else {
             $this->objectManager->merge($apiCall);
         }
     }
     $this->objectManager->flush();
 }
开发者ID:assimtech,项目名称:dislog,代码行数:14,代码来源:DoctrineObjectManager.php

示例3: update

 /**
  * {@inheritdoc}
  */
 public function update(Content $content)
 {
     $managed = true;
     if (!$this->om->contains($content)) {
         $managed = false;
         $content = $this->om->merge($content);
     }
     $this->om->flush($content);
     if (!$managed) {
         $this->om->detach($content);
     }
 }
开发者ID:ivoaz,项目名称:content-editable-bundle,代码行数:15,代码来源:ContentManager.php

示例4: getIdentifierValues

 /**
  * Returns the values of the identifier fields of an entity.
  *
  * Doctrine must know about this entity, that is, the entity must already
  * be persisted or added to the identity map before. Otherwise an
  * exception is thrown.
  *
  * @param  object $entity The entity for which to get the identifier
  *
  * @return array          The identifier values
  *
  * @throws FormException  If the entity does not exist in Doctrine's identity map
  */
 public function getIdentifierValues($entity)
 {
     if (!$this->em->contains($entity)) {
         throw new FormException('Entities passed to the choice field must be managed');
     }
     return $this->classMetadata->getIdentifierValues($entity);
 }
开发者ID:usefulthink,项目名称:symfony,代码行数:20,代码来源:EntityChoiceList.php

示例5:

 function it_can_handle_exiting_unmanaged_objects(ObjectManager $objectManager, ApiCallInterface $apiCall)
 {
     $objectManager->contains($apiCall)->willReturn(false);
     $apiCall->getId()->willReturn(1);
     $objectManager->merge($apiCall)->shouldBeCalled();
     $objectManager->flush()->shouldBeCalled();
     $this->handle($apiCall);
 }
开发者ID:assimtech,项目名称:dislog,代码行数:8,代码来源:DoctrineObjectManagerSpec.php

示例6: getIdentifierValues

 /**
  * Returns the values of the identifier fields of an entity.
  *
  * Doctrine must know about this entity, that is, the entity must already
  * be persisted or added to the identity map before. Otherwise an
  * exception is thrown.
  *
  * @param object $entity The entity for which to get the identifier
  *
  * @return array          The identifier values
  *
  * @throws Exception If the entity does not exist in Doctrine's identity map
  */
 private function getIdentifierValues($entity)
 {
     if (!$this->em->contains($entity)) {
         throw new Exception('Entities passed to the choice field must be managed. Maybe ' . 'persist them in the entity manager?');
     }
     $this->em->initializeObject($entity);
     return $this->classMetadata->getIdentifierValues($entity);
 }
开发者ID:ronaldlunaramos,项目名称:webstore,代码行数:21,代码来源:EntityChoiceList.php

示例7: getIdValue

 /**
  * Returns the ID value for an object.
  *
  * This method assumes that the object has a single-column ID.
  *
  * @param object $object The object.
  *
  * @return mixed The ID value.
  */
 public function getIdValue($object)
 {
     if (!$object) {
         return;
     }
     if (!$this->om->contains($object)) {
         throw new RuntimeException('Entities passed to the choice field must be managed. Maybe ' . 'persist them in the entity manager?');
     }
     $this->om->initializeObject($object);
     return current($this->classMetadata->getIdentifierValues($object));
 }
开发者ID:neteasy-work,项目名称:hkgbf_crm,代码行数:20,代码来源:IdReader.php

示例8: getReference

 /**
  * Loads an object using stored reference
  * named by $name
  *
  * @param string $name
  * @throws OutOfBoundsException - if repository does not exist
  * @return object
  */
 public function getReference($name)
 {
     if (!$this->hasReference($name)) {
         throw new \OutOfBoundsException("Reference to: ({$name}) does not exist");
     }
     $reference = $this->references[$name];
     $meta = $this->manager->getClassMetadata(get_class($reference));
     if (!$this->manager->contains($reference) && isset($this->identities[$name])) {
         $reference = $this->manager->getReference($meta->name, $this->identities[$name]);
         $this->references[$name] = $reference;
         // already in identity map
     }
     return $reference;
 }
开发者ID:zhangyuxiao,项目名称:qoros,代码行数:22,代码来源:ReferenceRepository.php

示例9: getIdentifierByObject

 /**
  * Returns the (internal) identifier for the object, if it is known to the
  * backend. Otherwise NULL is returned.
  *
  * Note: this returns an identifier even if the object has not been
  * persisted in case of AOP-managed entities. Use isNewObject() if you need
  * to distinguish those cases.
  *
  * @param object $object
  * @return mixed The identifier for the object if it is known, or NULL
  * @api
  * @todo improve try/catch block
  */
 public function getIdentifierByObject($object)
 {
     if ($this->entityManager->contains($object)) {
         try {
             return current($this->entityManager->getUnitOfWork()->getEntityIdentifier($object));
         } catch (\Doctrine\ORM\ORMException $e) {
             return NULL;
         }
     } elseif (property_exists($object, 'FLOW3_Persistence_Identifier')) {
         return \TYPO3\FLOW3\Reflection\ObjectAccess::getProperty($object, 'FLOW3_Persistence_Identifier', TRUE);
     } else {
         return NULL;
     }
 }
开发者ID:nxpthx,项目名称:FLOW3,代码行数:27,代码来源:PersistenceManager.php

示例10: getIdentifierByObject

 /**
  * Returns the (internal) identifier for the object, if it is known to the
  * backend. Otherwise NULL is returned.
  *
  * Note: this returns an identifier even if the object has not been
  * persisted in case of AOP-managed entities. Use isNewObject() if you need
  * to distinguish those cases.
  *
  * @param object $object
  * @return mixed The identifier for the object if it is known, or NULL
  * @api
  * @todo improve try/catch block
  */
 public function getIdentifierByObject($object)
 {
     if (property_exists($object, 'Persistence_Object_Identifier')) {
         $identifierCandidate = ObjectAccess::getProperty($object, 'Persistence_Object_Identifier', true);
         if ($identifierCandidate !== null) {
             return $identifierCandidate;
         }
     }
     if ($this->entityManager->contains($object)) {
         try {
             return current($this->entityManager->getUnitOfWork()->getEntityIdentifier($object));
         } catch (\Doctrine\ORM\ORMException $exception) {
         }
     }
     return null;
 }
开发者ID:neos,项目名称:flow-development-collection,代码行数:29,代码来源:PersistenceManager.php

示例11: getIdentifierByObject

 /**
  * Returns the (internal) identifier for the object, if it is known to the
  * backend. Otherwise NULL is returned.
  *
  * Note: this returns an identifier even if the object has not been
  * persisted in case of AOP-managed entities. Use isNewObject() if you need
  * to distinguish those cases.
  *
  * @param object $object
  * @return mixed The identifier for the object if it is known, or NULL
  * @api
  * @todo improve try/catch block
  */
 public function getIdentifierByObject($object)
 {
     if (property_exists($object, 'Persistence_Object_Identifier')) {
         $identifierCandidate = \TYPO3\Flow\Reflection\ObjectAccess::getProperty($object, 'Persistence_Object_Identifier', TRUE);
         if ($identifierCandidate !== NULL) {
             return $identifierCandidate;
         }
     }
     if ($this->entityManager->contains($object)) {
         try {
             return current($this->entityManager->getUnitOfWork()->getEntityIdentifier($object));
         } catch (\Doctrine\ORM\ORMException $e) {
         }
     }
     return NULL;
 }
开发者ID:animaltool,项目名称:webinterface,代码行数:29,代码来源:PersistenceManager.php

示例12: refreshUser

 /**
  * (non-PHPdoc)
  *
  * @see \Symfony\Component\Security\Core\User\UserProviderInterface::refreshUser()
  */
 public function refreshUser(UserInterface $user)
 {
     $userClass = get_class($user);
     if (!$this->supportsClass($userClass)) {
         throw new UnsupportedUserException("Unsupported user '" . $userClass . "'");
     }
     /* @var ADH\UserBundle\Entity\User $user */
     if ($this->entityManager->contains($user)) {
         $this->entityManager->refresh($user);
     } else {
         $user = $this->userRepository->findOneById($user->getId());
     }
     if ($user === null) {
         throw new UsernameNotFoundException("User does not exist.");
     }
     return $user;
 }
开发者ID:Ad-Honorem,项目名称:site,代码行数:22,代码来源:UserManager.php

示例13: supports

 /**
  * {@inheritDoc}
  */
 public function supports($object)
 {
     return $this->om->contains($object);
 }
开发者ID:waifei,项目名称:createphp,代码行数:7,代码来源:BaseDoctrineRdfMapper.php

示例14: recomputeSingleObjectChangeSet

 /**
  * @param ObjectManager|DocumentManager|EntityManager $om
  * @param object                                      $object
  */
 protected function recomputeSingleObjectChangeSet(ObjectManager $om, $object)
 {
     if ($om->contains($object)) {
         $classMetadata = $om->getClassMetadata(get_class($object));
         $uow = $om->getUnitOfWork();
         if ($uow instanceof ODMUnitOfWork) {
             $uow->recomputeSingleDocumentChangeSet($classMetadata, $object);
         } elseif ($uow instanceof ORMUnitOfWork) {
             $uow->recomputeSingleEntityChangeSet($classMetadata, $object);
         }
     }
 }
开发者ID:integratedfordevelopers,项目名称:integrated-slug-bundle,代码行数:16,代码来源:SluggableSubscriber.php

示例15: computeViolations

 /**
  * @param object        $entity        entity
  * @param ObjectManager $entityManager entityManager
  * @param UnitOfWork    $uow           uow
  */
 private function computeViolations($entity, ObjectManager $entityManager, UnitOfWork $uow)
 {
     if (!($handlers = $this->handlerManager->fetch($entity))) {
         return null;
     }
     $list = $this->violationManager->getViolationListNotFixed($entity);
     $list->setFixed(true);
     foreach ($handlers as $handler) {
         $handler->validate($entity, $list);
     }
     $uow->computeChangeSets();
     foreach ($list as $violation) {
         $changeSet = $uow->getEntityChangeSet($violation);
         if (!empty($changeSet) || !$entityManager->contains($violation)) {
             $this->violations[spl_object_hash($violation)] = $violation;
         }
     }
 }
开发者ID:rezzza,项目名称:ModelViolationLoggerBundle,代码行数:23,代码来源:ViolationListener.php


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