本文整理汇总了PHP中Symfony\Bridge\Doctrine\ManagerRegistry::resetManager方法的典型用法代码示例。如果您正苦于以下问题:PHP ManagerRegistry::resetManager方法的具体用法?PHP ManagerRegistry::resetManager怎么用?PHP ManagerRegistry::resetManager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Bridge\Doctrine\ManagerRegistry
的用法示例。
在下文中一共展示了ManagerRegistry::resetManager方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: executeJob
/**
* @param string $jobType
* @param string $jobName
* @param array $configuration
* @return JobResult
*/
public function executeJob($jobType, $jobName, array $configuration = array())
{
// create and persist job instance and job execution
$jobInstance = new JobInstance(self::CONNECTOR_NAME, $jobType, $jobName);
$jobInstance->setCode($this->generateJobCode($jobName));
$jobInstance->setLabel(sprintf('%s.%s', $jobType, $jobName));
$jobInstance->setRawConfiguration($configuration);
$jobExecution = new JobExecution();
$jobExecution->setJobInstance($jobInstance);
// persist batch entities
$this->batchJobManager->persist($jobInstance);
$this->batchJobManager->persist($jobExecution);
// do job
$jobResult = $this->doJob($jobInstance, $jobExecution);
// EntityManager can be closed when there was an exception in flush method called inside some jobs execution
// Can't be implemented right now due to OroEntityManager external dependencies
// on ExtendManager and FilterCollection
if (!$this->entityManager->isOpen()) {
$this->managerRegistry->resetManager();
$this->entityManager = $this->managerRegistry->getManager();
}
// flush batch entities
$this->batchJobManager->flush($jobInstance);
$this->batchJobManager->flush($jobExecution);
// set data to JobResult
$jobResult->setJobId($jobInstance->getId());
$jobResult->setJobCode($jobInstance->getCode());
// TODO: Find a way to work with multiple amount of job and step executions
// TODO: https://magecore.atlassian.net/browse/BAP-2600
/** @var JobExecution $jobExecution */
$jobExecution = $jobInstance->getJobExecutions()->first();
if ($jobExecution) {
$stepExecution = $jobExecution->getStepExecutions()->first();
if ($stepExecution) {
$context = $this->contextRegistry->getByStepExecution($stepExecution);
$jobResult->setContext($context);
}
}
return $jobResult;
}