Ahoj,

pokouším se použít Zenify/DoctrineBehaviors pro překlad entity, ale překlad se mě neuloží. Nevíte kde dělám chybu?

<?php
namespace App\Model\Entity;

use Doctrine\Common\Collections\ArrayCollection;

use Doctrine\ORM\Mapping as ORM;
use Kdyby\Doctrine\Entities\Attributes\Identifier;
use Knp\DoctrineBehaviors\Model\Translatable\Translatable;


/**
 * @ORM\Entity
 * @ORM\Table(name="categories")
 */
class Category
{

    use Translatable;
    // use \Zenify\DoctrineBehaviors\Entities\Attributes\Translatable;
    use Identifier;

}
<?php
namespace App\Model\Entity;

use Doctrine\Common\Collections\ArrayCollection;

use Doctrine\ORM\Mapping as ORM;
use Kdyby\Doctrine\Entities\Attributes\Identifier;
use Knp\DoctrineBehaviors\Model\Translatable\Translation;


/**
 * @ORM\Entity
 */
class CategoryTranslation
{

    use Translation;

    /**
     * @ORM\Column(type="string", nullable=FALSE)
     * @var string
     */
    protected $title;

    /**
     * @return string $title
     */
    public function getTitle()
    {

        return $this->title;
    }

    /**
     * @param $title
     */
    public function setTitle($title)
    {

        $this->title = $title;
    }

}

a pak pouziti

$cat3 = new Category();
$cat3->translate('cz')->setTitle('Ženy');
$cat3->translate('en')->setTitle('Women');
$this->em->persist($cat3);
$cat3->mergeNewTranslations();

$this->em->flush();

Ahoj, zkous smazat cache a pak updatnout schema php www\index.php orm:schema-tool:update --force


You must first log in to participate in this discussion