em = $em; } protected function configure() { $this ->setName('copypaste:cron:drop-expired') ->setDescription('Drop expired copypastes') ; } protected function execute(InputInterface $input, OutputInterface $output) { $output->write('Deleting expired entities...'); // @todo move to repository $qb = $this->em->createQueryBuilder() ->delete(Copypaste::class, 'c') ->where('c.dateExpire < :now') ->andWhere('c.dateExpire IS NOT NULL') ->setParameter('now', new \DateTime()); $qb->getQuery()->execute(); $output->writeln('Done.'); } }