本文整理匯總了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;
}