I need some help understanding documents, workspace and nodes.

27 views
Skip to first unread message

Bruno Reis

unread,
Aug 8, 2015, 12:57:51 PM8/8/15
to symfony-...@googlegroups.com
I'm going a little further on my understanding of the cmf now. I've being reading docs and debugging a lot but still have some confusion in my mind. Please help. 

What are workspaces? I don't see it explained on the docs, but I see this term used a lot. 

I understand a doc is an object persisted by phpcr, normally mapped with @Document. But, I had some problems because some places require a "NodeInterface" implementation. 

Looking at this interface, it says that "The Node interface represents a node in a workspace.". And I also found some info about The Node field mapping" (http://doctrine-phpcr-odm.readthedocs.org/en/latest/reference/phpcr-access.html"). 

I also see that AbstractBlock do not implement the NodeInterface and also do not use a node field mapping. 

So, an AbstractBlock or SimpleBlock is not a node in the workspace? (I see it implements a ChildInterface.)

Please Help!

Just so you know, I started looking at that because I've finished a first iteration of a content structure and I want to refactor it to use best practices. 

I also had some problems because I created some Documents that do not implement that interface, but those would not show in the admin. Why? Because MenuNode and another type that I do not remember now will filter the getChildren method and ignore objects that do not implement that. 

Lukas Kahwe Smith

unread,
Aug 8, 2015, 4:54:57 PM8/8/15
to symfony-...@googlegroups.com

> On 08 Aug 2015, at 18:57, Bruno Reis <bruno....@gmail.com> wrote:
>
> I'm going a little further on my understanding of the cmf now. I've being reading docs and debugging a lot but still have some confusion in my mind. Please help.
>
> What are workspaces? I don't see it explained on the docs, but I see this term used a lot.

workspaces are essentially separate mount points .. essentially it allows you to have many root paths .. some people use this for example to have one workspace for their media files shared with multiple independent workspaces for different websites.

it is also often used to have one workspace for staging and another for production. there are ways to clone workspaces and copy/merge content between workspaces.

BTW when ever you are wondering about a PHPCR concept .. you can also search for the same concept with JCR .. often there is more content on the web discussing JCR ..

> I understand a doc is an object persisted by phpcr, normally mapped with @Document. But, I had some problems because some places require a "NodeInterface" implementation.
>
> Looking at this interface, it says that "The Node interface represents a node in a workspace.". And I also found some info about The Node field mapping" (http://doctrine-phpcr-odm.readthedocs.org/en/latest/reference/phpcr-access.html").

The “in a workspace” part is only really relevant to you if you have multiple workspaces.

> I also see that AbstractBlock do not implement the NodeInterface and also do not use a node field mapping.

PHPCR fundamentally is a tree of nodes attached to the root or a child node. PHPCR ODM maps document state to nodes, which kind of hides the concept of Nodes from the user ..

BTW there is also a NodeInterface part of KnpMenu which is a different thing entirely.

> So, an AbstractBlock or SimpleBlock is not a node in the workspace? (I see it implements a ChildInterface.)
>
> Please Help!
>
> Just so you know, I started looking at that because I've finished a first iteration of a content structure and I want to refactor it to use best practices.

I would recommend reading http://wiki.apache.org/jackrabbit/DavidsModel
However do note that he is talking about working with JCR on the node level .. and most CMF users work on the ODM level (ie. PHP classes) which is a much more ridged way of defining structure than a normal PHPCR node is .. effectively PHPCR ODM classes are essentially very restrictive node types (indeed we have pondered to allow generation of node types from PHPCR ODM classes).

> I also had some problems because I created some Documents that do not implement that interface, but those would not show in the admin. Why? Because MenuNode and another type that I do not remember now will filter the getChildren method and ignore objects that do not implement that.

again MenuNode has nothing to do with PHPCR.

regards,
Lukas Kahwe Smith
sm...@pooteeweet.org



signature.asc

Bruno Reis

unread,
Aug 9, 2015, 7:13:16 AM8/9/15
to symfony-...@googlegroups.com
Hey Lukas, thanks a lot. Good clarifications. I read DavidsModel and also got good insights from there. But, I still have a doubt on how to model new documents, specially in the ODM level. 

Do I always need to implement \PHPCR\NodeInterface?

I see that the mysterious class Doctrine\ODM\PHPCR\Document\Generic does not implement it. But, it has a @PHPCRODM\Node and a @PHPCRODM\Children fields. 

What is the difference between both?




--
You received this message because you are subscribed to the Google Groups "symfony-cmf-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to symfony-cmf-us...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Lukas Smith

unread,
Aug 9, 2015, 7:19:42 AM8/9/15
to symfony-...@googlegroups.com
If you use PHPCR ODM you dont need to bother with NodeInterface of PHPCR at all. The NodeInterface of KnpMenu you only need to bother with if the document is supposed to work as a menu item. 

Using the Node mapping exposes the underlying node (kind of like the row in an ORM) as a property. Usually though this isnt needed but it can be useful when using some advanced PHPCR features like locking. 

regards,
Lukas

Bruno Reis

unread,
Aug 9, 2015, 8:54:59 AM8/9/15
to symfony-...@googlegroups.com
Hey, thanks a lot again. Things got a lot cleaner to me now. 
Reply all
Reply to author
Forward
0 new messages