/**
  * {@inheritdoc}
  */
 public function archive(JobExecution $jobExecution)
 {
     if (!$this->collector->getInvalidItems()) {
         return;
     }
     $key = strtr($this->getRelativeArchivePath($jobExecution), array('%filename%' => 'invalid_items.csv'));
     $this->filesystem->put($key, '');
     $this->writer->setFilePath($this->filesystem->getAdapter()->getPathPrefix() . $key);
     $this->writer->initialize();
     $this->writer->write($this->collector->getInvalidItems());
     $this->writer->flush();
 }
 /**
  * {@inheritdoc}
  */
 public function archive(JobExecution $jobExecution)
 {
     if (!$this->collector->getInvalidItems()) {
         return;
     }
     $key = strtr($this->getRelativeArchivePath($jobExecution), array('%filename%' => 'invalid_items.csv'));
     $this->filesystem->write($key, '', true);
     $this->writer->setFilePath(sprintf('%s/%s', $this->archiveDir, $key));
     $this->writer->initialize();
     $this->writer->write($this->collector->getInvalidItems());
     $this->writer->flush();
 }
 function it_archives_unvalid_items(InvalidItemsCollector $collector, CsvWriter $writer, JobExecution $jobExecution, JobInstance $jobInstance, Filesystem $filesystem)
 {
     $collector->getInvalidItems()->willReturn(['items']);
     $jobExecution->getId()->willReturn('id');
     $jobExecution->getJobInstance()->willReturn($jobInstance);
     $jobInstance->getType()->willReturn('type');
     $jobInstance->getAlias()->willReturn('alias');
     $filesystem->put('type/alias/id/invalid/invalid_items.csv', '')->shouldBeCalled();
     $writer->setFilePath('/tmp/archivist/type/alias/id/invalid/invalid_items.csv')->shouldBeCalled();
     $writer->initialize()->shouldBeCalled();
     $writer->write(['items'])->shouldBeCalled();
     $writer->flush()->shouldBeCalled();
     $this->archive($jobExecution);
 }
 /**
  * {@inheritdoc}
  */
 public function getPath()
 {
     if (null === $this->resolvedFilePath) {
         $this->resolvedFilePath = parent::getPath();
         foreach ($this->context as $key => $value) {
             $this->resolvedFilePath = strtr($this->resolvedFilePath, ['%' . $key . '%' => $value]);
         }
     }
     return $this->resolvedFilePath;
 }
 /**
  * @param FileExporterInterface $fileExporter
  */
 public function __construct(FileExporterInterface $fileExporter)
 {
     parent::__construct();
     $this->fileExporter = $fileExporter;
 }