Example #1
0
 /**
  * {@inheritdoc}
  */
 public function write(array $items)
 {
     $exportDirectory = dirname($this->getPath());
     if (!is_dir($exportDirectory)) {
         $this->localFs->mkdir($exportDirectory);
     }
     $flatItems = [];
     foreach ($items as $item) {
         $flatItems[] = $this->arrayConverter->convert($item);
     }
     $parameters = $this->stepExecution->getJobParameters();
     $options = [];
     $options['withHeader'] = $parameters->get('withHeader');
     $this->flatRowBuffer->write($flatItems, $options);
 }
 /**
  * {@inheritdoc}
  */
 public function write(array $items)
 {
     $parameters = $this->stepExecution->getJobParameters();
     $converterOptions = $this->getConverterOptions($parameters);
     $flatItems = [];
     $directory = $this->stepExecution->getJobExecution()->getExecutionContext()->get(JobInterface::WORKING_DIRECTORY_PARAMETER);
     foreach ($items as $item) {
         if ($parameters->has('with_media') && $parameters->get('with_media')) {
             $item = $this->resolveMediaPaths($item, $directory);
         }
         $flatItems[] = $this->arrayConverter->convert($item, $converterOptions);
     }
     $options = [];
     $options['withHeader'] = $parameters->get('withHeader');
     $this->flatRowBuffer->write($flatItems, $options);
 }
 /**
  * @param FlatItemBuffer $buffer
  * @param int            $maxLinesPerFile
  *
  * @return bool
  */
 protected function areSeveralFilesNeeded(FlatItemBuffer $buffer, $maxLinesPerFile)
 {
     if (-1 === $maxLinesPerFile) {
         return false;
     }
     return $buffer->count() > $maxLinesPerFile;
 }
 function it_throws_an_exception_if_type_is_not_recognized($columnSorter, FlatItemBuffer $buffer, StepExecution $stepExecution, JobParameters $parameters)
 {
     $columnSorter->sort(Argument::any(), [])->willReturn(['colA', 'colB']);
     $stepExecution->getJobParameters()->willReturn($parameters);
     $parameters->all()->willReturn([]);
     $buffer->getHeaders()->willReturn(['colA', 'colB']);
     $this->shouldThrow('Box\\Spout\\Common\\Exception\\UnsupportedTypeException')->during('flush', [$buffer, ['type' => 'undefined'], Argument::any()]);
 }