本文整理汇总了PHP中Akeneo\Bundle\BatchBundle\Entity\StepExecution类的典型用法代码示例。如果您正苦于以下问题:PHP StepExecution类的具体用法?PHP StepExecution怎么用?PHP StepExecution使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了StepExecution类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ArrayCollection
function it_normalizes_a_step_execution(StepExecution $stepExecution, BatchStatus $status, \DateTime $startTime, $translator)
{
$stepExecution->getStepName()->willReturn('export');
$translator->trans('export')->willReturn('Export step');
$stepExecution->getSummary()->willReturn(['read' => 12, 'write' => 50]);
$translator->trans('job_execution.summary.read')->willReturn('Read');
$translator->trans('job_execution.summary.write')->willReturn('Write');
$stepExecution->getStatus()->willReturn($status);
$status->getValue()->willReturn(9);
$translator->trans('pim_import_export.batch_status.9')->willReturn('PENDING');
$stepExecution->getStartTime()->willReturn($startTime);
$stepExecution->getEndTime()->willReturn(null);
$startTime->getTimestamp()->willReturn(1411400461);
$utcStartTime = new \DateTime();
$utcStartTime->setTimestamp(1411400461);
$finalDate = $utcStartTime->format('Y-m-d g:i:s A');
$stepExecution->getWarnings()->willReturn(new ArrayCollection([new Warning($stepExecution->getWrappedObject(), 'a_warning', 'warning_reason', ['foo' => 'bar'], ['a' => 'A', 'b' => 'B', 'c' => 'C'])]));
$translator->trans('a_warning')->willReturn('Reader');
$translator->trans(12)->willReturn(12);
$translator->trans(50)->willReturn(50);
$translator->trans('warning_reason', ['foo' => 'bar'])->willReturn('WARNING!');
$stepExecution->getFailureExceptions()->willReturn([['message' => 'a_failure', 'messageParameters' => ['foo' => 'bar']]]);
$translator->trans('a_failure', ['foo' => 'bar'])->willReturn('FAIL!');
$this->normalize($stepExecution, 'any')->shouldReturn(['label' => 'Export step', 'status' => 'PENDING', 'summary' => ['Read' => 12, 'Write' => 50], 'startedAt' => $finalDate, 'endedAt' => null, 'warnings' => [['label' => 'Reader', 'reason' => 'WARNING!', 'item' => ['a' => 'A', 'b' => 'B', 'c' => 'C']]], 'failures' => ['FAIL!']]);
}
示例2:
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');
}
示例3: getJobContext
/**
* @return ExecutionContext
*/
protected function getJobContext()
{
if (!$this->stepExecution) {
throw new \InvalidArgumentException('Missing StepExecution');
}
return $this->stepExecution->getJobExecution()->getExecutionContext();
}
示例4: updateStepExecution
/**
* {@inheritdoc}
*/
public function updateStepExecution(StepExecution $stepExecution)
{
$jobExecution = $stepExecution->getJobExecution();
if ($jobExecution) {
$this->updateJobExecution($jobExecution);
}
parent::updateStepExecution($stepExecution);
}
示例5:
function it_reads_several_entities_from_a_yml_file_incrementing_summary_info(StepExecution $stepExecution)
{
$this->beConstructedWith(true, false);
$stepExecution->incrementSummaryInfo('read_lines')->shouldBeCalled();
$this->setFilePath(realpath(__DIR__ . '/../../../../../../features/Context/fixtures/fake_products_with_code.yml'));
$this->setStepExecution($stepExecution);
$this->read()->shouldReturn(['mug_akeneo' => ['sku' => 'mug_akeneo'], 't_shirt_akeneo_purple' => ['sku' => 't_shirt_akeneo_purple', 'color' => 'purple'], 'mouse_akeneo' => ['sku' => 'mouse_akeneo']]);
}
示例6:
function it_increments_summary_info(StepExecution $stepExecution, ProductInterface $product1, ProductInterface $product2)
{
$product1->getId()->willReturn('45');
$product2->getId()->willReturn(null);
$stepExecution->incrementSummaryInfo('update')->shouldBeCalled();
$stepExecution->incrementSummaryInfo('create')->shouldBeCalled();
$this->setStepExecution($stepExecution);
$this->write([$product1, $product2]);
}
示例7: getStepExecutionMessages
/**
* Returns the messages for a step execution
*
* @param StepExecution $stepExecution
*
* @return string
*/
protected function getStepExecutionMessages(StepExecution $stepExecution)
{
$message = '';
foreach ($stepExecution->getFailureExceptions() as $exception) {
$message .= $this->getFailureExceptionMessage(sprintf('STEP %s', $stepExecution->getStepName()), $exception);
}
foreach ($stepExecution->getWarnings() as $warning) {
$message .= $this->getWarningMessage($warning);
}
return $message;
}
示例8: InvalidItemException
function it_throws_an_exception_if_an_error_occurs_during_processing($transformer, $validator, $managerRegistry, ProductInterface $product, ColumnInfo $columnInfo, ObjectManager $objectManager, StepExecution $stepExecution)
{
$item = ['sku' => 'AKNTS', 'family' => 'tshirts', 'groups' => 'akeneo_tshirt', 'categories' => 'tshirts,goodies', 'SUBSTITUTION-groups' => '', 'SUBSTITUTION-products' => 'AKNTS_WPS,AKNTS_PBS,AKNTS_PWS', 'description-en_US-mobile' => '<p>Akeneo T-Shirt</p>', 'not_empty_attribute' => ''];
$transformer->transform('Pim\\Component\\Catalog\\Model\\Product', $item, ['enabled' => true])->willReturn($product);
$transformer->getErrors('Pim\\Component\\Catalog\\Model\\Product')->willReturn([]);
$transformer->getTransformedColumnsInfo('Pim\\Component\\Catalog\\Model\\Product')->willReturn([$columnInfo]);
$validator->validate($product, [$columnInfo], $item, [])->willReturn(['AKNTS' => [["The value \"\" for not empty attribute \"not_empty_attribute\" is empty"]]]);
$managerRegistry->getManagerForClass(Argument::type('string'))->willReturn($objectManager);
$stepExecution->incrementSummaryInfo('skip')->shouldBeCalled();
$this->setStepExecution($stepExecution);
$this->shouldThrow(new InvalidItemException('AKNTS: ', $item))->duringProcess($item);
}
示例9: let
function let(NotificationManager $manager, JobExecutionEvent $event, JobExecution $jobExecution, StepExecution $stepExecution, ArrayCollection $warnings, JobInstance $jobInstance, UserInterface $user, BatchStatus $status)
{
$this->beConstructedWith($manager);
$jobExecution->getUser()->willReturn($user);
$jobExecution->getStepExecutions()->willReturn([$stepExecution]);
$jobExecution->getStatus()->willReturn($status);
$jobExecution->getJobInstance()->willReturn($jobInstance);
$stepExecution->getWarnings()->willReturn($warnings);
$jobExecution->getId()->willReturn(5);
$jobInstance->getType()->willReturn('export');
$jobInstance->getLabel()->willReturn('Foo export');
$event->getJobExecution()->willReturn($jobExecution);
}
示例10: 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);
}
示例11: process
public function process($item)
{
$sku = (string) $item['sku'];
$attribute = $this->productManager->getIdentifierAttribute();
$product = $this->productManager->findByIdentifier($sku);
// if (!$product) {
// $product = $this->productManager->createProduct();
// $value = $this->productManager->createProductValue();
// $value->setAttribute($attribute);
// $value->setData($sku);
// $product->addValue($value);
// $this->stepExecution->incrementSummaryInfo('create');
// return $product;
// } else {
if (!$product) {
$data = current((array) $item);
$this->stepExecution->incrementSummaryInfo('skip');
throw new InvalidItemException(sprintf('Skip the existing %s product', $sku), $data);
} else {
$product_tab = array();
$product_tab[] = $product;
$this->productUpdater->setValue($product_tab, 'price', [['data' => (string) $item['price'], 'currency' => (string) $item['currency']]]);
return $product;
}
// }
}
示例12: write
public function write(array $items)
{
foreach ($items as $product) {
$this->productManager->save($product);
$this->stepExecution->incrementSummaryInfo('save');
}
}
示例13: incrementCount
/**
* @param object $item
*/
protected function incrementCount($item)
{
if ($item->getId()) {
$this->stepExecution->incrementSummaryInfo('update');
} else {
$this->stepExecution->incrementSummaryInfo('create');
}
}
示例14: write
public function write(array $items)
{
if (null === $this->file) {
$this->file = new \SplFileObject($this->filePath, "w");
}
foreach ($items as $product) {
$this->file->fputcsv($product);
$this->stepExecution->incrementSummaryInfo('write');
}
}
示例15: incrementCount
/**
* @param array $objects
*/
protected function incrementCount(array $objects)
{
foreach ($objects as $object) {
if ($object->getId()) {
$this->stepExecution->incrementSummaryInfo('process');
} else {
$this->stepExecution->incrementSummaryInfo('create');
}
}
}