config = $config; $this->entityManager = $entityManager; } protected $cleanupRemindersPeriod = '15 days'; public function process() { $period = '-' . $this->config->get('cleanupRemindersPeriod', $this->cleanupRemindersPeriod); $dt = new \DateTime(); $dt->modify($period); $pdo = $this->entityManager->getPDO(); $sql = $this->entityManager->getQuery()->createDeleteQuery('Reminder', [ 'whereClause' => [ 'remindAt<' => $dt->format('Y-m-d') ], ]); $sth = $pdo->prepare($sql); $sth->execute(); } }