當前位置: 首頁>>代碼示例>>PHP>>正文


PHP EntityManagerInterface::merge方法代碼示例

本文整理匯總了PHP中Doctrine\ORM\EntityManagerInterface::merge方法的典型用法代碼示例。如果您正苦於以下問題:PHP EntityManagerInterface::merge方法的具體用法?PHP EntityManagerInterface::merge怎麽用?PHP EntityManagerInterface::merge使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Doctrine\ORM\EntityManagerInterface的用法示例。


在下文中一共展示了EntityManagerInterface::merge方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getReference

 /**
  * {@inheritDoc}
  */
 public function getReference($name, $property = null)
 {
     if (isset($this->objectsCache[$name])) {
         try {
             $reference = $this->entityManager->merge($this->objectsCache[$name]);
         } catch (\Exception $e) {
             var_dump($e->getMessage());
             var_dump($this->objectsCache[$name]);
             exit;
         }
     } else {
         if (isset($this->references[$name])) {
             $reference = $this->references[$name];
         } else {
             throw new \UnexpectedValueException('Reference ' . $name . ' is not defined');
         }
     }
     if ($property !== null) {
         if (property_exists($reference, $property)) {
             $prop = new \ReflectionProperty($reference, $property);
             if ($prop->isPublic()) {
                 return $reference->{$property};
             }
         }
         $getter = 'get' . ucfirst($property);
         if (method_exists($reference, $getter) && is_callable(array($reference, $getter))) {
             return $reference->{$getter}();
         }
         throw new \UnexpectedValueException('Property ' . $property . ' is not defined for reference ' . $name);
     }
     return $reference;
 }
開發者ID:vivait,項目名稱:behat-fixture-extension,代碼行數:35,代碼來源:Yaml.php

示例2: saveCountries

 /**
  * @param array $countries
  */
 public function saveCountries($countries)
 {
     foreach ($countries as $country) {
         if ($this->em->find('MainBundle:Country', $country->getCodeCountry())) {
             $this->em->merge($country);
         } else {
             $this->em->persist($country);
         }
     }
     $this->em->flush();
 }
開發者ID:donatienthorez,項目名稱:sf_mobilIT_backEnd,代碼行數:14,代碼來源:CountryManager.php

示例3: prepare

 private function prepare($data)
 {
     $metaDataClass = $this->entityManager->getClassMetadata(get_class($data));
     $assocFields = $metaDataClass->getAssociationMappings();
     foreach ($assocFields as $assoc) {
         $relatedEntities = $metaDataClass->reflFields[$assoc['fieldName']]->getValue($data);
         if ($relatedEntities instanceof Collection) {
             if ($relatedEntities === $metaDataClass->reflFields[$assoc['fieldName']]->getValue($data)) {
                 continue;
             }
             if ($relatedEntities instanceof PersistentCollection) {
                 // Unwrap so that foreach() does not initialize
                 $relatedEntities = $relatedEntities->unwrap();
             }
             foreach ($relatedEntities as $relatedEntity) {
                 $relatedEntitiesState = $this->entityManager->getUnitOfWork()->getEntityState($relatedEntities);
                 if ($relatedEntitiesState === UnitOfWork::STATE_DETACHED) {
                     $metaDataClass->setFieldValue($data, $assoc['fieldName'], $this->entityManager->merge($relatedEntity));
                 }
             }
         } else {
             if ($relatedEntities !== null) {
                 $relatedEntitiesState = $this->entityManager->getUnitOfWork()->getEntityState($relatedEntities);
                 if ($relatedEntitiesState === UnitOfWork::STATE_DETACHED) {
                     $metaDataClass->setFieldValue($data, $assoc['fieldName'], $this->entityManager->merge($relatedEntities));
                 }
             }
         }
     }
 }
開發者ID:pbrazhko,項目名稱:form-wizard-bundle-for-symfony,代碼行數:30,代碼來源:WizardStorage.php

示例4: saveSections

 /**
  * @param array $sections
  */
 public function saveSections($sections)
 {
     foreach ($sections as $section) {
         $oldSection = $this->sectionFetcher->getSection($section->getCodeSection());
         if (!$oldSection) {
             $this->em->persist($section);
             $this->em->flush();
         } else {
             $section->setGuide($oldSection->getGuide());
             $section->setToken($oldSection->getToken());
             $section->setLogoUrl($oldSection->getLogoUrl());
             $section->setAddedAt($oldSection->getAddedAt());
             $section->setActivated($oldSection->isActivated());
             $section->setUpdatedAt();
             $this->em->merge($section);
             $this->em->flush();
         }
     }
 }
開發者ID:donatienthorez,項目名稱:sf_mobilIT_backEnd,代碼行數:22,代碼來源:SectionManager.php

示例5: merge

 private function merge(Article $article)
 {
     $this->em->merge($article);
 }
開發者ID:ffff5912,項目名稱:antena,代碼行數:4,代碼來源:ArticleRepository.php

示例6: mergeAndPersist

 public function mergeAndPersist(EntityManagerInterface $entityManager)
 {
     $settings = $entityManager->merge($this);
     $entityManager->persist($settings);
     return $settings;
 }
開發者ID:ppiedaderawnet,項目名稱:concrete5,代碼行數:6,代碼來源:Settings.php

示例7: mergeAndPersist

 public function mergeAndPersist(EntityManagerInterface $entityManager)
 {
     $tempOptions = array();
     foreach ($this->list->getOptions() as $option) {
         if (!$option->getSelectAttributeOptionID()) {
             $tempOptions[] = $option;
             $this->list->getOptions()->removeElement($option);
         }
     }
     $settings = $entityManager->merge($this);
     foreach ($tempOptions as $option) {
         $option->setOptionList($settings->list);
         $settings->list->getOptions()->add($option);
     }
     $entityManager->persist($settings);
     return $settings;
 }
開發者ID:ppiedaderawnet,項目名稱:concrete5,代碼行數:17,代碼來源:SelectSettings.php

示例8: delete

 /**
  * @param $entity
  * @return mixed
  */
 public function delete($entity)
 {
     $entity = $this->entityManager->merge($entity);
     $this->entityManager->remove($entity);
     $this->entityManager->flush();
 }
開發者ID:mkbrv,項目名稱:laravel-doctrine-project,代碼行數:10,代碼來源:AbstractRepository.php


注:本文中的Doctrine\ORM\EntityManagerInterface::merge方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。