protected function collect($types) {
    $persistenceFacade = $this->getPersistenceFacade();
    $nodesPerCall = $this->getRequestValue('nodesPerCall');
    foreach ($types as $type) {
      $oids = $persistenceFacade->getOIDs($type);
      $oidLists = array_chunk($oids, self::OPTIMIZE_FREQ);
      for ($i=0, $count=sizeof($oidLists); $i<$count; $i++) {
        $this->addWorkPackage($this->getMessage()->getText('Indexing %0% %1% objects, starting from %2%., ', [sizeof($oids), $type, ($i*self::OPTIMIZE_FREQ+1)]),
                $nodesPerCall, $oidLists[$i], 'index');
        $this->addWorkPackage($this->getMessage()->getText('Optimizing index'),
                1, [0], 'optimize');
      }
    }
  }