IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Symfony PHP Discussion :

softDoctrineExtension : Tree (MaterializedPath) + sluggable + Translatable = Fail :/


Sujet :

Symfony PHP

  1. #1
    Futur Membre du Club
    Profil pro
    Inscrit en
    Février 2008
    Messages
    11
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2008
    Messages : 11
    Points : 8
    Points
    8
    Par défaut softDoctrineExtension : Tree (MaterializedPath) + sluggable + Translatable = Fail :/
    Bonjour tout le monde,

    j'utilise le softdoctrineExtensionBundle sur une entity Place. (cf classe jointe)
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
     
    	<?php
     
    	namespace AppBundle\Entity;
     
    	use Doctrine\ORM\Mapping as ORM;
    	use Doctrine\ORM\Mapping\JoinColumn as JoinColumn;
    	use Doctrine\Common\Collections\ArrayCollection;
    	use Gedmo\Mapping\Annotation as Gedmo;
     
    	/**
    	 * @Gedmo\Tree(type="materializedPath")
    	 * @Gedmo\TranslationEntity(class="PlaceTranslation")
    	 * @ORM\Table(name="`place`")
    	 * @ORM\Entity(repositoryClass="PlaceRepository")
    	 */
    	class Place {
     
    	    /**
    	     * @ORM\Id
    	     * @ORM\Column(name="geoname_id", type="integer")
    	     */
    	    protected $geonameId;
     
    	    /**
    	     * @Gedmo\TreeParent
    	     * @ORM\ManyToOne(targetEntity="Place", inversedBy="children")
    	     * @ORM\JoinColumns({
    	     *   @ORM\JoinColumn(name="geoname_id_parent", referencedColumnName="geoname_id", onDelete="CASCADE")
    	     * })
    	     */
    	    protected $parent;
     
    	    /**
    	     * @ORM\OneToMany(targetEntity="Place", mappedBy="parent")
    	     * @var ArrayCollection
    	     */
    	    protected $children;
     
    	    /**
    	     * @Gedmo\TreeLevel
    	     * @ORM\Column(type="integer", nullable=true)
    	     */
    	    protected $level;
     
    	    /**
    	     * @Gedmo\Translatable
    	     * @ORM\Column(type="string", length=200)
    	     */
    	    protected $name;
     
    	    /**
    	     * @Gedmo\Translatable
    	     * @Gedmo\Slug(fields={"name"})
    	     * @Gedmo\TreePathSource
    	     * @ORM\Column(length=200, unique=true)
    	     */
    	    protected $slug;
     
    	    /**
    	     * @Gedmo\Translatable
    	     * @Gedmo\TreePath(separator="/", appendId=false, endsWithSeparator=false)
    	     * @ORM\Column(name="path", type="string", length=3000, nullable=true)
    	     */
    	    protected $path;
     
    	    /**
    	     * Constructor
    	     */
    	    public function __construct()
    	    {
    	        $this->children = new ArrayCollection();
    	    }
     
    	}
    Notamment l'extension Tree en materialized_path(gestion des "place" parents/enfants), Slug (à partir du "name") & Translatable conjointement.
    Ma conf (app/config.yml)

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
     
        orm:
            auto_generate_proxy_classes: "%kernel.debug%"
            entity_managers:
                default:
                    auto_mapping: true
                    mappings:
                        gedmo_translatable:
                            type: annotation
                            prefix: Gedmo\Translatable\Entity
                            dir: "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Translatable/Entity"
                            alias: GedmoTranslatable # (optional) it will default to the name set for the mapping
                            is_bundle: false
                        gedmo_translator:
                            type: annotation
                            prefix: Gedmo\Translator\Entity
                            dir: "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Translator/Entity"
                            alias: GedmoTranslator # (optional) it will default to the name set for the mapping
                            is_bundle: false
                        gedmo_loggable:
                            type: annotation
                            prefix: Gedmo\Loggable\Entity
                            dir: "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Loggable/Entity"
                            alias: GedmoLoggable # (optional) it will default to the name set for the mappingmapping
                            is_bundle: false
                        gedmo_tree:
                            type: annotation
                            prefix: Gedmo\Tree\Entity
                            dir: "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Tree/Entity"
                            alias: GedmoTree # (optional) it will default to the name set for the mapping
                            is_bundle: false
     
    	# Stof Doctrine Extensions Configuration
    	stof_doctrine_extensions:
    	    default_locale: "%locale%"
    	    translation_fallback: true
    	    orm:
    	        default:
    	            translatable: true
    	            sluggable:    true
    	            tree:         true
    Mes annotations me generent 2 tables correctement : "place" & "place_translations"
    Ma locale par défaut est "en_US".
    Dans mon controlleur, lorsque je fait le traitement suivant :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
     
        $place = $placeRepository->findOneByGeonameId(1024032);
        $place->setName('mon nom en francais');
        $place->setTranslatableLocale('fr_FR');
        $em->persist($place);
        $em->flush();
    Mon "name" et "slug" sont bien générés et traduit dans la table place_translation.
    En revanche mon path (materialized path) se met à jour et est traduit dans ma table place d'origine et non dans ma table place_translation.
    Je pense que cela vient de l'ordre des listeners du softdoctrine et j'ai de ce fait essayé les différentes solutions proposées sur le web, mais aucun résultat probant.
    Solutions testées :


    solution 1 : dans mon __construct de mon entity place :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
     
    		$evm = new \Doctrine\Common\EventManager();
    		$sluggableListener = new \Gedmo\Sluggable\SluggableListener();
    		$evm->addEventSubscriber($sluggableListener);
    		$treeListener = new \Gedmo\Tree\TreeListener();
    		$evm->addEventSubscriber($treeListener);
    		$translatableListener = new \Gedmo\Translatable\TranslatableListener();
    		$translatableListener->setTranslatableLocale($this->getTranslatableLocale());
    		$evm->addEventSubscriber($translatableListener);
    solution 2 : jouer avec les setHint()

    4 jours que je suis dessus et ce doit etre un truc tout con, mais je bloque.
    Des idées ?

  2. #2
    Futur Membre du Club
    Profil pro
    Inscrit en
    Février 2008
    Messages
    11
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2008
    Messages : 11
    Points : 8
    Points
    8
    Par défaut
    Petit up

  3. #3
    Futur Membre du Club
    Profil pro
    Inscrit en
    Février 2008
    Messages
    11
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2008
    Messages : 11
    Points : 8
    Points
    8
    Par défaut
    vraiment personne n'a d'idées ? Pas possible que personne n'utilise le materialized path avec des slugs traduits :/

  4. #4
    Membre expert
    Avatar de dukoid
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Novembre 2012
    Messages
    2 100
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Novembre 2012
    Messages : 2 100
    Points : 3 004
    Points
    3 004
    Par défaut
    et bien amigo, j'ai regardé mais même les Borgs ne puissent t'aider !

Discussions similaires

  1. [2.x] jms translator bundle
    Par chlock62 dans le forum Symfony
    Réponses: 1
    Dernier message: 04/11/2013, 09h54
  2. Tree View avec XML et XSL
    Par Drooxy dans le forum XSL/XSLT/XPATH
    Réponses: 3
    Dernier message: 22/04/2003, 10h21
  3. pb formatage document XML généré par un dom tree
    Par lionel69 dans le forum APIs
    Réponses: 11
    Dernier message: 17/10/2002, 09h53
  4. BTREE & B+TREE
    Par TuxP dans le forum Algorithmes et structures de données
    Réponses: 2
    Dernier message: 09/08/2002, 17h27
  5. Recherche algo tree
    Par Anonymous dans le forum Algorithmes et structures de données
    Réponses: 10
    Dernier message: 24/05/2002, 13h44

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo