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


PHP EntityManager::detach方法代碼示例

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


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

示例1: convertFromLoanApp

 public function convertFromLoanApp(LoanApplication $application)
 {
     $this->em->detach($application);
     $vantage = $this->formatVantage($application);
     $applicationXml = $this->container->get('templating')->render('SudouxMortgageBundle:LoanApplicationAdmin/formats:vantageFull.xml.twig', array('application' => $vantage), 'text/xml');
     return $applicationXml;
 }
開發者ID:eric19h,項目名稱:turbulent-wookie,代碼行數:7,代碼來源:VantageFormat.php

示例2: onMessage

 /**
  * @param ConnectionInterface $from
  * @param string $data
  */
 public function onMessage(ConnectionInterface $from, $data)
 {
     $data = json_decode($data);
     if (JSON_ERROR_NONE !== json_last_error() || !is_array($data) || count($data) < 0) {
         return;
     }
     $message = $this->onReceiveData($from->user, $data);
     if (null !== $message) {
         $this->em->detach($message);
     }
 }
開發者ID:elfchat,項目名稱:elfchat,代碼行數:15,代碼來源:WebSocketServer.php

示例3: onBroadcast

 /**
  * @param ChannelBroadcastEvent $event
  */
 public function onBroadcast(ChannelBroadcastEvent $event)
 {
     if (!$event->checkContext('email')) {
         return;
     }
     // Get list of published broadcasts or broadcast if there is only a single ID
     $id = $event->getId();
     $emails = $this->model->getRepository()->getPublishedBroadcasts($id);
     $output = $event->getOutput();
     /** @var Email $email */
     while (($email = $emails->next()) !== false) {
         list($sentCount, $failedCount, $ignore) = $this->model->sendEmailToLists($email[0], null, 100, true, $output);
         $event->setResults($this->translator->trans('mautic.email.email') . ': ' . $email[0]->getName(), $sentCount, $failedCount);
         $this->em->detach($email[0]);
     }
 }
開發者ID:dongilbert,項目名稱:mautic,代碼行數:19,代碼來源:BroadcastSubscriber.php

示例4: resetCacheEntity

 /**
  * Resets the last stored entity.
  *
  * @codeCoverageIgnore
  */
 private function resetCacheEntity()
 {
     if (null !== $this->_entity) {
         $this->_em->detach($this->_entity);
         $this->_entity = null;
     }
 }
開發者ID:mickaelsteinberg,項目名稱:BackBee,代碼行數:12,代碼來源:Cache.php

示例5: handleCannibalisticEntity

 /**
  * @param Entity $entity
  *
  * @return $this
  */
 protected function handleCannibalisticEntity(Entity $entity)
 {
     if ($this->metadata->isCannibal()) {
         $this->manager->flush($entity);
         $this->manager->detach($entity);
     }
     return $this;
 }
開發者ID:scr-be,項目名稱:arthur-doctrine-fixtures-bundle,代碼行數:13,代碼來源:AbstractFixture.php

示例6: toEntity

 /**
  * @param string $entityName
  * @param array $values
  * @throws \RuntimeException
  * @return object Detached Doctrine2 entity instance
  */
 public function toEntity($entityName, $values)
 {
     $false = serialize(false);
     if (!empty($values[self::SERIALIZED_KEY])) {
         foreach ($values[self::SERIALIZED_KEY] as $field) {
             $result = unserialize($values[$field]);
             if ($values[$field] !== $false && $result === false) {
                 throw new RuntimeException('Could not unserialize value: ' . $values[$field]);
             }
             $values[$field] = $result;
         }
     }
     $unit = $this->em->getUnitOfWork();
     $entity = $unit->createEntity($entityName, $values);
     $this->em->detach($entity);
     return $entity;
 }
開發者ID:vend,項目名稱:doxport,代碼行數:23,代碼來源:EntityArrayHelper.php

示例7: clearRound

 /**
  * @param Tournament $tournament
  * @param int $round
  * @return void
  */
 private function clearRound(Tournament $tournament, int $round)
 {
     $this->getTournamentHandler()->clearRound($tournament, $round);
     foreach ($this->possibleTournamentGames as $possibleTournamentGame) {
         $this->manager->detach($possibleTournamentGame);
         $this->manager->detach($possibleTournamentGame->getGame());
     }
     $this->possibleTournamentGames = [];
 }
