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; }
/** * @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); } }
/** * @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]); } }
/** * Resets the last stored entity. * * @codeCoverageIgnore */ private function resetCacheEntity() { if (null !== $this->_entity) { $this->_em->detach($this->_entity); $this->_entity = null; } }
/** * @param Entity $entity * * @return $this */ protected function handleCannibalisticEntity(Entity $entity) { if ($this->metadata->isCannibal()) { $this->manager->flush($entity); $this->manager->detach($entity); } return $this; }
/** * @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; }
/** * @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 = []; }
/** * 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); } }
/** * 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; }
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); }
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' => '*****@*****.**'); $users = $this->em->getRepository('AppBundle:User')->searchUsers($criteria); $this->assertCount(1, $users); $this->assertEquals('*****@*****.**', $users[0]->getEmail()); }
/** * クエリビルダにもとづいてデータ行を出力する. * このメソッドを使う場合は, 事前に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(); }
/** * 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; }
/** * 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; }
/** * 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); }
/** * importFile * * @param array $currentNode * @param integer $depth * @param mixed $file */ public function importFile($currentNode, $depth, $file) { $document = new Document($currentNode[$depth]); $document->setName($file->getBaseName())->setOriginalName($file->getBaseName())->setFilename($file->getBaseName()); if (isset($this->options['document_callback']) && is_callable($this->options['document_callback'])) { call_user_func_array($this->options['document_callback'], array($document)); } $this->emn->persist($document); $this->emn->flush(); $document->setFilename($document->getComputedFilename()); $destFile = $this->options['storage_path'] . '/' . $document->getFilename(); if (!is_dir(dirname($destFile))) { mkdir(dirname($destFile), 0755, true); } if ($this->options['copy']) { copy($file->getRealPath(), $destFile); } else { rename($file->getRealPath(), $destFile); } $this->emn->persist($document); $this->emn->flush(); $this->emn->detach($document); }
/** * For cloning purpose * * @param ContentInterface|\Opifer\EavBundle\Model\ValueSetInterface|\Opifer\EavBundle\Entity\Value $entity */ private function detachAndPersist($entity) { $this->em->detach($entity); $this->em->persist($entity); }
/** * {@inheritdoc} */ public function detach($entity) { if ($logger = $this->getProfilingLogger()) { $logger->startDetach(); parent::detach($entity); $logger->stopDetach(); } else { parent::detach($entity); } }
/** * Detaches an entity from the EntityManager, causing a managed entity to * become detached. Unflushed changes made to the entity if any * (including removal of the entity), will not be synchronized to the database. * * Entities which previously referenced the detached entity will continue to * reference it. * * @param object $entity The entity to detach. * @return void * @throws ORMInvalidArgumentException * @static */ public static function detach($entity) { \Doctrine\ORM\EntityManager::detach($entity); }
public function detach($entity) { // add to detached if (!$this->detached->contains($entity)) { $this->detached->add($entity); } // remove from all if ($this->persisted->contains($entity)) { $this->persisted->removeElement($entity); } if ($this->removed->contains($entity)) { $this->removed->removeElement($entity); } if ($this->delegate) { return parent::detach($entity); } }
/** * {@inheritdoc} */ public function reload($entity) { $this->entityManager->detach($entity); return $this->entityManager->getRepository(get_class($entity))->find($entity); }
/** * {@inheritdoc} */ public function detach($object) { $this->em->detach($object); }
/** * Detach a user from the entity manager. * * @param UserModel $user */ public function detach(UserModel $user) { $this->em->detach($user); }
/** * {@inheritdoc} */ public function detach($entity) { return $this->wrapped->detach($entity); }