Skip to content

Node edit command #73

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

Merged
merged 3 commits into from
Aug 7, 2014
Merged

Node edit command #73

merged 3 commits into from
Aug 7, 2014

Conversation

dantleech
Copy link
Member

This is a PR for a new command which enables nodes to be edited as a whole, and replaces the node:property:edit command (the node:property:set command still exists however).

Example:

PHPCRSH> node:edit cms/products/product1

Will open an editor with the following:

cost:
    type: Double
    value: 12.13
weight:
    type: Long
    value: 10
size:
    type: String
    value: XL
name:
    type: String
    value: 'Product One'
'jcr:primaryType':
    type: Name
    value: 'nt:unstructured'
tags:
    type: String
    value: [one, two, three]

It also supports a short syntax when creating nodes:

'jcr:primaryType':
    type: Name
    value: 'nt:unstructured'
foobar: barfoo
barfoo: foobar

You can then edit, remove or add properties as required.

- One edit command to rule them all
- Will be able to edit entire nodes or single properties
- Will use Serializer component to serialize nodes to and from different
  formats (YAML/XML f.e.)
/**
* Encodes YAML data
*
* @author Sander Coolen <sander@jibber.nl>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. This is not me ..


if ($datum['type'] != $typeName) {
throw new \InvalidArgumentException(sprintf(
'Cannot currently change a properties type for property "%s" (trying to change from "%s" to "%s")',
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dbu @lsmith77 am I correct in thinking that the only way to change a properties type is to delete it and recreate it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think changes on node types are not something that was well planned for in jcr. jackrabbit does not even support to remove anything on a node type or remove a whole type / mixin. last i heard, their recommendation is to migrate the whole repository when this is needed...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well this is not necessarily about node-types, this could be a property on an nt:unstructured node. But there doesn't seem to be a setType method on the PropertyInterface.

Also.. I noticed that when saving "10" as a "Double" to jackrabbit, that it comes back as a "Long". Is that jackalope ignoring the specified type, or jackrabbit?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah sorry, did not read enough context. hm, in jcr you have not only Property but also Value. setting a Property to a different Value object would most likely change its type as well. maybe PHPCR is missing a method here, indeed. could you open an issue about this on phcpr?

the other thing should really not happen. https://github.com/phpcr/phpcr-api-tests/blob/master/tests/10_Writing/SetPropertyTypesTest.php tries out such cases. do we have the example you mention? is the problem also occuring with doctrine-dbal?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, checked the JCR API and it behaves as you described, created:

phpcr/phpcr#79

For the other it is only for jackrabbit:

jackalope/jackalope-jackrabbit#92

@dantleech
Copy link
Member Author

Need to handle BINARY properties - i.e. do not serialize them, but show a message in the comment section listing the BINARY properties that have been ommitted.

@dbu
Copy link
Member

dbu commented Jul 28, 2014

for binary, something like writing into file / reading from file would be cool. but lets postpone to a separate PR i guess.

dantleech added a commit that referenced this pull request Aug 7, 2014
@dantleech dantleech merged commit 4eb6150 into master Aug 7, 2014
@dantleech dantleech deleted the node-edit-command branch August 7, 2014 05:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants