示例#1
0
 /**
  * To rename a file from the importr you
  * have to use the "rename: 1" statement in
  * your configuration. The file will be
  * prefixed with the current (human readable)
  * timestamp.
  *
  * Caution: after this method, the file is moved
  * you should only use this in the before
  * configuration if you are fully aware of it!
  *
  * @param  ManagerInterface $manager
  * @param  Import           $import
  * @return void
  */
 public function execute(ManagerInterface $manager, Import $import)
 {
     $configuration = $import->getStrategy()->getConfiguration();
     if (isset($configuration['after']['rename'])) {
         $oldFileName = $this->fileService->getFileAbsFileName($import->getFilepath());
         $info = pathinfo($oldFileName);
         $newFileName = $info['dirname'] . DIRECTORY_SEPARATOR . date('YmdHis') . '_' . $info['basename'];
         rename($oldFileName, $newFileName);
     }
 }
示例#2
0
 /**
  * @param \HDNET\Importr\Domain\Model\Import $import
  *
  * @return array
  */
 protected function initializeTargets(Import $import)
 {
     $targets = [];
     $targetConfiguration = $import->getStrategy()->getTargets();
     foreach ($targetConfiguration as $target => $configuration) {
         $object = $this->objectManager->get($target);
         $object->setConfiguration($configuration);
         $object->getConfiguration();
         $object->start($import->getStrategy());
         $targets[$target] = $object;
     }
     return $targets;
 }