本文整理汇总了PHP中Akeneo\Bundle\BatchBundle\Entity\StepExecution::getJobExecution方法的典型用法代码示例。如果您正苦于以下问题:PHP StepExecution::getJobExecution方法的具体用法?PHP StepExecution::getJobExecution怎么用?PHP StepExecution::getJobExecution使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Akeneo\Bundle\BatchBundle\Entity\StepExecution
的用法示例。
在下文中一共展示了StepExecution::getJobExecution方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getJobContext
/**
* @return ExecutionContext
*/
protected function getJobContext()
{
if (!$this->stepExecution) {
throw new \InvalidArgumentException('Missing StepExecution');
}
return $this->stepExecution->getJobExecution()->getExecutionContext();
}
示例2: testProcessWithoutCustomer
public function testProcessWithoutCustomer()
{
/** @var NewsletterSubscriber $newsletterSubscriber */
$newsletterSubscriber = $this->getReference('newsletter_subscriber2');
$newsletterSubscriber->setCustomer(null);
$em = $this->getContainer()->get('doctrine')->getManager();
$em->persist($newsletterSubscriber);
$em->flush($newsletterSubscriber);
$this->strategy->setEntityName(get_class($newsletterSubscriber));
$this->assertEquals($newsletterSubscriber, $this->strategy->process($newsletterSubscriber));
$this->assertEmpty($this->stepExecution->getJobExecution()->getExecutionContext()->get('postProcessSubscribers'));
$this->assertEmpty($this->stepExecution->getJobExecution()->getExecutionContext()->get('postProcessCustomerIds'));
}
示例3:
function it_throws_an_exception_if_no_job_configuration_is_found($jobConfigurationRepo, StepExecution $stepExecution, JobExecution $jobExecution)
{
$stepExecution->getJobExecution()->willReturn($jobExecution);
$jobConfigurationRepo->findOneBy(['jobExecution' => $jobExecution])->willReturn(null);
$this->setStepExecution($stepExecution);
$this->shouldThrow('Doctrine\\ORM\\EntityNotFoundException')->during('read');
}
示例4: getExecutionContext
/**
* @return ExecutionContext
*/
protected function getExecutionContext()
{
if (!$this->stepExecution) {
throw new \InvalidArgumentException('Execution context is not configured');
}
return $this->stepExecution->getJobExecution()->getExecutionContext();
}
示例5: setJobConfiguration
/**
* Save the job configuration
*
* @param string $configuration
*/
protected function setJobConfiguration($configuration)
{
$jobExecution = $this->stepExecution->getJobExecution();
$massEditJobConf = $this->jobConfigurationRepo->findOneBy(['jobExecution' => $jobExecution]);
$massEditJobConf->setConfiguration($configuration);
$this->jobConfigurationSaver->save($massEditJobConf);
}
示例6: removeOption
/**
* {@inheritdoc}
*/
public function removeOption($name)
{
if ($this->hasOption($name)) {
$configuration = $this->getConfiguration();
unset($configuration[$name]);
$this->stepExecution->getJobExecution()->getJobInstance()->setRawConfiguration($configuration);
}
}
示例7: setJobConfiguration
/**
* Save the job configuration
*
* @param string $configuration
*/
protected function setJobConfiguration($configuration)
{
$jobExecution = $this->stepExecution->getJobExecution();
$massEditJobConf = $this->jobConfigurationRepo->findOneBy(['jobExecution' => $jobExecution]);
$massEditJobConf->setConfiguration($configuration);
$this->objectManager->persist($massEditJobConf);
$this->objectManager->flush($massEditJobConf);
}
示例8: updateStepExecution
/**
* {@inheritdoc}
*/
public function updateStepExecution(StepExecution $stepExecution)
{
$jobExecution = $stepExecution->getJobExecution();
if ($jobExecution) {
$this->updateJobExecution($jobExecution);
}
parent::updateStepExecution($stepExecution);
}
示例9: getJobConfiguration
/**
* Return the job configuration
*
* @throws EntityNotFoundException
*
* @return array
*/
protected function getJobConfiguration()
{
$jobExecution = $this->stepExecution->getJobExecution();
$massEditJobConf = $this->jobConfigurationRepo->findOneBy(['jobExecution' => $jobExecution]);
if (null === $massEditJobConf) {
throw new EntityNotFoundException(sprintf('No JobConfiguration found for jobExecution with id %s', $jobExecution->getId()));
}
return json_decode(stripcslashes($massEditJobConf->getConfiguration()), true);
}
示例10: write
/**
* {@inheritdoc}
*/
public function write(array $items)
{
/** @var EntityManager $em */
$em = $this->registry->getManager();
try {
$em->beginTransaction();
foreach ($items as $item) {
$em->persist($item);
}
$em->flush();
$em->commit();
$configuration = $this->contextRegistry->getByStepExecution($this->stepExecution)->getConfiguration();
$contextSkipClear = $this->stepExecution->getJobExecution()->getExecutionContext()->get(EntityWriter::SKIP_CLEAR);
if (empty($configuration[EntityWriter::SKIP_CLEAR]) && !$contextSkipClear) {
$em->clear();
}
} catch (\Exception $exception) {
$em->rollback();
if (!$em->isOpen()) {
$this->registry->resetManager();
}
$jobName = $this->stepExecution->getJobExecution()->getJobInstance()->getAlias();
$event = new WriterErrorEvent($items, $jobName, $exception);
$this->eventDispatcher->dispatch(WriterErrorEvent::NAME, $event);
if ($event->getCouldBeSkipped()) {
$importContext = $this->contextRegistry->getByStepExecution($this->stepExecution);
$importContext->setValue('error_entries_count', (int) $importContext->getValue('error_entries_count') + count($items));
$this->logger->warning($event->getWarning());
if ($event->getException() === $exception) {
// exception are already handled and job can move forward
throw new InvalidItemException($event->getWarning(), []);
} else {
// exception are already created and ready to be rethrown
throw $event->getException();
}
} else {
throw $exception;
}
}
$this->eventDispatcher->dispatch(WriterAfterFlushEvent::NAME, new WriterAfterFlushEvent($em));
}
示例11: getLastExecutionDate
/**
* Get the last successful execution date for the current job instance
*
* @return \DateTime||null
*/
protected function getLastExecutionDate()
{
$query = $this->entityManager->createQuery(sprintf("SELECT MAX(e.endTime) FROM %s e WHERE e.jobInstance = :jobInstance AND e.exitCode = :completed", $this->jobExecutionClass));
$query->setParameter('jobInstance', $this->stepExecution->getJobExecution()->getJobInstance());
$query->setParameter('completed', ExitStatus::COMPLETED);
$utcDateTime = $query->getOneOrNullResult();
if (is_array($utcDateTime)) {
$utcTimeZone = new \DateTimeZone('Etc/UTC');
$utcDateTime = new \DateTime(reset($utcDateTime), $utcTimeZone);
}
$dateTime = new \DateTime();
$dateTime->setTimestamp($utcDateTime->getTimestamp());
return $dateTime;
}
示例12: ConstraintViolation
function it_adds_invalid_values_to_product($propertyAdder, $validator, ProductInterface $product, StepExecution $stepExecution, JobConfigurationRepositoryInterface $jobConfigurationRepo, JobExecution $jobExecution, JobConfigurationInterface $jobConfiguration)
{
$violation = new ConstraintViolation('error2', 'spec', [], '', '', $product);
$violations = new ConstraintViolationList([$violation, $violation]);
$validator->validate($product)->willReturn($violations);
$stepExecution->getJobExecution()->willReturn($jobExecution);
$jobConfigurationRepo->findOneBy(['jobExecution' => $jobExecution])->willReturn($jobConfiguration);
$jobConfiguration->getConfiguration()->willReturn(json_encode(['filters' => [], 'actions' => [['field' => 'categories', 'value' => ['office', 'bedroom']]]]));
$propertyAdder->addData($product, 'categories', ['office', 'bedroom'])->shouldBeCalled();
$stepExecution->addWarning(Argument::cetera())->shouldBeCalled();
$stepExecution->incrementSummaryInfo('skipped_products')->shouldBeCalled();
$this->setStepExecution($stepExecution);
$this->process($product);
}
示例13: ArrayCollection
function it_reads_products($entityManager, $jobRepository, JobConfigurationRepositoryInterface $jobConfigurationRepo, JobInstance $jobInstance, JobExecution $jobExecution, JobConfigurationInterface $jobConfiguration, ProductQueryBuilderFactory $pqbFactory, ProductQueryBuilder $pqb, StepExecution $stepExecution, Cursor $cursor, ProductInterface $product, EntityRepository $customEntityRepository)
{
$jobRepository->getJobManager()->willReturn($entityManager);
$stepExecution->getJobExecution()->willReturn($jobExecution);
$customEntityRepository->findOneBy(['code' => 'update_product_value'])->willReturn($jobInstance);
$jobInstance->getJobExecutions()->willReturn(new ArrayCollection([$jobExecution]));
$jobConfigurationRepo->findOneBy(['jobExecution' => $jobExecution])->willReturn($jobConfiguration);
$pqbFactory->create()->willReturn($pqb);
$jobConfiguration->getConfiguration()->willReturn(json_encode(['filters' => [], 'actions' => []]));
$pqb->execute()->willReturn($cursor);
$cursor->next()->shouldBeCalled();
$stepExecution->incrementSummaryInfo('read')->shouldBeCalledTimes(1);
$this->setStepExecution($stepExecution);
$cursor->current()->willReturn($product);
$this->read()->shouldReturn($product);
}
示例14: ConstraintViolation
function it_adds_invalid_values_to_product($groupRepository, $validator, $templateUpdater, GroupInterface $variantGroup, ProductInterface $product, StepExecution $stepExecution, JobConfigurationRepositoryInterface $jobConfigurationRepo, JobExecution $jobExecution, JobConfigurationInterface $jobConfiguration, ProductTemplateInterface $productTemplate)
{
$violation = new ConstraintViolation('error2', 'spec', [], '', '', $product);
$violations = new ConstraintViolationList([$violation, $violation]);
$validator->validate($product)->willReturn($violations);
$stepExecution->getJobExecution()->willReturn($jobExecution);
$jobConfigurationRepo->findOneBy(['jobExecution' => $jobExecution])->willReturn($jobConfiguration);
$jobConfiguration->getConfiguration()->willReturn(json_encode(['filters' => [], 'actions' => ['field' => 'variant_group', 'value' => 'variant_group_code']]));
$groupRepository->findOneByIdentifier('variant_group_code')->willReturn($variantGroup);
$product->getVariantGroup()->willReturn(null);
$variantGroup->addProduct($product)->shouldBeCalled();
$variantGroup->getProductTemplate()->willReturn($productTemplate);
$templateUpdater->update($variantGroup->getProductTemplate(), [$product]);
$stepExecution->addWarning(Argument::cetera())->shouldBeCalled();
$stepExecution->incrementSummaryInfo('skipped_products')->shouldBeCalled();
$this->setStepExecution($stepExecution);
$this->process($product);
}
示例15: ConstraintViolation
function it_sets_invalid_values_to_attributes($validator, $propertySetter, FamilyInterface $family, AttributeInterface $attribute, AttributeRepository $attributeRepository, ProductInterface $product, ConstraintViolationListInterface $violations, StepExecution $stepExecution, JobConfigurationRepositoryInterface $jobConfigurationRepo, JobExecution $jobExecution, JobConfigurationInterface $jobConfiguration)
{
$stepExecution->getJobExecution()->willReturn($jobExecution);
$jobConfigurationRepo->findOneBy(['jobExecution' => $jobExecution])->willReturn($jobConfiguration);
$jobConfiguration->getConfiguration()->willReturn(json_encode(['filters' => [], 'actions' => [['field' => 'categories', 'value' => ['office', 'bedroom'], 'options' => []]]]));
$validator->validate($product)->willReturn($violations);
$violation = new ConstraintViolation('error2', 'spec', [], '', '', $product);
$violations = new ConstraintViolationList([$violation, $violation]);
$validator->validate($product)->willReturn($violations);
$attributeRepository->findOneBy(['code' => 'categories'])->willReturn($attribute);
$family->hasAttribute($attribute)->willReturn(true);
$product->getFamily()->willReturn($family);
$propertySetter->setData($product, 'categories', ['office', 'bedroom'], [])->shouldBeCalled();
$this->setStepExecution($stepExecution);
$stepExecution->addWarning(Argument::cetera())->shouldBeCalled();
$stepExecution->incrementSummaryInfo('skipped_products')->shouldBeCalled();
$this->process($product);
}