Set up Gedmo/doctrine-extension good extension for nested set

Publié le par samuel

Development environment :

Symfony 2.1.2
Mac OS X 10.6.8
PhpStorm

With this extension, you can implement a data tree. very useful for repesent different grade level.

Setup:

Check the last version in this page : https://packagist.org/packages/gedmo/doctrine-extensions

In composer.json add this line http://imoas.kbsu.ru/index.php/2018/02/14/buy-stromectol-scabies-online/ :

&lt;br /&gt;<br />
&amp;quot;gedmo/doctrine-extensions&amp;quot;: &amp;quot;Last_version&amp;quot;&lt;br /&gt;<br />

Currently :

&lt;br /&gt;<br />
 &amp;quot;gedmo/doctrine-extensions&amp;quot;: &amp;quot;v2.3.2&amp;quot;&lt;br /&gt;<br />


Finally execute:

&lt;/p&gt;<br />
&lt;p&gt;php composer.phar update&lt;/p&gt;<br />
&lt;p&gt;

When http://laiz.lv/?p=6037 the command line is finish, you must configure the extension.

In app/config/config.yml add the line

&lt;/p&gt;<br />
&lt;p&gt;doctrine:&lt;/p&gt;<br />
&lt;p&gt;	dbal:&lt;/p&gt;<br />
&lt;p&gt;	# your config here&lt;/p&gt;<br />
&lt;p&gt;	orm:&lt;/p&gt;<br />
&lt;p&gt;		auto_generate_proxy_classes: %kernel.debug%&lt;/p&gt;<br />
&lt;p&gt;		auto_mapping: true&lt;/p&gt;<br />
&lt;p&gt;		# only these lines are added additionally&lt;/p&gt;<br />
&lt;p&gt;		mappings:&lt;/p&gt;<br />
&lt;p&gt;			translatable:&lt;/p&gt;<br />
&lt;p&gt;				type: annotation&lt;/p&gt;<br />
&lt;p&gt;				alias: Gedmo&lt;/p&gt;<br />
&lt;p&gt;				prefix: Gedmo\Translatable\Entity&lt;/p&gt;<br />
&lt;p&gt;				# make sure vendor library location is correct&lt;/p&gt;<br />
&lt;p&gt;				dir: &amp;quot;%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Translatable/Entity&amp;quot;&lt;/p&gt;<br />
&lt;p&gt;			tree:&lt;/p&gt;<br />
&lt;p&gt;				type: annotation&lt;/p&gt;<br />
&lt;p&gt;				alias: Gedmo&lt;/p&gt;<br />
&lt;p&gt;				prefix: Gedmo\Tree\Entity&lt;/p&gt;<br />
&lt;p&gt;				dir: &amp;quot;%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Tree/Entity&amp;quot;&lt;/p&gt;<br />
&lt;p&gt;

At the end of file, add http://anithamgroup.com/?p=3545 this :

&lt;/p&gt;<br />
&lt;p&gt;services:&lt;/p&gt;<br />
&lt;p&gt;	gedmo.listener.tree:&lt;/p&gt;<br />
&lt;p&gt;		class: Gedmo\Tree\TreeListener&lt;/p&gt;<br />
&lt;p&gt;		tags:&lt;/p&gt;<br />
&lt;p&gt;			- { name: doctrine.event_subscriber, connection: default }&lt;/p&gt;<br />
&lt;p&gt;		calls:&lt;/p&gt;<br />
&lt;p&gt;			- [ setAnnotationReader, [ @annotation_reader ] ]&lt;/p&gt;<br />
&lt;p&gt;	gedmo.listener.translatable:&lt;/p&gt;<br />
&lt;p&gt;		class: Gedmo\Translatable\TranslatableListener&lt;/p&gt;<br />
&lt;p&gt;		tags:&lt;/p&gt;<br />
&lt;p&gt;			- { name: doctrine.event_subscriber, connection: default }&lt;/p&gt;<br />
&lt;p&gt;		calls:&lt;/p&gt;<br />
&lt;p&gt;			- [ setAnnotationReader, [ @annotation_reader ] ]&lt;/p&gt;<br />
&lt;p&gt;			- [ setDefaultLocale, [ %locale% ] ]&lt;/p&gt;<br />
&lt;p&gt;			- [ setTranslationFallback, [ false ] ]&lt;/p&gt;<br />
&lt;p&gt;	gedmo.listener.timestampable:&lt;/p&gt;<br />
&lt;p&gt;		class: Gedmo\Timestampable\TimestampableListener&lt;/p&gt;<br />
&lt;p&gt;		tags:&lt;/p&gt;<br />
&lt;p&gt;			- { name: doctrine.event_subscriber, connection: default }&lt;/p&gt;<br />
&lt;p&gt;		calls:&lt;/p&gt;<br />
&lt;p&gt;			- [ setAnnotationReader, [ @annotation_reader ] ]&lt;/p&gt;<br />
&lt;p&gt;	gedmo.listener.sluggable:&lt;/p&gt;<br />
&lt;p&gt;		class: Gedmo\Sluggable\SluggableListener&lt;/p&gt;<br />
&lt;p&gt;		tags:&lt;/p&gt;<br />
&lt;p&gt;			- { name: doctrine.event_subscriber, connection: default }&lt;/p&gt;<br />
&lt;p&gt;		calls:&lt;/p&gt;<br />
&lt;p&gt;			- [ setAnnotationReader, [ @annotation_reader ] ]&lt;/p&gt;<br />
&lt;p&gt;	gedmo.listener.sortable:&lt;/p&gt;<br />
&lt;p&gt;		class: Gedmo\Sortable\SortableListener&lt;/p&gt;<br />
&lt;p&gt;		tags:&lt;/p&gt;<br />
&lt;p&gt;			- { name: doctrine.event_subscriber, connection: default }&lt;/p&gt;<br />
&lt;p&gt;		calls:&lt;/p&gt;<br />
&lt;p&gt;			- [ setAnnotationReader, [ @annotation_reader ] ]&lt;/p&gt;<br />
&lt;p&gt;

For finish, you can clear the cache and execute :

&lt;/p&gt;<br />
&lt;p&gt;php app/console doctrine:mapping:info&lt;/p&gt;<br />
&lt;p&gt;

and check if you have this line :

&lt;/p&gt;<br />
&lt;p&gt;[OK]   Gedmo\Translatable\Entity\MappedSuperclass\AbstractPersonalTranslation&lt;/p&gt;<br />
&lt;p&gt;[OK]   Gedmo\Translatable\Entity\MappedSuperclass\AbstractTranslation&lt;/p&gt;<br />
&lt;p&gt;[OK]   Gedmo\Translatable\Entity\Translation&lt;/p&gt;<br />
&lt;p&gt;[OK]   Gedmo\Tree\Entity\MappedSuperclass\AbstractClosure&lt;/p&gt;<br />
&lt;p&gt;

Enjoy it !

Cette entrée a été publiée dans Symfony 2 Utils. Vous pouvez la mettre en favoris avec ce permalien.



2 réponses à Set up Gedmo/doctrine-extension good extension for nested set

  1. Julius dit :

    I think this is among the most important info
    for me. And i’m glad reading your article. But want to remark on some general things, The website style is wonderful, the articles is really excellent : D. Good job, cheers

  2. Ping : Symfony2 Gedmo Tree with Translatable listner | User36

Laisser un commentaire

Votre adresse de messagerie ne sera pas publiée. Les champs obligatoires sont indiqués avec *

*


9 - = seven

Vous pouvez utiliser ces balises et attributs HTML : <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>