Closed lsmith77 closed 11 years ago
@sixty-nine can we interest you in this one? ;-)
I have some prototype of the parser (intricated in a lot of other code), but I need to test it before refactoring.
@dbu would you please point me to the test CND file you suggested once for testing?
its all standard node types of jcr
Exactly, thanks David
I have a first working version that parses the example you've given.
It is here:
https://github.com/sixty-nine/ClassGrapher/blob/master/src/LazyGuy/PhpParse/Parser/CndParser.php
Now I have a problem to integrate it with PHPCR / Jackalope.
The CND parser actually generates a syntax tree that implements the visitor pattern. In order to construct the node type definitions the visitor must be able to write to the NodeTypeDefinition instances. The simple solution is to add a lot of setters in several Jackalope\NodeType classes and mark them as private.
But this parser is not really bound to Jackalope.
So my idea is to implement abstract versions of the required PHPCR\NodeType classes and add the setters there. Those classes would reside somewhere in the PHPCR namespace and could be reused by the other implementations.
An implementation of this idea for PHPCR\NodeType\NodeTypeDefinition can be found here:
The only problem would be that the final implementation as Jackalope\NodeType\NodeTypeDefinition would then have to extend an abstract class rather than implement an interface. I don't know if this is a problem. If it is for some implementations, then the correct getters could be added directly there.
The same idea goes for the Jackalope\Query\QOM namespace. It's very loosely bound to Jackalope and could (and should) be reused by the other implementations.
the parser should not need any implementation specific knowledge to build node types. the NodeTypeManager has methods to create NodeTypeTemplateInterface (plus NodeTypeDefinitionTemplate and PropertyTypeDefinitionTemplate to model child nodes and properties): http://phpcr.github.com/doc/html/phpcr/nodetype/nodetypemanagerinterface.html
for an example see the code at the bottom of this command https://github.com/doctrine/phpcr-odm/blob/master/lib/Doctrine/ODM/PHPCR/Tools/Console/Command/RegisterSystemNodeTypesCommand.php (the case when its not jackalope-jackrabbit)
The dev is going on in the branch cnd-parser but I'd need some information.
The parser is generating NodeDefinitionTemplateInterface objects. I don't get how to add child nodes definitions.
In the jackalope implementation, for the properties definitions NodeTypeDefinitionInterface::getDeclaredPropertyDefinitions() will return a mutable list so that it's possible to add properties definitions, but NodeTypeDefinitionInterface::getDeclaredChildNodeDefinitions() returns null so that it seems not possible to add child nodes definitions.
Am I missing something @dbu ?
i found this information: http://phpcr.github.com/doc/html/phpcr/nodetype/nodetypemanagerinterface.html#createNodeDefinitionTemplate%28%29 but at the moment i don't see anything in the interfaces about how to add a child node.
reading through the jcr doc did not help either: http://www.day.com/maven/javax.jcr/javadocs/jcr-2.0/index.html
this one also is not too helpful. http://wiki.apache.org/jackrabbit/ExamplesPage#Register_a_Node_Type
maybe you could ask on the jackrabbit mailinglist.
see #31
as part of this we should also add a new interface that includes the
registerNodeTypesCnd()
method extending the defaultNodeTypeManagerInterface
which should then be used inRegisterNodeTypesCommand