kernel = $kernel; $this->doctrine = $doctrine; parent::__construct(); } protected function configure() { $this ->setDescription('Cleanup runs') ->setHelp('This command cleans the runs table') ->addOption('jobid', 'j', InputOption::VALUE_IS_ARRAY + InputOption::VALUE_REQUIRED, 'The ids of the jobs to clean') ->addOption('maxage', 'm', InputOption::VALUE_REQUIRED, 'The maximum age of the oldest runs'); } protected function execute(InputInterface $input, OutputInterface $output) { $maxage = $input->getOption('maxage'); $jobs = $input->getOption('jobid'); $runRepo = $this->doctrine->getRepository(Run::class); try { $deleted = $runRepo->cleanupRuns($jobs, $maxage); $output->writeln('Deleted ' . $deleted . ' runs'); return Command::SUCCESS; } catch(Exception $exception) { $output->writeln($exception->getMessage()); return Command::FAILURE; } return Command::SUCCESS; } }