Skip to content

Commit

Permalink
Fixed up following review
Browse files Browse the repository at this point in the history
  • Loading branch information
dantleech committed Apr 16, 2013
1 parent 7c8be1c commit 87df665
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/PHPCR/Util/Console/Command/PurgeCommand.php
Expand Up @@ -50,7 +50,7 @@ protected function configure()
->setDescription('Remove content from the repository')
->addArgument('path', InputArgument::OPTIONAL, 'Path of the node to purge', '/')
->addOption('force', null, InputOption::VALUE_NONE, 'Use to bypass the confirmation dialog')
->addOption('children', null, InputOption::VALUE_NONE, 'Use to only purge children of specified path')
->addOption('only-children', null, InputOption::VALUE_NONE, 'Use to only purge children of specified path')
->setHelp(<<<EOF
The <info>phpcr:purge</info> command remove all the non-standard nodes from the content repository
EOF
Expand All @@ -67,20 +67,20 @@ protected function execute(InputInterface $input, OutputInterface $output)

$path = $input->getArgument('path');
$force = $input->getOption('force');
$onlyChildren = $input->getOption('children');
$onlyChildren = $input->getOption('only-children');

if (!$force) {
$dialog = new DialogHelper();
$workspaceName = $session->getWorkspace()->getName();

if ($onlyChildren) {
$question =
'Are you sure you want to purge all the children of path "%s" '.
'Are you sure you want to recursively delete the children of path "%s" '.
'from workspace "%s"';
} else {
$question =
'Are you sure you want to purge the path "%s" and all of its '.
'children from workspace "%s"';
'Are you sure you want to recursively delete the path "%s" '.
'from workspace "%s"';
}

$force = $dialog->askConfirmation($output, sprintf(
Expand All @@ -93,9 +93,6 @@ protected function execute(InputInterface $input, OutputInterface $output)

if ($onlyChildren) {
$baseNode = $session->getNode($path, 0);
if (!$baseNode) {
throw new \Exception(sprintf('Could not find node at path "%s"', $path));
}

foreach ($baseNode->getNodes() as $childNode) {
$output->writeln(sprintf($message, $childNode->getPath()));
Expand Down

0 comments on commit 87df665

Please sign in to comment.