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


PHP EntityManagerInterface::refresh方法代码示例

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


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

示例1: refreshEntityField

 /**
  * @param $entity
  * @param $field
  * @return null|object
  * @throws \Doctrine\ORM\ORMException
  * @throws \Doctrine\ORM\OptimisticLockException
  * @throws \Doctrine\ORM\TransactionRequiredException
  */
 protected function refreshEntityField($entity, $field)
 {
     $accessor = PropertyAccess::createPropertyAccessor();
     if ($accessor->isReadable($entity, $field)) {
         $field = $accessor->getValue($entity, $field);
         if (empty($field) && $this->entityManager->contains($entity)) {
             $this->entityManager->refresh($entity);
         }
         // if
     }
     // if
     return $this;
 }
开发者ID:slim627,项目名称:bellon,代码行数:21,代码来源:PathResolver.php

示例2: refresh

 /**
  * Refresh an entity
  *
  * @param object $entity
  * @return       $this
  */
 public function refresh($entity)
 {
     if ($this->supports($entity)) {
         $this->entityManager->refresh($entity);
     }
     return $this;
 }
开发者ID:FaustineMastrodicasa,项目名称:sfs,代码行数:13,代码来源:AbstractManager.php

示例3: postFormSubmit

 public function postFormSubmit(FormSubmitEvent $event)
 {
     $post = $event->getPost();
     $values = $post->getValueSet()->getValues();
     $this->entityManager->refresh($post);
     foreach ($values as $value) {
         if ($value instanceof AttachmentValue) {
             $media = $this->mediaManager->createMedia();
             $media->setFile($value->getFile());
             $media->setProvider('file');
             $value->setAttachment($media);
         }
     }
     $this->entityManager->persist($post);
     $this->entityManager->flush();
 }
开发者ID:dzoke,项目名称:CmsBundle,代码行数:16,代码来源:AttachmentListener.php

示例4: leave

 public function leave($id, UserInterface $user, $farewellMessage = 'Elvis has left the building.')
 {
     $channel = $this->find($id);
     $repo = $this->em->getRepository('SiciarekChatBundle:ChatChannelAssignee');
     $qb = $repo->createQueryBuilder('a')->leftJoin('a.channel', 'c')->andWhere('c.id = :channel')->andWhere('a.assigneeId = :id')->andWhere('a.assigneeClass = :class')->setParameters(['channel' => $id, 'id' => $user->getId(), 'class' => get_class($user)]);
     $query = $qb->getQuery();
     $assignee = $query->getSingleResult();
     $channel->removeAssignee($assignee);
     $this->em->remove($assignee);
     $this->em->flush();
     $this->em->refresh($channel);
     if ($channel->getAssignees()->count() === 0) {
         $this->em->remove($channel);
         $this->em->flush();
     }
     $this->getContainer()->get('chat.message')->send($farewellMessage, $id);
     return true;
 }
开发者ID:siciarek,项目名称:chat-bundle,代码行数:18,代码来源:ChatChannel.php

示例5: content

 /**
  * @param string $name
  * @param string $default
  * @return string
  */
 public function content($name, $default = 'no content')
 {
     /** @var Content $content */
     $content = $this->entityManager->getRepository('Ist1ContentBundle:Content')->findOneBy(['name' => $name]);
     if (!$content) {
         $content = new Content($name, $default);
     }
     /** @var \Gedmo\Translatable\Entity\Repository\TranslationRepository $translationRepo */
     $translationRepo = $this->entityManager->getRepository('Gedmo\\Translatable\\Entity\\Translation');
     $translations = $translationRepo->findTranslations($content);
     $locale = $this->requestStack->getCurrentRequest()->getLocale();
     if (!array_key_exists($locale, $translations)) {
         $content->setTranslatableLocale($locale);
         $this->entityManager->persist($content);
         $this->entityManager->flush();
     }
     $content->setTranslatableLocale($locale);
     $this->entityManager->refresh($content);
     return $content->getContent();
 }
开发者ID:janoist1,项目名称:ContentBundle,代码行数:25,代码来源:ContentExtension.php

示例6: postFormSubmit

 /**
  * @param FormSubmitEvent $event
  */
 public function postFormSubmit(FormSubmitEvent $event)
 {
     $post = $event->getPost();
     $values = $post->getValueSet()->getValues();
     $this->entityManager->refresh($post);
     foreach ($values as $value) {
         if ($value instanceof AttachmentValue) {
             // Avoid saving the attachment when it's empty and not required
             if (null === $value->getFile() && !$value->getAttribute()->getRequired()) {
                 continue;
             }
             $media = $this->mediaManager->createMedia();
             $media->setFile($value->getFile());
             $media->setProvider('file');
             $value->setAttachment($media);
         }
     }
     $this->entityManager->persist($post);
     $this->entityManager->flush();
 }
开发者ID:Opifer,项目名称:Cms,代码行数:23,代码来源:AttachmentListener.php

示例7: handleDetach

 /**
  * Detach given and create new keyword entity.
  *
  * @param CategoryInterface $category
  * @param Keyword $keyword
  *
  * @return Keyword
  */
 private function handleDetach(KeywordInterface $keyword, CategoryInterface $category)
 {
     $keywordString = $keyword->getKeyword();
     $keywordLocale = $keyword->getLocale();
     // if keyword wont be deleted (because of multiple references)
     // refresh it to be sure hat changes wont be written to
     // database.
     $this->entityManager->refresh($keyword);
     // delete old keyword from category
     $this->delete($keyword, $category);
     // create new keyword
     $newEntity = $this->keywordRepository->createNew();
     $newEntity->setKeyword($keywordString);
     $newEntity->setLocale($keywordLocale);
     // add new keyword to category
     return $this->save($newEntity, $category);
 }
开发者ID:sulu,项目名称:sulu,代码行数:25,代码来源:KeywordManager.php


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