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


PHP EntityManager::merge方法代码示例

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


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

示例1: onIndexUpdate

 /**
  * The actual listener, will store the objects in the database
  *
  * @param IndexUpdateEvent $event
  */
 public function onIndexUpdate(IndexUpdateEvent $event)
 {
     $objects = $event->getObjects();
     foreach ($objects as $indexItem) {
         $this->em->merge($indexItem);
     }
     $this->em->flush();
 }
开发者ID:sumocoders,项目名称:framework-search-bundle,代码行数:13,代码来源:IndexListener.php

示例2: merge

 /**
  * @param string $id
  * @param string|int|float $value
  * @return void
  */
 public function merge($id, $value)
 {
     $entity = $this->createEntity();
     $entity->setId($id);
     $entity->setContent(is_array($value) ? serialize($value) : $value);
     $entity->setIsSerialized(is_array($value));
     $this->em->merge($entity);
 }
开发者ID:webchemistry,项目名称:parameters,代码行数:13,代码来源:Doctrine.php

示例3: addWatcher

 /**
  * @param Ticket $ticket
  * @param User $user
  */
 public function addWatcher(Ticket $ticket, User $user)
 {
     $watcher = $this->watcherListRepository->findOne($ticket, $user);
     if (!$watcher) {
         $ticket = $this->em->merge($ticket);
         $watcher = new WatcherList($ticket, $user);
         $this->watcherListRepository->store($watcher);
     }
 }
开发者ID:northdakota,项目名称:DiamanteDeskBundle,代码行数:13,代码来源:WatchersServiceImpl.php

示例4: getUser

 /**
  * Get the currently logged in user
  *
  * @throws AccessDeniedHttpException When no currently logged in user exists in the session
  *
  * @return User
  */
 public function getUser()
 {
     $user = $this->tokenStorage->getToken()->getUser();
     if (!$user instanceof User) {
         $this->session->getFlashBag()->add(self::ERROR_TYPE, self::ERROR_MESSAGE);
         throw new AccessDeniedHttpException(self::ERROR_MESSAGE);
     }
     return $this->entityManager->merge($user);
 }
开发者ID:j7mbo,项目名称:aurex,代码行数:16,代码来源:UserProvider.php

示例5: set

 /**
  * @param string $key
  * @param mixed  $value
  */
 public function set($key, $value)
 {
     $config = $this->getConfig($key);
     $object = new \stdClass();
     $object->Value = $value;
     $config->setValue($object);
     $this->em->merge($config);
     $this->em->flush();
 }
开发者ID:Opifer,项目名称:Cms,代码行数:13,代码来源:ConfigManager.php

示例6: update

 /**
  * 
  * @param Hanking $entity
  * @return boolean|Hanking
  */
 public function update(Hanking $entity)
 {
     try {
         $this->manager->merge($entity);
         $this->manager->flush();
         return $entity;
     } catch (Exception $ex) {
         return false;
     }
 }
开发者ID:serbinario,项目名称:UCHI,代码行数:15,代码来源:RankingDAO.php

示例7: get

 /**
  * @return Comunidad|mixed|null|object
  * @throws \Doctrine\ORM\ORMException
  * @throws \Doctrine\ORM\OptimisticLockException
  * @throws \Doctrine\ORM\TransactionRequiredException
  */
 public function get()
 {
     if ($this->comunidad instanceof Comunidad) {
         return $this->comunidad;
     }
     if ($this->session->has('comunidad')) {
         $comunidad = $this->session->get('comunidad');
         $this->comunidad = $this->em->merge($comunidad);
         return $this->comunidad;
     }
     return null;
 }
开发者ID:javiermadueno,项目名称:futbol,代码行数:18,代码来源:ComunidadProvider.php

示例8: detailAction

 /**
  * @Template
  *
  * @param Request $request
  * @param Question $question
  * @param string $answer
  * @return array
  */
 public function detailAction(Request $request, Question $question, $answer = null)
 {
     /** @var User $currentUser */
     $currentUser = $this->entityManager->merge($this->loginUser->getUser());
     if ($answer) {
         $correct = $answer == $question->getCorrectAnswer();
         $consumption = new QuestionAnswer($currentUser, $question, $correct);
         $this->entityManager->persist($consumption);
         $this->entityManager->flush();
         return new RedirectResponse($this->urlGenerator->generate('home'));
     }
     return ['question' => $question];
 }
开发者ID:alineswinkels,项目名称:koffietijd,代码行数:21,代码来源:QuestionController.php

示例9: consumptionAction

 /**
  * @Template
  *
  * @param Request $request
  * @return array
  */
 public function consumptionAction(Request $request)
 {
     /** @var User $currentUser */
     $currentUser = $this->entityManager->merge($this->loginUser->getUser());
     $users = $this->userRepository->findAllExceptUser($currentUser);
     $receiverId = $request->query->get('receiver_id');
     $receiver = $this->userRepository->findOneById($receiverId);
     if ($receiver) {
         $consumption = new Consumption($currentUser, $receiver);
         $this->entityManager->persist($consumption);
         $this->entityManager->flush();
         return new RedirectResponse($this->urlGenerator->generate('question_detail', ['id' => $this->questionRepository->findOneRandom()->getId()]));
     }
     return ['users' => $users];
 }
开发者ID:alineswinkels,项目名称:koffietijd,代码行数:21,代码来源:UserController.php

