Skip to content
This repository has been archived by the owner on Sep 16, 2021. It is now read-only.

PHPCR-ODM enhancer #27

Merged
merged 1 commit into from
Jul 17, 2016
Merged

PHPCR-ODM enhancer #27

merged 1 commit into from
Jul 17, 2016

Conversation

dantleech
Copy link
Member

@dantleech dantleech commented Jun 20, 2016

This PR adds an enhancer for the PHPCR-ODM in which supporting child types are added to the Description.

This will allow for resource browsers to know which types can be added to any given node.

/cc @wouterj @dbu

(note it depends on https://github.com/doctrine/phpcr-odm/pull/706/commits)

* Value is an array.
*/
const CHILDREN_TYPES = 'children.types';
const CHILDREN_ALLOW = 'children.allow';
Copy link
Member Author

Choose a reason for hiding this comment

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

See #25 for a possible alternative to this system of enhancement by using vendor-provided objects as descriptors.

@dantleech dantleech force-pushed the phpcr_odm_descriptor branch from c520f48 to 4215a1d Compare June 20, 2016 08:18
@wouterj
Copy link
Member

wouterj commented Jun 20, 2016

👍

However, the fun begins when using interfaces (and we probably need to use interfaces), as the tree browsers have to become aware of the implementation of the interfaces.

@dantleech
Copy link
Member Author

Well, we would have the standard descriptor classes, (HtmlLinks, Children, RestLink (?)) etc. which would suffice for most situations, so our implementations only need to be aware of these, while vendors are free to implement their own enhancers as required.

@wouterj
Copy link
Member

wouterj commented Jun 20, 2016

@dantleech well, I mainly meant using interfaces for the allowed child class configuration. We have to use interfaces, in order to allow custom documents created by the users. But JavaScript isn't aware if DemoSeoContent is an actual allowed content object.

@dantleech
Copy link
Member Author

ah I see. not sure i see the problem though - the "allowed type" is just the "payload type", that it happens to be a class in this case shouldn't matter to the JS. All (CMF) resources have a payload type. Sorry if I missed the point.

@wouterj
Copy link
Member

wouterj commented Jun 20, 2016

@dantleech in the tree browser, this allowed child option will be used to (a) determine if I can drag 'n drop a specific document as child or (b) determine which documnts I can create when doing right click -> create.

Assume I drag an DemoSeoContent document to /cms/routes/home. I then need to know whether DemoSeoContent implements RouteInterface in order to know if it's allowed under /cms/routes/home.

@dantleech
Copy link
Member Author

@wouterj now i see. Maybe we should splurge the interfaces and parent types into the descriptor also?

@dantleech
Copy link
Member Author

Updated to explode the allowed classes to concrete mapped instances.

@dantleech dantleech force-pushed the phpcr_odm_descriptor branch from fda9cdf to 1f8c822 Compare June 21, 2016 06:49
* file that was distributed with this source code.
*/

namespace Symfony\Cmf\Component\Resource\Description\Enhancer\Doctrine\PhpcrOdm;
Copy link
Member Author

Choose a reason for hiding this comment

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

Namespace should not have PhpcrOdm

@dantleech dantleech force-pushed the phpcr_odm_descriptor branch 2 times, most recently from 036e444 to d0562f9 Compare June 27, 2016 07:37
public function testNotSupportsNotSupportedByPhpcrOdm()
{
$this->cmfResource->getPayloadType()->willReturn(\stdClass::class);
$this->metadataFactory->hasMetadataFor(\stdClass::class)->willReturn(true);
Copy link
Member Author

Choose a reason for hiding this comment

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

why this?

@dantleech dantleech force-pushed the phpcr_odm_descriptor branch from d0562f9 to 84e8bad Compare June 27, 2016 07:43
@dantleech
Copy link
Member Author

dantleech commented Jun 27, 2016

/cc @wouterj so now the descriptor returns all concrete mapped classes that are instances of the allowed children, e.g. if the document allows FooInterface and AbstractBar; If Foobar and Barfoo implement FooInterface and ConcreteBar extends AbstractBar then the descriptor will have the value:

[ "Foobar", "Barfoo", "ConcreteBar" ]

@dantleech dantleech force-pushed the phpcr_odm_descriptor branch from 84e8bad to 85ca078 Compare June 28, 2016 07:32
@@ -42,13 +46,31 @@
const LINK_SHOW_HTML = 'link.show.html';
const LINK_LIST_HTML = 'link.list.html';

const LINKS_CREATE_CHILD_HTML = 'links.create_child.html';
Copy link
Member Author

Choose a reason for hiding this comment

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

Add cmment

@dantleech
Copy link
Member Author

@wouterj @dbu good to review

@dantleech
Copy link
Member Author

Will fix my comments and merge tomorrow if no objections.

@dantleech dantleech force-pushed the phpcr_odm_descriptor branch 3 times, most recently from b51a5b6 to 96c72ef Compare July 16, 2016 08:58
@dantleech dantleech force-pushed the phpcr_odm_descriptor branch from 96c72ef to 12d11f2 Compare July 16, 2016 09:06
- Explode class metadata
- Do not generate for non-existing routes
- Added support for children links (Sylius)
@dantleech dantleech force-pushed the phpcr_odm_descriptor branch from 12d11f2 to f1368ec Compare July 16, 2016 09:06
@dantleech dantleech merged commit 438bdec into master Jul 17, 2016
@dantleech dantleech deleted the phpcr_odm_descriptor branch July 17, 2016 08:07
@dantleech dantleech removed the wip/poc label Jul 17, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants