/**
  * {@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);
 }