src/Sulu/Bundle/PageBundle/Command/CleanupHistoryCommand.php
private function cleanup(OutputInterface $output, NodeInterface $node, $rootPath, $dryRun)
    {
        foreach ($node->getNodes() as $childNode) {
            $this->cleanup($output, $childNode, $rootPath, $dryRun);
        }

        $path = ltrim(str_replace($rootPath, '', $node->getPath()), '/');

        if (!$node->getPropertyValueWithDefault('sulu:history', false)) {
            $output->writeln(
                '<info>Processing aborted: </info>/' .
                $path . ' <comment>(no history url)</comment>'
            );

            return;
        }

        if (false === $dryRun) {
            $node->remove();
        }
        $output->writeln('<info>Processing: </info>/' . $path);
    }
private function cleanup(OutputInterface $output, NodeInterface $node, $rootPath, $dryRun)
    {
        foreach ($node->getNodes() as $childNode) {
            $this->cleanup($output, $childNode, $rootPath, $dryRun);
        }

        $path = ltrim(str_replace($rootPath, '', $node->getPath()), '/');

        if (!$node->getPropertyValueWithDefault('sulu:history', false)) {
            $output->writeln(
                '<info>Processing aborted: </info>/' .
                $path . ' <comment>(no history url)</comment>'
            );

            return;
        }

        if (false === $dryRun) {
            $node->remove();
        }
        $output->writeln('<info>Processing: </info>/' . $path);
    }
private function cleanup ( OutputInterface $ output , NodeInterface $ node , $ rootPath , $ dryRun ) { foreach ( $ node -> getNodes ( ) as $ childNode ) { $ this -> cleanup ( $ output , $ childNode , $ rootPath , $ dryRun ) ; } $ path = ltrim ( str_replace ( $ rootPath , '' , $ node -> getPath ( ) ) , '/' ) ; if ( ! $ node -> getPropertyValueWithDefault ( 'sulu:history' , false ) ) { $ output -> writeln ( '<info>Processing aborted: </info>/' . $ path . ' <comment>(no history url)</comment>' ) ; return ; } if ( false === $ dryRun ) { $ node -> remove ( ) ; } $ output -> writeln ( '<info>Processing: </info>/' . $ path ) ; }
Cleanup specific node and his children.

@param NodeInterface $node
@param string $rootPath
@param bool $dryRun
Cleanup specific node and his children .