entityManager = $entityManager; parent::__construct(); } protected function configure() { $this // the name of the command (the part after "bin/console") ->setName('generationfile:clean') // the short description shown while running "php bin/console list" ->setDescription('clean generation file') // add 'processDate' argument ->addArgument('process_date', InputArgument::OPTIONAL, 'Date of the process', date_create()->format('Y-m-d')); } public function execute(InputInterface $input, OutputInterface $output) { #get process date from config $processDate = $input->getArgument('process_date'); // outputs multiple lines to the console (adding "\n" at the end of each line) $output->writeln([ 'Clean generation file ', '============', 'Clean generation file =>', '============' ]); $qb = $this->entityManager->createQueryBuilder(); $qb->delete(GenerationFileData::class, 'gfd') ->where("gfd.archivedAt is not NULL"); $result = $qb->getQuery()->getResult(); $qb->delete(DedicatedFile::class, 'df') ->where("df.archivedAt is not NULL"); $result = $qb->getQuery()->getResult(); $io = new SymfonyStyle($input, $output); $io->success('Generation file was clean'); } }