/** * Execute the command. Get all the deposits needing to be harvested. Each * deposit will be passed to the commands processDeposit() function. * * @param InputInterface $input * @param OutputInterface $output */ protected final function execute(InputInterface $input, OutputInterface $output) { $force = $input->getOption('force'); $this->em->getConnection()->getConfiguration()->setSQLLogger(null); $q = $this->em->createQuery('SELECT d FROM AppBundle\\Entity\\Deposit d where d.plnState = :state'); $q->setParameter('state', 'agreement'); $iterator = $q->iterate(); $i = 0; foreach ($iterator as $row) { $deposit = $row[0]; $this->processDeposit($deposit, $force); $i++; if ($i % 50 === 0) { $this->em->clear(); gc_collect_cycles(); } } }