-
Notifications
You must be signed in to change notification settings - Fork 30
cleaning up the dump command parameters #72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
9894a06
a00e8f1
ec645f5
39b38dc
84da397
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,20 +21,18 @@ | |
|
|
||
| namespace PHPCR\Util\Console\Command; | ||
|
|
||
| use PHPCR\Util\UUIDHelper; | ||
| use PHPCR\ItemNotFoundException; | ||
| use PHPCR\RepositoryException; | ||
| use PHPCR\PathNotFoundException; | ||
|
|
||
| use PHPCR\Util\UUIDHelper; | ||
| use PHPCR\Util\Console\Helper\PhpcrConsoleDumperHelper; | ||
|
|
||
| use Symfony\Component\Console\Input\InputArgument; | ||
| use Symfony\Component\Console\Input\InputOption; | ||
| use Symfony\Component\Console\Input\InputInterface; | ||
| use Symfony\Component\Console\Output\OutputInterface; | ||
|
|
||
| use PHPCR\Util\TreeWalker; | ||
| use PHPCR\Util\Console\Helper\TreeDumper\ConsoleDumperNodeVisitor; | ||
| use PHPCR\Util\Console\Helper\TreeDumper\ConsoleDumperPropertyVisitor; | ||
| use PHPCR\Util\Console\Helper\TreeDumper\SystemNodeFilter; | ||
|
|
||
| /** | ||
| * Command subtrees under a path to the console | ||
| * | ||
|
|
@@ -43,21 +41,14 @@ | |
| */ | ||
| class NodeDumpCommand extends BaseCommand | ||
| { | ||
| /** | ||
| * Limit after which to cut lines when dumping properties | ||
| * | ||
| * @var int | ||
| */ | ||
| private $dump_max_line_length = 120; | ||
|
|
||
| /** | ||
| * {@inheritDoc} | ||
| */ | ||
| protected function configure() | ||
| { | ||
| $this | ||
| ->setName('phpcr:node:dump') | ||
| ->addOption('sys_nodes', null, InputOption::VALUE_NONE, 'Also dump system nodes') | ||
| ->addOption('sys-nodes', null, InputOption::VALUE_NONE, 'Also dump system nodes (recommended to use with a depth limit)') | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this was leftover from the refactoring, it is now in the console dumper helper.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is kind of a BC break but before we already checked for sys-nodes, so it stopped working. and the convention is -, not _
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 |
||
| ->addOption('props', null, InputOption::VALUE_NONE, 'Also dump properties of the nodes') | ||
| ->addOption('identifiers', null, InputOption::VALUE_NONE, 'Also output node UUID') | ||
| ->addOption('depth', null, InputOption::VALUE_OPTIONAL, 'Limit how many level of children to show', "-1") | ||
|
|
@@ -72,29 +63,20 @@ protected function configure() | |
| displayed as yaml arrays. | ||
|
|
||
| By default the command filters out system nodes and properties (i.e. nodes and | ||
| properties with names starting with 'jcr:'), the <info>sys_nodes</info> option | ||
| properties with names starting with 'jcr:'), the <info>--sys-nodes</info> option | ||
| allows to turn this filter off. | ||
| HERE | ||
| ) | ||
| ; | ||
| } | ||
|
|
||
| /** | ||
| * Change at which length lines in the dump get cut. | ||
| * | ||
| * @param int $length maximum line length after which to cut the output. | ||
| */ | ||
| public function setDumpMaxLineLength($length) | ||
| { | ||
| $this->dump_max_line_length = $length; | ||
| } | ||
|
|
||
| /** | ||
| * {@inheritDoc} | ||
| */ | ||
| protected function execute(InputInterface $input, OutputInterface $output) | ||
| { | ||
| $session = $this->getPhpcrSession(); | ||
| /** @var $dumperHelper PhpcrConsoleDumperHelper */ | ||
| $dumperHelper = $this->getHelper('phpcr_console_dumper'); | ||
|
|
||
| // node to dump | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,7 @@ | |
|
|
||
| use PHPCR\ItemInterface; | ||
| use PHPCR\NodeInterface; | ||
| use PHPCR\PropertyInterface; | ||
| use PHPCR\PropertyType; | ||
| use PHPCR\SessionInterface; | ||
| use PHPCR\RepositoryException; | ||
|
|
@@ -50,7 +51,7 @@ private function __construct() | |
| * @param SessionInterface $session the PHPCR session to create the path | ||
| * @param string $path full path, like /content/jobs/data | ||
| * | ||
| * @return \PHPCR\NodeInterface the last node of the path, i.e. data | ||
| * @return NodeInterface the last node of the path, i.e. data | ||
| */ | ||
| public static function createPath(SessionInterface $session, $path) | ||
| { | ||
|
|
@@ -87,12 +88,14 @@ public static function purgeWorkspace(SessionInterface $session) | |
| { | ||
| $root = $session->getRootNode(); | ||
|
|
||
| /** @var $property PropertyInterface */ | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I assume this is a IDE helper comment. Why doesn't the IDE pick up the right typing here? Are there missing doc blocks for return types or something?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah thats because of the foreach that the ide does not see what it will get |
||
| foreach ($root->getProperties() as $property) { | ||
| if (! self::isSystemItem($property)) { | ||
| $property->remove(); | ||
| } | ||
| } | ||
|
|
||
| /** @var $node NodeInterface */ | ||
| foreach ($root->getNodes() as $node) { | ||
| if (! self::isSystemItem($node)) { | ||
| $node->remove(); | ||
|
|
@@ -111,13 +114,17 @@ public static function deleteAllNodes(SessionInterface $session) | |
| } | ||
|
|
||
| /** | ||
| * Determine whether this item has a namespace that is to be considered | ||
| * a system namespace | ||
| * Determine whether this item is to be considered a system item that you | ||
| * usually want to hide and that should not be removed when purging the | ||
| * repository. | ||
| * | ||
| * @param ItemInterface $item | ||
| */ | ||
| public static function isSystemItem(ItemInterface $item) | ||
| { | ||
| if ($item->getDepth() > 1) { | ||
| return false; | ||
| } | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is a change in behaviour, but i think it makes sense. before we skipped things like the jcr:resource of an nt:file node, which is stupid and confusing. the intention was to not dump the version history and similar things by default, and to not delete that in the purge operation. @dantleech so now this would be the place for your input as i closed #73 and merged into here to avoid the testing chaos i produced. ok if we do that?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the road atm, not quite sure of implications of the sys node change, but if you and lukas agree thats ok by me. One thing i was going to suggest was maybe moving the repository exception to a method to avoide the several "if throw" methods. Can try and have a proper look thos evening if I manage to plug my laptop in! David Buchmann notifications@github.com a écrit :
Envoyé de mon téléphone Android avec K-9 Mail. Excusez la brièveté.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good idea, will move that check to a method. |
||
| $name = $item->getName(); | ||
|
|
||
| return strpos($name, 'jcr:') === 0 || strpos($name, 'rep:') === 0; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the list of commands was totally outdated. better point to the self-doc than trying to replicate it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1