当前位置: 首页>>代码示例>>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;未经允许,请勿转载。