本文整理汇总了PHP中Doctrine\Bundle\DoctrineBundle\Registry::flush方法的典型用法代码示例。如果您正苦于以下问题:PHP Registry::flush方法的具体用法?PHP Registry::flush怎么用?PHP Registry::flush使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\Bundle\DoctrineBundle\Registry
的用法示例。
在下文中一共展示了Registry::flush方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handle
/**
* @param RemoveDojoCommand $command
*/
public function handle(RemoveDojoCommand $command)
{
$dojo = $this->doctrine->getRepository('CoderDojoWebsiteBundle:Dojo')->find($command->getId());
$this->doctrine->remove($dojo);
$this->doctrine->flush();
$event = new DojoRemovedEvent($command->getId());
$this->eventRecorder->record($event);
}
示例2: run
public function run(OutputInterface $output)
{
$output->writeln('**********************************');
$output->writeln('Starting sync for dojos');
$this->progressBar = $this->newProgressBar($output);
$externalDojos = $this->zen->getDojos();
$this->progressBar->start(count($externalDojos));
$this->progressBar->setMessage('Iterating dojos...');
foreach ($externalDojos as $externalDojo) {
$this->progressBar->setMessage('Handling ' . $externalDojo->getName());
if (true === $externalDojo->isRemoved()) {
$this->removeInternalDojo($externalDojo);
continue;
}
try {
$internalDojo = $this->getInternalDojo($externalDojo->getZenId(), $externalDojo->getCity(), $externalDojo->getTwitter(), $externalDojo->getEmail());
} catch (NonUniqueResultException $exception) {
$this->unmatched[] = $externalDojo;
continue;
}
if (null !== $internalDojo) {
$this->updateInternalDojo($internalDojo, $externalDojo);
continue;
}
$this->createDojo($externalDojo);
}
$this->progressBar->setMessage('Flushing');
$this->doctrine->flush();
$this->progressBar->setMessage('Finished syncing dojos!');
$this->progressBar->finish();
$output->writeln($this->countNew . ' New dojos added');
$output->writeln($this->countUpdated . ' Existing dojos updated');
$output->writeln($this->countRemoved . ' Existing dojos removed');
$this->notifySlack();
}
示例3: handle
/**
* @param CreateEventCommand $command
*/
public function handle(CreateEventCommand $command)
{
$dojo = $this->doctrine->getRepository('CoderDojoWebsiteBundle:Dojo')->find($command->getDojoId());
$event = new DojoEvent();
$event->setName($command->getName());
$event->setDate($command->getDate());
$event->setType($command->getType());
$event->setZenId($command->getZenId());
$event->setUrl($command->getUrl());
$event->setDojo($dojo);
$dojo->addEvent($event);
$this->doctrine->persist($event);
$this->doctrine->flush();
$event = new EventCreatedEvent($command->getDojoId(), $command->getName(), $command->getDate(), $command->getUrl(), $command->getZenId(), $command->getType());
$this->eventRecorder->record($event);
}
示例4: execute
/**
* Execute the command. Get all the deposits needing to be harvested. Each
* deposit will be passed to the commands processDeposit() function.
*
* @param InputInterface $input
* @param OutputInterface $output
*/
protected final function execute(InputInterface $input, OutputInterface $output)
{
$this->preExecute();
$deposits = $this->getDeposits($input->getOption('retry'), $input->getArgument('deposit-id'));
if ($input->hasOption('limit')) {
$deposits = array_slice($deposits, 0, $input->getOption('limit'));
}
$count = count($deposits);
$this->logger->info("Processing {$count} deposits.");
$this->preprocessDeposits($deposits);
foreach ($deposits as $deposit) {
try {
$result = $this->processDeposit($deposit);
} catch (Exception $e) {
$this->logger->error($e->getMessage());
$deposit->setState($this->errorState());
$deposit->addToProcessingLog($this->failureLogMessage());
$deposit->addErrorLog(get_class($e) . $e->getMessage());
$this->em->flush($deposit);
continue;
}
if ($input->getOption('dry-run')) {
continue;
}
if ($result) {
$deposit->setState($this->nextState());
$deposit->addToProcessingLog($this->successLogMessage());
} else {
$deposit->setState($this->errorState());
$deposit->addToProcessingLog($this->failureLogMessage());
}
$this->em->flush($deposit);
}
}
示例5: onSuccess
/**
* "Success" form handler
*
* @param OrderItem $entity
*/
protected function onSuccess(OrderItem $entity)
{
$this->manager->persist($entity);
$this->manager->flush();
}
示例6: run
public function run(OutputInterface $output)
{
$output->writeln('**********************************');
$output->writeln('Starting sync for Events');
$progressbar = $this->newProgressBar($output);
$zenIds = $this->doctrine->getRepository('CoderDojoWebsiteBundle:Dojo')->getZenIds();
$externalEvents = $this->zen->getEvents($zenIds);
$progressbar->start(count($externalEvents));
$progressbar->setMessage('Iterating Events...');
$countNew = 0;
$countUpdated = 0;
$countNoMatch = 0;
foreach ($externalEvents as $externalEvent) {
$progressbar->setMessage('Handling ' . $externalEvent->getName());
$internalEvent = $this->doctrine->getRepository('CoderDojoWebsiteBundle:DojoEvent')->findOneBy(['zenId' => $externalEvent->getZenId()]);
/** @var Dojo $dojo */
$internalDojo = $this->doctrine->getRepository('CoderDojoWebsiteBundle:Dojo')->findOneBy(['zenId' => $externalEvent->getZenDojoId()]);
if (null === $internalDojo) {
$progressbar->setMessage('No internal dojo found!');
$progressbar->advance();
$countNoMatch++;
continue;
}
if (null === $internalEvent) {
$progressbar->setMessage('No internal event found');
$command = new CreateEventCommand($internalDojo->getId(), $externalEvent->getName(), $externalEvent->getStartTime(), $internalDojo->getZenUrl(), $externalEvent->getZenId(), DojoEvent::TYPE_ZEN);
$this->commandBus->handle($command);
$progressbar->advance();
$countNew++;
} else {
$progressbar->setMessage('Internal event found');
$internalEvent->setName($externalEvent->getName());
$internalEvent->setDate($externalEvent->getStartTime());
$internalEvent->setUrl($internalDojo->getZenUrl());
$progressbar->advance();
$countUpdated++;
}
}
$progressbar->setMessage('Flushing');
$this->doctrine->flush();
$progressbar->setMessage('Finished syncing Events!');
$progressbar->finish();
$output->writeln($countNew . ' New events added');
$output->writeln($countUpdated . ' Existing events updated');
$output->writeln($countNoMatch . ' events could not be matched with a dojo');
$message = "Zen synchronizer just handled events.";
$attachments = [];
$attachment = new Attachment();
$attachment->setFallback($countNew . " events added.");
$attachment->setText($countNew . " events added.");
$attachment->setColor('good');
$attachments[] = $attachment;
$attachment = new Attachment();
$attachment->setFallback($countUpdated . " events updated.");
$attachment->setText($countUpdated . " events updated.");
$attachment->setColor('warning');
$attachments[] = $attachment;
$attachment = new Attachment();
$attachment->setFallback($countNoMatch . " events not matched.");
$attachment->setText($countNoMatch . " events not matched.");
$attachment->setColor('danger');
$attachments[] = $attachment;
$this->slackService->sendToChannel('#website-nl', $message, $attachments);
}