開發者ID:StasPiv,項目名稱:playzone,代碼行數:14,代碼來源:SwissService.php

示例8: write

 /**
  * Do persist into EntityManager
  *
  * @param array $items
  */
 private function write(array $items)
 {
     foreach ($items as $item) {
         $this->em->persist($item);
     }
     $this->em->flush();
     foreach ($items as $item) {
         $this->em->detach($item);
     }
 }
開發者ID:dairdr,項目名稱:crm,代碼行數:15,代碼來源:AbstractDefaultChannelDataFixture.php

示例9: filterProductValues

 /**
  * Filter on product values
  *
  * @param AbstractProduct $product
  *
  * @return AbstractProduct
  */
 public function filterProductValues(AbstractProduct $product)
 {
     $this->entityManager->detach($product);
     $productValues = $product->getValues();
     $identifierType = $product->getIdentifier()->getAttribute()->getAttributeType();
     foreach ($productValues as $productValue) {
         if ($identifierType != $productValue->getAttribute()->getAttributeType() && (null == $productValue->getUpdated() || null != $productValue->getUpdated() && $product->getUpdated()->getTimestamp() - $productValue->getUpdated()->getTimestamp() > 60)) {
             $product->removeValue($productValue);
         }
     }
     return $product;
 }
開發者ID:calin-marian,項目名稱:DrupalCommerceConnectorBundle,代碼行數:19,代碼來源:ProductExportManager.php

示例10: execute

 public function execute(InputInterface $input, OutputInterface $output)
 {
     $mapper = $input->getOption('mapper');
     $this->validateMapper($mapper);
     $this->entityManager = $this->getContainer()->get('doctrine.orm.entity_manager');
     $iterableResult = $this->getIterableResult();
     /**
      * @var \Closure $closure
      */
     $closure = (require $mapper);
     foreach ($iterableResult as $collection) {
         foreach ($collection as $perspective) {
             $perspective = $closure($perspective);
             $this->entityManager->persist($perspective);
             $this->entityManager->flush($perspective);
             $this->entityManager->detach($perspective);
         }
     }
     $successMessage = $this->getContainer()->get('translator')->trans('perspective_mapping_success');
     $output->writeln($successMessage);
 }
開發者ID:WeavingTheWeb,項目名稱:devobs,代碼行數:21,代碼來源:MapPerspectiveCommand.php

示例11: testUserRepository

 public function testUserRepository()
 {
     $user = $this->em->getRepository('AppBundle:User')->loadUserByUsername('belac');
     $this->assertEquals('belac', $user->getUsername());
     //    }
     //   public function testRefreshUser()
     //   {
     $user = $this->em->getRepository('AppBundle:User')->loadUserByUsername('belac');
     $this->em->detach($user);
     $user->setUsername('notBelac');
     $serializedUser = serialize($user);
     $unSerializedUser = unserialize($serializedUser);
     $user = $this->em->getRepository('AppBundle:User')->refreshUser($unSerializedUser);
     $this->assertEquals('belac', $user->getUsername());
     // }
     //public function testSearchUsers()
     //{
     $criteria = array('email' => 'belackriv@gmail.com');
     $users = $this->em->getRepository('AppBundle:User')->searchUsers($criteria);
     $this->assertCount(1, $users);
     $this->assertEquals('belackriv@gmail.com', $users[0]->getEmail());
 }
開發者ID:belackriv,項目名稱:step-inventory,代碼行數:22,代碼來源:UserRepositoryFunctionalTest.php

示例12: exportData

 /**
  * クエリビルダにもとづいてデータ行を出力する.
  * このメソッドを使う場合は, 事前にsetExportQueryBuilder($qb)で出力対象のクエリビルダをわたしておく必要がある.
  *
  * @param \Closure $closure
  */
 public function exportData(\Closure $closure)
 {
     if (is_null($this->qb) || is_null($this->em)) {
         throw new \LogicException('query builder not set.');
     }
     $this->fopen();
     $query = $this->qb->getQuery();
     foreach ($query->getResult() as $iteratableResult) {
         $closure($iteratableResult, $this);
         $this->em->detach($iteratableResult);
         $query->free();
         flush();
     }
     $this->fclose();
 }
開發者ID:ec-cube,項目名稱:ec-cube,代碼行數:21,代碼來源:CsvExportService.php

