Ejemplo n.º 1
0
 /**
  * run the Importr
  */
 public function runImports()
 {
     try {
         $imports = $this->importRepository->findWorkQueue();
         foreach ($imports as $import) {
             $this->runImport($import);
         }
     } catch (ReinitializeException $exc) {
         $this->runImports();
     }
 }
Ejemplo n.º 2
0
 /**
  * @return void
  */
 public function indexAction()
 {
     $combinedIdentifier = GeneralUtility::_GP('id');
     if (isset($combinedIdentifier) && is_string($combinedIdentifier)) {
         $folder = $this->resourceFactory->getFolderObjectFromCombinedIdentifier($combinedIdentifier);
         $files = [];
         foreach ($folder->getFiles() as $file) {
             $files[$file->getStorage()->getUid() . ':' . $file->getIdentifier()] = $file->getName();
         }
         $this->view->assign('folder', $files);
     }
     $this->view->assign('imports', $this->importRepository->findUserQueue());
 }
Ejemplo n.º 3
0
 /**
  * @test
  */
 public function is_import_added_to_queue()
 {
     $import = $this->getMock(Import::class);
     $strategy = $this->getMock(Strategy::class);
     $path = './import.csv';
     $time = '2016-06-19T13:49:39+00:00';
     $import->expects($this->once())->method('setStrategy')->with($strategy);
     $import->expects($this->once())->method('setFilepath')->with($path);
     $import->expects($this->once())->method('setStarttime')->with($this->callback(function ($date) use($time) {
         return $date->format(\DateTime::ATOM) === $time;
     }));
     $this->objectManager->expects($this->once())->method('get')->with(Import::class)->will($this->returnCallback(function () use($import) {
         return $import;
     }));
     $this->repository->expects($this->once())->method('add')->with($this->isInstanceOf(Import::class));
     $this->fixture->addToQueue($path, $strategy, ['start' => $time]);
 }
Ejemplo n.º 4
0
 /**
  * @param string                               $filepath
  * @param \HDNET\Importr\Domain\Model\Strategy $strategy
  * @param array                                $configuration
  */
 public function addToQueue($filepath, Strategy $strategy, array $configuration = [])
 {
     $import = $this->objectManager->get(Import::class);
     $start = 'now';
     if (isset($configuration['start'])) {
         $start = $configuration['start'];
     }
     try {
         $startTime = new \DateTime($start);
     } catch (\Exception $e) {
         $startTime = new \DateTime();
     }
     $import->setStarttime($startTime);
     $import->setFilepath($filepath);
     $import->setStrategy($strategy);
     $this->importRepository->add($import);
     $this->persistenceManager->persistAll();
 }