bien le bonjour,
voila 2 jours que je coince sur la gestion des langues de mon application sous Symfony2.
J'ai installer DoctrineExtensions dans /vendor/gedmo-doctrine-extensions
J'ai installer StofDoctrineExtensionsBundle dans /vendor/bundles/
J'ai modifier mon autoload
1 2
| 'Stof' => __DIR__.'/../vendor/bundles',
'Gedmo' => __DIR__.'/../vendor/gedmo-doctrine-extensions/lib', |
J'ai modifier AppKernel
new Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(),
J'ai rajouter la config suivante dans app/config/config.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
doctrine:
dbal:
driver: %database_driver%
host: %database_host%
port: %database_port%
dbname: %database_name%
user: %database_user%
password: %database_password%
charset: UTF8
orm:
auto_generate_proxy_classes: %kernel.debug%
auto_mapping: true
mappings:
StofDoctrineExtensionsBundle: ~
stof_doctrine_extensions:
default_locale: %locale%
translation_fallback: true
orm:
default: ~ |
Et j'ai rajouter dans mon bundle le listener suivant :
1 2 3 4 5 6 7 8 9
| public function boot() {
$em = $this->container->get('doctrine.orm.entity_manager');
$evm = $em->getEventManager();
// Timestampable
$evm->addEventSubscriber(new \Gedmo\Timestampable\TimestampableListener());
// Translatable
$evm->addEventSubscriber(new \Gedmo\Translatable\TranslatableListener());
} |
J'obtient une erreur lors de l'appel au flush()
Class Gedmo\Translatable\Entity\Translation is not a valid entity or mapped super class.
Au ca sou , voici mon entity
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
| namespace Anaprosy\MenuBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
use Gedmo\Mapping\Annotation as Gedmo;
use Gedmo\Translatable\Translatable;
/**
* Anaprosy\MenuBundle\Entity\MenuItem
*
* @ORM\Table()
* @ORM\Entity(repositoryClass="Anaprosy\MenuBundle\Entity\MenuItemRepository")
* @gedmo:TranslationEntity(class="Anaprosy\MenuBundle\Entity\MenuItemTranslation")
*/
class MenuItem implements Translatable {
/**
* @var integer $id
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string $titre
* @Gedmo\Translatable
* @ORM\Column(name="titre", type="string", length=255)
*/
private $titre;
} |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| <?php
namespace Anaprosy\MenuBundle\Entity;
use Stof\DoctrineExtensionsBundle\Entity\AbstractTranslation;
use Doctrine\ORM\Mapping as ORM;
/**
* Anaprosy\MenuBundle\Entity\MyTranslationEntity
*
*
* @ORM\Entity(repositoryClass="Gedmo\Translatable\Entity\Repository\TranslationRepository")
* @ORM\Table(
* indexes={@ORM\index(name="menuitem_translation_lookup_idx", columns={
* "locale", "object_class", "foreign_key"
* })},
* uniqueConstraints={@ORM\UniqueConstraint(name="menuitem_translation_unique_idx", columns={
* "locale", "object_class", "foreign_key", "field" * })}
* )
*/
class MenuItemTranslation extends AbstractTranslation
{
} |
Partager