示例13: createTicket

 /**
  * Creates Ticket and Message Reference fot it
  *
  * @param $messageId
  * @param $branchId
  * @param $subject
  * @param $description
  * @param $reporter
  * @param $assigneeId
  * @param array $attachments
  * @return \Diamante\DeskBundle\Model\Ticket\Ticket
  * @throws \RuntimeException if unable to load required branch, reporter, assignee
  */
 public function createTicket($messageId, $branchId, $subject, $description, $reporter, $assigneeId, array $attachments = null)
 {
     if (empty($subject)) {
         $subject = self::EMPTY_SUBJECT_PLACEHOLDER;
     }
     $this->ticketBuilder->setSubject($subject)->setDescription($description)->setBranchId($branchId)->setReporter($reporter)->setAssigneeId($assigneeId)->setSource(Source::EMAIL);
     $ticket = $this->ticketBuilder->build();
     if ($attachments) {
         $this->createAttachments($attachments, $ticket);
     }
     $this->ticketRepository->store($ticket);
     $this->createMessageReference($messageId, $ticket);
     $this->em->detach($ticket);
     $this->dispatchEvents($ticket);
     return $ticket;
 }
開發者ID:northdakota,項目名稱:DiamanteDeskBundle,代碼行數:29,代碼來源:MessageReferenceServiceImpl.php

示例14: createTicket

 /**
  * Create Ticket
  * @param CreateTicketCommand $command
  * @return \Diamante\DeskBundle\Model\Ticket\Ticket
  * @throws \RuntimeException if unable to load required branch, reporter, assignee
  */
 public function createTicket(CreateTicketCommand $command)
 {
     $this->isGranted('CREATE', 'Entity:DiamanteDeskBundle:Ticket');
     \Assert\that($command->attachmentsInput)->nullOr()->all()->isInstanceOf('Diamante\\DeskBundle\\Api\\Dto\\AttachmentInput');
     $this->ticketBuilder->setSubject($command->subject)->setDescription($command->description)->setBranchId($command->branch)->setReporter($command->reporter)->setAssigneeId($command->assignee)->setPriority($command->priority)->setSource($command->source)->setStatus($command->status)->setTags($command->tags);
     $ticket = $this->ticketBuilder->build();
     if (is_array($command->attachmentsInput) && false === empty($command->attachmentsInput)) {
         foreach ($command->attachmentsInput as $each) {
             $this->attachmentManager->createNewAttachment($each->getFilename(), $each->getContent(), $ticket);
         }
     }
     $this->ticketRepository->store($ticket);
     if ($this->securityFacade->getOrganization()) {
         $this->tagManager->saveTagging($ticket);
     }
     $this->em->detach($ticket);
     $this->dispatchEvents($ticket);
     return $ticket;
 }
開發者ID:northdakota,項目名稱:DiamanteDeskBundle,代碼行數:25,代碼來源:TicketServiceImpl.php

示例15: findWithFilters

 /**
  * Find the latest revisions of all connections that match the given filters and return them as Dto's
  *
  * @param array $filter
  * @param string|null $sortBy
  * @param string $sortOrder
  * @return ConnectionDtoCollection
  */
 public function findWithFilters(array $filter = array(), $sortBy = null, $sortOrder = 'DESC')
 {
     /** @var $sortFieldDefaultValue string */
     $sortFieldName = $this->config->getString('entity.prettyname', NULL);
     $revisions = $this->connectionRepository->findLatestRevisionsWithFilters($filter, $sortBy, $sortOrder, $sortFieldName);
     $metadataDefinitionHelper = $this->metadataDefinitionHelper;
     $dtos = array();
     $i = 0;
     /** @var Revision $revision */
     while ($revision = array_shift($revisions)) {
         $dtos[] = $revision->toDto($metadataDefinitionHelper);
         // Done this this revision, Entity Manager and PHP in general please forget it now.
         $this->entityManager->detach($revision);
         unset($revision);
         // Every 100 entities clear the entity memory to reduce memory usage for 1100 entities from 270Mb to 100Mb.
         if ($i++ % 100 === 0) {
             $this->clearEntities();
         }
     }
     $this->clearEntities();
     return new ConnectionDtoCollection($dtos);
 }
開發者ID:baszoetekouw,項目名稱:janus,代碼行數:30,代碼來源:ConnectionService.php


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