private function truncate(OutputInterface $output)
    {
        $output->writeln('Removing pages ...');

        $em = $this->getContainer()->get('ekyna_cms.page.manager');
        $repository = $this->getContainer()->get('ekyna_cms.page.repository');

        $count = 0;
        $pages = $repository->findAll();
        foreach ($pages as $page) {
            $em->remove($page);
            $count++;
        }
        $em->flush();
        $em->clear();

        $class = $this->getContainer()->getParameter('ekyna_cms.page.class');
        $cmd = $em->getClassMetadata($class);
        $connection = $em->getConnection();
        $dbPlatform = $connection->getDatabasePlatform();
        $connection->beginTransaction();
        try {
            $connection->query('SET FOREIGN_KEY_CHECKS=0');
            $q = $dbPlatform->getTruncateTableSQL($cmd->getTableName());
            $connection->executeUpdate($q);
            $connection->query('SET FOREIGN_KEY_CHECKS=1');
            $connection->commit();
        } catch (\Exception $e) {
            $output->writeln(sprintf('<error>Failed to truncate table for class %s.</error>', $class));
            $connection->rollBack();
        }

        $output->writeln(sprintf('<info>%s</info> pages removed.', $count));
    }