示例10: loadAndMergeEntity

 /**
  * @param \Scribe\Doctrine\ORM\Mapping\Entity|mixed $entity
  * @param mixed                                     $index
  *
  * @throws \Exception
  *
  * @return $this
  */
 protected function loadAndMergeEntity($index, $entity)
 {
     try {
         $entityMetadata = $this->getClassMetadata($this->getEntityFQCN());
         $this->identLog[] = $identity = $entityMetadata->getIdentifierValues($entity);
         if (count($identity) > 0) {
             $identity = [key($identity) => current($identity)];
         } elseif (!$entity->hasIdentity()) {
             OutBuffer::stat('+y/b-preload +y/i-[warns]+w/- import could not begin for "%s:%d"', basename($this->metadata->getName()), $index);
             OutBuffer::stat('+y/b-preload +y/i-[warns]+w/- import strategy "merge" unavailable due to failed identifier map resolution');
         }
         $repository = $this->manager->getRepository($this->getEntityFQCN());
         $entitySearched = $repository->findOneBy($identity);
         $this->manager->initializeObject($entitySearched);
         if ($entitySearched && !$entity->isEqualTo($entitySearched)) {
             $mapper = new HydratorManager(new HydratorMapping(true));
             $entity = $mapper->getMappedObject($entity, $entitySearched);
             $this->manager->remove($entitySearched);
             $this->manager->merge($entity);
             $this->manager->persist($entity);
             $this->manager->flush();
             $this->manager->clear();
             ++$this->countUpdate;
             return $this;
         } elseif ($entitySearched && $entity->isEqualTo($entitySearched)) {
             $entity = $entitySearched;
             ++$this->countSkip;
             return $this;
         }
         $this->loadAndPersistEntity($entity);
     } catch (\Exception $e) {
         throw $e;
     }
     return $this;
 }
开发者ID:scr-be,项目名称:arthur-doctrine-fixtures-bundle,代码行数:43,代码来源:AbstractFixture.php

示例11: insertUpdateProcessing

 public function insertUpdateProcessing(EntityManager $em, $data, $id = null)
 {
     $update = !is_null($id);
     try {
         $em->beginTransaction();
         if ($update) {
             $language = $em->find('Model\\Language', $id);
         } else {
             $language = new Language();
         }
         $language->setCode($data['code']);
         $language->setDescription($data['description']);
         $language->setFlagImageURL($data['flagimageurl']);
         $menu = $em->find('Model\\Menu', $data['menuid']);
         $language->setMenu($menu);
         if ($update) {
             $em->merge($language);
         } else {
             $em->persist($language);
         }
         $em->flush();
         $em->commit();
     } catch (\Exception $e) {
         $em->rollback();
         throw $e;
     }
     return $language->getId();
 }
开发者ID:francescocambi,项目名称:FCMS2,代码行数:28,代码来源:EditorController.php

示例12: onAuthenticationSuccessResponse

 /**
  * Add unsigned parameters, such as:
  * - databases (this list is also signed but presented here for listing to unauthenticated clients)
  * - parameters, extra info you may attach to object as necessary
  *
  * @param AuthenticationSuccessEvent $event
  */
 public function onAuthenticationSuccessResponse(AuthenticationSuccessEvent $event)
 {
     $data = $event->getData();
     $AuthUser = $event->getUser();
     if (!$AuthUser instanceof AuthUser) {
         throw new AccessDeniedException('AuthUser object not found');
     }
     if (!in_array('ROLE_USER', $AuthUser->getRoles())) {
         throw new AccessDeniedException('User lacks necessary role');
     }
     $AuthUser->setLastToken($data['token']);
     $AuthUser = $this->entityManager->merge($AuthUser);
     $this->entityManager->persist($AuthUser);
     $this->entityManager->flush();
     $data['databases'] = $this->getDatabaseArray($event->getUser());
     $data['parameters'] = $this->getParametersArray($event->getUser());
     $event->setData($data);
 }
开发者ID:Maltronic,项目名称:JwtDbSwitcher,代码行数:25,代码来源:AuthenticationSuccessListener.php

示例13: merge

 /**
  * @param mixed $entity
  * @param bool  $flush
  */
 public function merge($entity, $flush = null)
 {
     if ($entity !== null) {
         $this->entityManager->merge($entity);
     }
     if ($flush) {
         $this->entityManager->flush();
     }
 }
开发者ID:vimalkaurani,项目名称:healthByte,代码行数:13,代码来源:Helper.php

示例14: update

 public function update(\Entity\Usuario $usuario)
 {
     try {
         $this->em->merge($usuario);
         $this->em->flush();
     } catch (Exception $ex) {
         $this->CI->log->write_log('error', $ex->getMessage() . ' - usuario_dao::update ');
     }
 }
开发者ID:jeanlopes,项目名称:mostra-ifrs-poa,代码行数:9,代码来源:usuario_dao.php

示例15: merge

 /**
  * Efetua o merge do model atual com o banco de dados persistindo os dados editados.
  *
  * @param Model $model
  */
 public function merge(Model $model)
 {
     try {
         $this->manager->merge($model);
     } catch (\Exception $e) {
         Error::log($e);
         return false;
     }
     return true;
 }
开发者ID:anna-framework,项目名称:anna,代码行数:15,代码来源:Repository.php


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