/**
  * @inheritdoc
  */
 public function clean(DelegatingSourceCleaner $cleaner, ThresholdVoterInterface $voter)
 {
     $numCleaned = 0;
     $builder = $this->originManager->getRepository()->createQueryBuilder('o');
     /** @var OriginInterface $origin */
     foreach ($builder->getQuery()->iterate() as list($origin)) {
         if (false !== ($cleaned = $this->cleanOrigin($cleaner, $origin, $voter, $numCleaned))) {
             $numCleaned += $cleaned;
         }
     }
     return $numCleaned;
 }
 /**
  * @param ThresholdVoterInterface $voter
  * @param array                   $origins
  *
  * @throws \RuntimeException
  *
  * @return integer
  */
 protected function clean(ThresholdVoterInterface $voter, array $origins = null)
 {
     if ($origins) {
         $idleCleaner = null;
         foreach ($this->sourceCleaner->getCleaners() as $cleaner) {
             if ($cleaner instanceof IdleSourceCleaner) {
                 $idleCleaner = $cleaner;
                 break;
             }
         }
         if (null === $idleCleaner) {
             throw new \RuntimeException('No IdleSourceCleaner is configured');
         }
         $repo = $this->originManager->getRepository();
         $query = $repo->createQueryBuilder('o')->select('o')->where('o.id IN (:ids)')->setParameter('ids', $origins)->getQuery();
         $numCleaned = 0;
         foreach ($query->getResult() as $origin) {
             $numCleaned += $idleCleaner->cleanOrigin($this->sourceCleaner, $origin, $voter);
         }
         return $numCleaned;
     } else {
         return $this->sourceCleaner->cleanAll($voter);
     }
 }