Exemplo n.º 1
0
 /**
  * Get configured outputs.
  *
  * @param InputInterface $consoleInput
  * @param $config
  * @param $inputName
  *
  * @return mixed
  *
  * @throws \Exception
  */
 protected function getOutputNames(InputInterface $consoleInput, ConfigContract $config, $inputName)
 {
     if ($consoleInput->hasArgument('output') && !empty($consoleInput->getArgument('output'))) {
         return [$consoleInput->getArgument('output')];
     }
     if (isset($config->getInput($inputName)['to']) && is_string($config->getInput($inputName)['to'])) {
         return [$config->getInput($inputName)['to']];
     }
     if (isset($config->getInput($inputName)['to']) && is_array($config->getInput($inputName)['to'])) {
         return $config->getInput($inputName)['to'];
     }
     throw new \Exception('No Output specified and configured.');
 }
Exemplo n.º 2
0
 /**
  * @param $config
  * @param $inputName
  * @param $cron
  */
 protected function assertJob(ConfigContract $config, $inputName, CronContract $cron)
 {
     $cronExpression = $config->getInput($inputName)['cron'];
     if (!$cron->has($inputName) || $cron->get($inputName)->getCronExpression() != $cronExpression) {
         $cron->add(new BackupJob($inputName, $cronExpression));
     }
 }
Exemplo n.º 3
0
 /**
  * @param string         $name
  * @param ConfigContract $config
  * @param BackupCommand  $command
  * @param bool           $noInteraction
  *
  * @return OutputContract
  *
  * @throws PathNotFoundException
  */
 protected function createOutput($name, ConfigContract $config, BackupCommand $command = null, $noInteraction = false)
 {
     $command = $this->getCommand($command);
     try {
         return (new IOGenerator($name, $config->getOutput($name), 'output'))->validate()->make();
     } catch (PathNotFoundException $e) {
         // If we have access to the actual command object we can ask the
         // user if he or she wants to create the missing output directory
         // and finally create the directory for the user.
         if (!$command) {
             throw $e;
         }
         $helper = $command->getHelper('question');
         $question = new ConfirmationQuestion("<comment>The directory '" . $e->getPath() . "' doesn't exist. Create it?</comment> <info>[y|n]</info>\n", false);
         if (!$helper->ask($input = $command->getInput(), $output = $command->getOutput(), $question) && !$noInteraction) {
             throw $e;
         }
         mkdir($e->getPath(), 0777, true);
         $output->writeln('');
         return $this->createOutput($name, $config);
     }
 }