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