2014-06-25 14 views
5

Próbuję przetłumaczyć niektóre pola mojej jednostki i mam następujący błąd, gdy próbuję utworzyć obiekt ...Symfony2 - pole do przetłumaczenia - Klasa "Gedmo Translatable Entity Translation" nie została znaleziona w skonfigurowanych przestrzeniach nazw

<?php 

namespace XXXX\Entity; 

use Gedmo\Mapping\Annotation as Gedmo; 
use Doctrine\ORM\Mapping as ORM; 
use Gedmo\Translatable\Translatable; 
use Doctrine\Common\Collections\ArrayCollection; 

/** 
* Line 
* 
* @ORM\Table() 
* @ORM\Entity(repositoryClass="XXXX\Entity\LineRepository") 
*/ 
class Line implements Translatable 
{ 
    /** 
    * @var integer 
    * 
    * @ORM\Column(name="id", type="integer") 
    * @ORM\Id 
    * @ORM\GeneratedValue(strategy="AUTO") 
    */ 
    private $id; 

    /** 
    * @var string 
    * 
    * @Gedmo\Translatable 
    * @ORM\Column(name="name", type="string", length=255) 
    */ 
    private $name; 

    /** 
    * Get id 
    * 
    * @return integer 
    */ 
    public function getId() 
    { 
     return $this->id; 
    } 

    /** 
    * Set name 
    * 
    * @param string $name 
    * @return Line 
    */ 
    public function setName($name) 
    { 
     $this->name = $name; 

     return $this; 
    } 

    /** 
    * Get name 
    * 
    * @return string 
    */ 
    public function getName() 
    { 
     return $this->name; 
    } 

    public function setTranslatableLocale($locale) 
    { 
     $this->locale = $locale; 
    } 
} 

i błąd:

[Doctrine\Common\Persistence\Mapping\MappingException] 
The class 'Gedmo\Translatable\Entity\Translation' was not found in the chain configured namespaces 

Używam Symfony 2.5, ale w 2.4 występuje zbyt. Każdy pomysł, jak mogę to rozwiązać?

Odpowiedz

7

Musisz również skonfigurować tłumaczącą jednostkę. W config.yml:

orm: 
    (....) 
    mappings: 
     translatable: 
      type: annotation 
      is_bundle: false 
      prefix: Gedmo\Translatable\Entity 
      dir: "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Translatable/Entity" 
      alias: GedmoTranslatable 
Powiązane problemy