Exemplo n.º 1
0
 /**
  * @param $sourceDir
  * @param $targetDir
  * @param $isDryRun
  * @return Observable\ConnectableObservable
  */
 public function execute($sourceDir, $targetDir, $isDryRun)
 {
     $files = Observable::fromIterator($this->filesystem->ls($sourceDir));
     $filesWithDate = $this->fileWithDateRepository->extractDateFrom($files)->publish();
     $symlinkCommands = $this->symlinkCommandRepository->createSymlinkCommands($filesWithDate, new Path($targetDir));
     $summary = $this->summaryRepository->summarize($filesWithDate);
     $symlinkCommands->merge($summary)->subscribe($this->output);
     if (!$isDryRun) {
         $symlinkCommands->subscribeCallback(function (SymlinkCommand $cmd) {
             $this->output->onNext("write file");
             $this->linkRepository->createLink($cmd->getSource(), $cmd->getTarget());
         });
     }
     $filesWithDate->connect();
 }