/** * {@inheritdoc} */ public function normalize($object, $format = null, array $context = []) { if (!$this->serializer instanceof NormalizerInterface) { throw new \RuntimeException(sprintf('Cannot normalize job execution of "%s" because injected serializer is not a normalizer', $object->getLabel())); } return ['label' => $this->labelProvider->getJobLabel($object->getJobInstance()->getJobName()), 'failures' => array_map(function ($exception) { return $this->translator->trans($exception['message'], $exception['messageParameters']); }, $object->getFailureExceptions()), 'stepExecutions' => $this->normalizeStepExecutions($object->getStepExecutions(), $format, $context), 'isRunning' => $object->isRunning(), 'status' => $this->translator->trans(sprintf('pim_import_export.batch_status.%d', $object->getStatus()->getValue()))]; }
/** * Return filter choices for the job column * * @param string $type * * @return array */ protected function getJobChoices($type) { $choices = []; $jobs = $this->registry->allByType($type); foreach ($jobs as $job) { $choices[$job->getName()] = $this->labelProvider->getJobLabel($job->getName()); } asort($choices); return $choices; }
/** * {@inheritdoc} */ public function normalize($object, $format = null, array $context = []) { $normalizedWarnings = $this->normalizeWarnings($object->getWarnings(), $context); if (isset($context['limit_warnings']) && $object->getWarnings()->count() > 0) { $object->addSummaryInfo('displayed', count($normalizedWarnings) . '/' . $object->getWarnings()->count()); } return ['label' => $this->labelProvider->getStepLabel($object->getJobExecution()->getJobInstance()->getJobName(), $object->getStepName()), 'status' => $this->normalizeStatus($object->getStatus()->getValue()), 'summary' => $this->normalizeSummary($object->getSummary()), 'startedAt' => $this->presenter->present($object->getStartTime(), $context), 'endedAt' => $this->presenter->present($object->getEndTime(), $context), 'warnings' => $normalizedWarnings, 'failures' => array_map(function ($failure) { return $this->translator->trans($failure['message'], $failure['messageParameters']); }, $object->getFailureExceptions())]; }
/** * Add job name field * * @param FormBuilderInterface $builder * * @return JobInstanceFormType */ protected function addJobNameField(FormBuilderInterface $builder) { $choices = []; foreach ($this->jobRegistry->allByTypeGroupByConnector($this->jobType) as $connector => $jobs) { foreach ($jobs as $key => $job) { $choices[$connector][$key] = $this->jobLabelProvider->getJobLabel($job->getName()); } } $builder->add('jobName', 'choice', ['choices' => $choices, 'required' => true, 'by_reference' => false, 'mapped' => false, 'empty_value' => $this->translator->trans('pim_import_export.list'), 'empty_data' => null, 'label' => 'Job']); return $this; }