Doctrine Translatable create new translation query issue

Notice: This thread is very old.
lukas.sirhal
Backer | 20
+
0
-

Hello nette friends,

i decided to use ORM doctrine in nette i start with a Kdyby Doctrine its works fine and i do not had problem to involvement into my test project but i want to use Translation via Zenify/DoctrineBehaviors by TomasVotruba and i have problem with creating insert into DB I have Entities according tutorials the first one Pokus:

<?php
   namespace App\Entity;

   use Doctrine\ORM\Mapping as ORM;
   use Knp\DoctrineBehaviors\Model as ORMBehaviors;
   /**
    * Description of Pokus
    *
    * @author Lukas Sirhal
    * @ORM\Entity
    * @ORM\Table(name="pokus")
    */
    class Pokus extends \Kdyby\Doctrine\Entities\BaseEntity{
    use ORMBehaviors\Translatable\Translatable;
    /**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue
     */
    protected $id;

    /**
     * @ORM\Column(type="integer")
     */
    protected $number;

    //     /**
    //     * {@inheritdoc}
    //     */
    //    public static function getTranslationEntityClass()
    //    {
    //        return 'PokusTranslation';
    //    }
    public function __call($method, $arguments)
    {
        return $this->proxyCurrentLocaleTranslation($method, $arguments);
    }

    public function getId(){
        return $this->id;
    }

    public function getNumber(){
        return $this->number;
    }

    public function setNumber($number){
        $this->number = $number;
    }
  }
?>

And second entity for translations is:

<?php

namespace App\Entity;

use Doctrine\ORM\Mapping as ORM;
use Knp\DoctrineBehaviors\Model as ORMBehaviors;

/**
 * Description of PokusTranslation
 *
 * @author Lukas Sirhal
 * @ORM\Entity
 * @ORM\Table(name="pokus_translation")
 */
class PokusTranslation extends \Kdyby\Doctrine\Entities\BaseEntity {

    use ORMBehaviors\Translatable\Translation;

    /**
     * @ORM\Column(type="string")
     */
    protected $name;

    public function getName() {
        return $this->name;
    }

    public function setName($name) {
        $this->name = $name;
    }

}
?>

At the end the usage of this entities

<?php
$pokus = new Entity\Pokus;
        $pokus->setNumber(8);
        $pokus->translate('en')->setName("hello");
        $pokus->translate('cs')->setName("ahoj");
        $pokus->mergeNewTranslations();
        $this->em->persist($pokus);
        $pokus->mergeNewTranslations();
        $this->em->flush();
?>

Before this a generated the SQL code via new \Doctrine\ORM\Tools\SchemaTool($this->em)->getCreatedSchemSql($classes) and the SQL a post into my DB but the EntityManager create only 1 insert to the Pokus table and forgot on the Translation table.
Do somebody know what is wrong. THX