Ejemplo n.º 1
0
    /**
     * {@inheritDoc}
     */
    protected function configure()
    {
        parent::configure();
        $this->configureNodeManipulationInput();
        $this->setName('phpcr:nodes:update')->addOption('query', null, InputOption::VALUE_REQUIRED, 'Query used to select the nodes')->addOption('query-language', 'l', InputOption::VALUE_OPTIONAL, 'The query language (e.g. sql, jcr_sql2)', 'jcr-sql2')->addOption('persist-counter', 'c', InputOption::VALUE_OPTIONAL, 'Save the session every x requests', '100')->setDescription('Command to manipulate the nodes in the workspace.')->setHelp(<<<HERE
The <info>phpcr:nodes:update</info> can manipulate the properties of nodes
found using the given query.

For example, to set the property <comment>foo</comment> to <comment>bar</comment> on all unstructured nodes:

    <info>php bin/phpcr phpcr:nodes:update --query="SELECT * FROM [nt:unstructured]" --set-prop=foo=bar</info>

Or to update only nodes matching a certain criteria:

    <info>php bin/phpcr phpcr:nodes:update \\
        --query="SELECT * FROM [nt:unstructured] WHERE [phpcr:class]=\\"Some\\Class\\Here\\"" \\
        --add-mixin=mix:mimetype</info>

The options for manipulating nodes are the same as with the
<info>node:touch</info> command and
can be repeated to update multiple properties.

If you have an advanced use case you can use the <comment>--apply-closure</comment> option:

    <info>php bin/phpcr phpcr:nodes:update \\
        --query="SELECT * FROM [nt:unstructured] WHERE [phpcr:class]=\\"Some\\Class\\Here\\"" \\
        --apply-closure="\\\$session->doSomething(); \\\$node->setProperty('foo', 'bar');"</info>

For each node in the result set, the closure will be passed the current
<comment>PHPCR\\SessionInterface</comment> implementation and the node (<comment>PHPCR\\NodeInterface</comment>) as <comment>\$session</comment> and <comment>\$node</comment>.
HERE
);
    }
Ejemplo n.º 2
0
    /**
     * {@inheritDoc}
     */
    protected function configure()
    {
        parent::configure();
        $this->configureNodeManipulationInput();
        $this->setName('phpcr:node:touch')->addArgument('path', InputArgument::REQUIRED, 'Path at which to create the new node')->addOption('type', 't', InputOption::VALUE_OPTIONAL, 'Node type, default nt:unstructured', 'nt:unstructured')->addOption('dump', 'd', InputOption::VALUE_NONE, 'Dump a string reperesentation of the created / modified node.')->setDescription('Create or modify a node')->setHelp(<<<HERE
This command allows you to create or modify a node at the specified path.

For example::

  \$ ./bin/phpcr phpcr:touch /foobar --type=my:nodetype --set-prop=foo=bar

Will create the node "/foobar" and set (or create) the "foo" property
with a value of "bar".

You can execute the command again to further modify the node. Here we add
the property "bar" and remove the property "foo". We also add the dump option
to output a string reperesentation of the node.

  \$ ./bin/phpcr phpcr:touch /foobar --type=my:nodetype --set-prop=bar=myvalue --remove-prop=foo --dump
HERE
);
    }