/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $job = new CronJob(); $output->writeln(''); $output->writeln('<question>Name</question>'); $output->writeln('<info>The unique name how the job will be referenced.</info>'); $job->setName($this->getDialogHelper()->askAndValidate($output, ': ', function ($input) { return $this->validateJobName($input); }, false)); $output->writeln(''); $output->writeln('<question>Command</question>'); $output->writeln('<info>The command to execute. You may add extra arguments.</info>'); $job->setCommand($this->getDialogHelper()->askAndValidate($output, ': ', function ($input) { return $this->validateCommand($input); }, false)); $output->writeln(''); $output->writeln('<question>Schedule</question>'); $output->writeln('<info>The schedule in the crontab syntax.</info>'); $job->setSchedule($this->getDialogHelper()->askAndValidate($output, ': ', function ($input) { return $this->validateSchedule($input); }, false)); $output->writeln(''); $output->writeln('<question>Description</question>'); $output->writeln('<info>Some more information about the job.</info>'); $job->setDescription($this->getDialogHelper()->askAndValidate($output, '<question>Description</question>: ', function ($input) { return (string) $input; })); $output->writeln(''); $output->writeln('<question>Enable</question>'); $output->writeln('<info>Should the cron be enabled.</info>'); $job->setEnabled($this->getDialogHelper()->askConfirmation($output, '[Y/n]: ', true)); $this->getContainer()->get('cron.manager')->saveJob($job); $output->writeln(''); $output->writeln(sprintf('<info>Cron "%s" was created..</info>', $job->getName())); }