protected function doGenerateLocationAliases()
    {
        $totalLocationCount = $this->getTotalLocationCount();
        $totalContentCount = $this->getTotalLocationContentCount();
        $passCount = ceil($totalLocationCount / $this->bulkCount);
        $publishedAliasCount = 0;

        if ($totalLocationCount === 0) {
            $this->output->writeln('Could not find any Locations, nothing to generate.');
            $this->output->writeln('');

            return;
        }

        $queryBuilder = $this->connection->createQueryBuilder();
        $queryBuilder
            ->select('node_id', 'parent_node_id', 'contentobject_id')
            ->from('ezcontentobject_tree')
            ->where($queryBuilder->expr()->neq('node_id', 1))
            ->orderBy('depth', 'ASC')
            ->addOrderBy('node_id', 'ASC');

        $this->output->writeln(
            "Publishing URL aliases for {$totalLocationCount} Location(s) " .
            "with {$totalContentCount} Content item(s) in all languages."
        );

        $progressBar = $this->getProgressBar($totalLocationCount);
        $progressBar->start();

        for ($pass = 0; $pass <= $passCount; ++$pass) {
            $rows = $this->loadLocationData($queryBuilder, $pass);

            foreach ($rows as $row) {
                $publishedAliasCount += $this->publishAliases(
                    $row['node_id'],
                    $row['parent_node_id'],
                    $row['contentobject_id']
                );
            }

            $progressBar->advance(count($rows));
        }

        $progressBar->finish();

        $this->output->writeln('');
        $this->output->writeln("Done. Published {$publishedAliasCount} URL alias(es).");
        $this->output->writeln('');
    }