Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translatable doesn't work #322

Open
yannissgarra opened this issue May 4, 2016 · 1 comment
Open

Translatable doesn't work #322

yannissgarra opened this issue May 4, 2016 · 1 comment

Comments

@yannissgarra
Copy link

Hi ! I try to use Doctrine Extension Translatable, but it doesn't work.

So, this is my configuration :

In my composer

"stof/doctrine-extensions-bundle": "^1.2"

In my config.yml

doctrine:
    orm:
        auto_generate_proxy_classes: "%kernel.debug%"
        naming_strategy: doctrine.orm.naming_strategy.underscore
        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
                is_bundle: false

stof_doctrine_extensions:
    default_locale: en
    translation_fallback: true
    orm:
        default:
            translatable: true

My Shop Class

<?php

namespace ShopBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Gedmo\Translatable\Translatable;

/**
 * Shop implements Translatable
 *
 * @ORM\Table(name="shop")
 * @ORM\Entity(repositoryClass="ShopBundle\Repository\ShopRepository")
 */
class Shop
{
    /**
     * @var string
     *
     * @Gedmo\Translatable
     * @ORM\Column(name="description", type="string", length=255)
     */
    private $description;

    /**
     * @var string
     * 
     * @Gedmo\Locale
     */
    private $local;

    /**
     * Set description
     *
     * @param string $description
     * @return Shop
     */
    public function setDescription($description)
    {
        $this->description = $description;

        return $this;
    }

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

    /**
     * Set translatable local
     *
     * @param string $locale
     * @return Shop
     */
    public function setTranslatableLocale($locale)
    {
        $this->locale = $locale;

        return $this;
    }
}

My Fixtures

<?php

namespace GeographyBundle\DataFixtures\ORM;

use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;
use ShopBundle\Entity\Shop;

/**
 * Load Shop Data
 */
class LoadShopData extends AbstractFixture implements OrderedFixtureInterface
{
    /**
     * Load
     *
     * @param \Doctrine\Common\Persistence\ObjectManager $manager
     */
    public function load(ObjectManager $manager)
    {
        $shop = new Shop();
        $shop->setDescription('This is shop 1 !');
        $manager->persist($shop);
        $manager->flush();

        $shop->setTranslatableLocale('fr');
        $shop->setDescription("Ceci est le shop 1 !");
        $manager->flush();
    }
}

Table ext_translation was created on php app/console doctrine:schema:create, but no data was insert on php app/console doctrine:fixtures:load and description field was juste updated on shop table.

What's wrong with my code ?

Thanks for any help.

@FireLizard
Copy link

FireLizard commented Jan 26, 2017

Same here! :(

The Solution on Stackoverflow doesn't work, too.

Is there anybody who is maintaining this bundle, @stof ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants