youwe / data-dictionary
A data dictionary for Pimcore
Installs: 2 638
Dependents: 1
Suggesters: 0
Security: 0
Stars: 7
Watchers: 12
Forks: 3
Open Issues: 0
Type:pimcore-bundle
Requires
- clue/graph: ^0.9.0
- graphp/graphviz: ^0.2.1
- pimcore/pimcore: ^5.6 || ^6.2
Requires (Dev)
- phpunit/phpunit: ^7.4
- squizlabs/php_codesniffer: ^3.3
Suggests
- youwe/data-dictionary-object-bridge: If you are using the youwe/PimcoreObjectBridge, you can use this package to show it on the data model
This package is auto-updated.
Last update: 2024-12-13 19:06:54 UTC
README
Creates a diagram of the current datamodel inside Pimcore.
Install
Install the bundle with composer, go to the directory of the project and run the following command:
COMPOSER_MEMORY_LIMIT=3G composer require youwe/data-dictionary
And then enable the bundle:
./bin/console pimcore:bundle:install DataDictionaryBundle
And youre done!
First interface: Visitor
Nice, so the next step is to create a class that implements the interface:
namespace DataDictionaryBundle\Graph\Interfaces; interface Visitor { public function setFieldDefinition($object); public function setClassDefinition(\Pimcore\Model\DataObject\ClassDefinition $object); public function setGraph(Graph $graph); public function getGraph():Graph; public function visit(); }
In this class you will be able to change the graph that you will receive through the setGraph method. Before calling the visit method, the data dictionary will provide the field definition (setFieldDefinition), the class definition (setClassDefinition) and the graph.
We encourage you to implement those in separated class, and not in your main DataType class.
You can also extend the class
\DataDictionaryBundle\Graph\Visitor\AbstractVisitor
That implements all the methods from the interface except the method visit, you will have in this class the following properties:
protected $graph; protected $fieldDefinition; protected $classDefinition;
Second interface: DataDictionary
After you implement your visitor class, you will have to indicate how to load it, so you will have to implement an interface that will give us a method to recover your class.
namespace DataDictionaryBundle\Interfaces; use DataDictionaryBundle\Graph\Interfaces\Visitor; interface DataDictionary { public static function getVisitor(string $className = null):Visitor; public static function canVisit(string $className):bool; }
The method getVisitor receive as parameter the class name of the field definition that should be visited by the data dictionary.
Edit the services.yml to enable it
In the services.yml file you should add:
services:
datadictionary.defaultclass: #some identifier
class: DataDictionaryBundle\Graph\Visitor\Factory\DefaultClass #the class that implements the DataDictionary interface
public: true
autowiring: true
autoconfigure: true
tags: ['datadictionary'] #and this tag will allow us to load your class automaticaly
Results
You can get the data dictionary by going to the setting (gear icon) -> Show Current Data Dictionary. Then a new tab wil be opened with the data dictionary.
Or you can get the data dictionary directly going to the following URL: http:///admin/data-dictionary/
Remember to change the localhost to your own pimcore host name.
Todo
- Create a diagram with all the classes, attributes and relations;
- Classes;
- Attributes;
- Relations (basic);
- Create specific elements for specific cases:
- Localized fields;
- Object Bridge
- Bricks
- Block;
- Field collection;
- Tables;
- Classificationstore
- Generate textual documentation;
- Create links between the diagram and the documentation;