crontabManager = $crontabManager; $this->tasksProvider = $tasksProvider; parent::__construct(); } /** * {@inheritdoc} */ protected function configure() { $this->setName('cron:install') ->setDescription('Generates and installs crontab for current user') ->addOption('force', 'f', InputOption::VALUE_NONE, 'Force install tasks'); parent::configure(); } /** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { if ($this->crontabManager->getTasks() && !$input->getOption('force')) { $output->writeln('Crontab has already been generated and saved'); return Cli::RETURN_FAILURE; } try { $this->crontabManager->saveTasks($this->tasksProvider->getTasks()); } catch (LocalizedException $e) { $output->writeln('' . $e->getMessage() . ''); return Cli::RETURN_FAILURE; } $output->writeln('Crontab has been generated and saved'); return Cli::RETURN_SUCCESS; } }