tree-browser-bundle icon indicating copy to clipboard operation
tree-browser-bundle copied to clipboard

[2.0] Usage without Doctrine ODM

Open iluuu1994 opened this issue 8 years ago • 3 comments

We're using Gedmo Tree instead of Doctrine ODM for our tree data structure. In Version 1.0 of the TreeBrowserBundle it was pretty easy to write my own Tree class by implementing the TreeInterface.

How can I achieve the same thing now?

Thanks for your work!

iluuu1994 avatar Mar 31 '17 18:03 iluuu1994

@iluuu1994 now, the resource packages are used for the backend. Resource is an abstraction of tree-based backends, built on top of Puli.

So to make this Gedmo Tree compatible, you have to create a GedmoTreeRepository. You can see the DoctrineOdm repository here: https://github.com/symfony-cmf/resource/blob/master/src/Repository/PhpcrOdmRepository.php

After that, you have to create a GedmoTreeRepositoryFactory for the interaction with the container: https://github.com/symfony-cmf/resource-bundle/blob/master/src/DependencyInjection/Repository/Factory/DoctrinePhpcrOdmFactory.php

Then in your bundle's build() method, add CmfResourceBundle::addRepositoryFactory(new GedmoTreeRepositoryFactory()); and enable the factory like: https://github.com/symfony-cmf/cmf-sandbox/blob/master/app/config/config.yml#L121-L123

So it involves some more things, but the good side of the story is that you have a nice abstraction for the tree that you can use throughout your application (so it's easy to switch to PHPCR ODM, file structure, XML, any tree like thing in the future for instance).

wouterj avatar Apr 07 '17 21:04 wouterj

@wouterj Thanks for the thorough explanation! I'll let you know if I get it working. Would you be interested in merging the Gedmo adapter?

iluuu1994 avatar Apr 07 '17 23:04 iluuu1994

Yep, I'm very interesting in supporting ORM in the Symfony CMF. Adding a Gedmo tree repository seems like a very nice step in this direction.

If you need any help creating the repository or pull request, feel free to join the #symfony_cmf channel on the Symfony slack and ping me (@wouterj).

wouterj avatar Apr 08 '17 09:04 wouterj