/**
  * {@inheritdoc}
  */
 protected function getInputFileIterator(JobParameters $jobParameters)
 {
     $filePath = $jobParameters->get('filePath');
     $fileIterator = $this->fileIteratorFactory->create($filePath);
     $fileIterator->rewind();
     return $fileIterator;
 }
 function it_validates_a_job_parameters($validator, $registry, ConstraintCollectionProviderInterface $provider, JobInterface $job, JobParameters $jobParameters)
 {
     $registry->get($job)->willReturn($provider);
     $provider->getConstraintCollection()->willReturn(['fields' => 'my constraints']);
     $jobParameters->all()->willReturn(['my params']);
     $validator->validate(['my params'], ['fields' => 'my constraints'], ['MyValidationGroup', 'Default'])->shouldBeCalled();
     $this->validate($job, $jobParameters, ['MyValidationGroup', 'Default']);
 }
 /**
  * @param JobInterface  $job
  * @param JobParameters $jobParameters
  * @param array         $groups
  *
  * @return ConstraintViolationListInterface A list of constraint violations. If the
  *                                          list is empty, validation succeeded.
  */
 public function validate(JobInterface $job, JobParameters $jobParameters, $groups = null)
 {
     $provider = $this->registry->get($job);
     $collection = $provider->getConstraintCollection();
     $parameters = $jobParameters->all();
     $errors = $this->validator->validate($parameters, $collection, $groups);
     return $errors;
 }
 /**
  * Get the input file iterator to iterate on all the lines of the file.
  *
  * @param JobParameters $jobParameters
  *
  * @return FileIteratorInterface
  */
 protected function getInputFileIterator(JobParameters $jobParameters)
 {
     $filePath = $jobParameters->get('filePath');
     $delimiter = $jobParameters->get('delimiter');
     $enclosure = $jobParameters->get('enclosure');
     $fileIterator = $this->fileIteratorFactory->create($filePath, ['reader_options' => ['fieldDelimiter' => $delimiter, 'fieldEnclosure' => $enclosure]]);
     $fileIterator->rewind();
     return $fileIterator;
 }
 /**
  * @param JobParameters $parameters
  *
  * @return array
  */
 protected function getConverterOptions(JobParameters $parameters)
 {
     $options = [];
     if ($parameters->has('decimalSeparator')) {
         $options['decimal_separator'] = $parameters->get('decimalSeparator');
     }
     if ($parameters->has('dateFormat')) {
         $options['date_format'] = $parameters->get('dateFormat');
     }
     if ($parameters->has('ui_locale')) {
         $options['locale'] = $parameters->get('ui_locale');
     }
     return $options;
 }
 /**
  * Are there attributes to filters ?
  *
  * @param JobParameters $parameters
  *
  * @return bool
  */
 protected function areAttributesToFilter(JobParameters $parameters)
 {
     return isset($parameters->get('filters')['structure']['attributes']) && !empty($parameters->get('filters')['structure']['attributes']);
 }
 /**
  * @param JobParameters $parameters
  *
  * @throws \InvalidArgumentException
  *
  * @return array
  */
 protected function getNormalizerContext(JobParameters $parameters)
 {
     if (!$parameters->has('scope')) {
         throw new \InvalidArgumentException('No channel found');
     }
     $normalizerContext = ['channels' => [$parameters->get('scope')], 'locales' => $this->getLocaleCodes($parameters->get('scope')), 'filter_types' => ['pim.transform.product_value.structured', 'pim.transform.product_value.structured.quick_export']];
     return $normalizerContext;
 }