title: API Platform - Entity Translation, Doctrine Translatable
body: <p>I'm trying to add <a href="https://github.com/KnpLabs/DoctrineBehaviors" rel="nofollow noreferrer">KnpLabs Doctrine Behaviors</a> -  and precisely, the <a href="https://github.com/KnpLabs/DoctrineBehaviors#translatable" rel="nofollow noreferrer">Translatable Behavior</a> - on one of the entity in my API Platform project.</p>
  
  <p>Here's what I've done so far : </p>
  
  <pre><code>    namespace App\Entity;
  
      use Doctrine\ORM\Mapping as ORM;
      use Knp\DoctrineBehaviors\Model as ORMBehaviors;
      use ApiPlatform\Core\Annotation\ApiResource;
  
      /**
      * @ORM\Entity(repositoryClass="App\Repository\ArticleRepository")
      * @ApiResource
      */
      class Article
      {
          use ORMBehaviors\Translatable\Translation,
              ORMBehaviors\Timestampable\Timestampable
          ;
  
          /**
          * @ORM\Id
          * @ORM\GeneratedValue
          * @ORM\Column(type="integer")
          */
          protected $id;
  
          /**
           * Get id
           *
           * @return int
           */
           public function getId()
           {
               return $this-&gt;id;
           }
      }
  </code></pre>
  
  <p>And here's the Entity translation :</p>
  
  <pre><code>    namespace App\Entity;
  
      use Doctrine\ORM\Mapping as ORM;
      use Knp\DoctrineBehaviors\Model as ORMBehaviors;
      use ApiPlatform\Core\Annotation\ApiResource;
      use App\Traits as CustomTraits;
  
      /**
       * @ORM\Entity(repositoryClass="App\Repository\ArticleTranslationRepository")
       * @ApiResource
       */
       class ArticleTranslation
       {
            use ORMBehaviors\Translatable\Translatable;
  
            /**
             * @var string
             * 
             * @ORM\Column(name="someFieldToTranslate", type="string", length=255, nullable=true)
             */
             private $someFieldToTranslate;
  
             public function getSomeFieldToTranslate(){...}
             public function setSomeFieldToTranslate($someFieldToTranslate){...}
       }
  </code></pre>
  
  <p>Here's the basic "configuration" for getting Translatable Behavior working according to the doc.</p>
  
  <p>Issues start when I try to update the DB schema : I got this error: </p>
  
  <blockquote>
    <p>No identifier/primary key specified for Entity "App\Entity\ArticleTranslation". Every Entity must have an identifier/primary key in . (which is being imported from "/Sites/bookshop-api/config/routes/api_platform.yaml"). Make sure there is a<br>
      loader supporting the "api_platform" type.   </p>
  </blockquote>
  
  <p>However in Translatable Traits, there's already an ID and documentation precise that Translation Entity should only have fields we want to translate...</p>
  
  <p>Anyway, I've put an ID to this ArtcleTranslation Entity to get rid of the error  : </p>
  
  <pre><code>    namespace App\Entity;
  
      use Doctrine\ORM\Mapping as ORM;
      use Knp\DoctrineBehaviors\Model as ORMBehaviors;
      use ApiPlatform\Core\Annotation\ApiResource;
      use App\Traits as CustomTraits;
  
      /**
       * @ORM\Entity(repositoryClass="App\Repository\ArticleTranslationRepository")
       * @ApiResource
       */
       class ArticleTranslation
       {
            use ORMBehaviors\Translatable\Translatable;
  
            /**
             * @ORM\Id
             * @ORM\GeneratedValue
             * @ORM\Column(type="integer")
             */
             protected $id;
  
  
            /**
             * @var string
             * 
             * @ORM\Column(name="content", type="string", length=255, nullable=true)
             */
             private $content;
  
             public function getContent(){...}
             public function setContent($someContent){...}
       }
  </code></pre>
  
  <p>From here, no error when I update the DB schema. Perfect ! 
  Now I can take a look at the Swagger Documentation : </p>
  
  <p><a href="https://i.stack.imgur.com/ai2gO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ai2gO.png" alt="enter image description here"></a></p>
  
  <p>Everything looks fine ! But when I do take a look at the DB : </p>
  
  <p>In Article table : </p>
  
  <ul>
  <li>no "local" field</li>
  <li>no "empty" field</li>
  </ul>
  
  <p>In ArticleTranslation table : </p>
  
  <ul>
  <li>no "translatable_id" field</li>
  <li>no "currentLocal"</li>
  <li>no "defaultLocal"</li>
  </ul>
  
  <p>I guess it must be linked but in the swagger POST Tab, the model is different too.</p>
  
  <p><a href="https://i.stack.imgur.com/8y3aF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8y3aF.png" alt="enter image description here"></a>
           <em>article_translation model</em></p>
  
  <p>I only tried /GET and /POST method on both entities, they're working (I can see it in DB) but no relation between the 2 of them.</p>
  
  <p>I hope my post is not too long but I tried to be the more specific ! </p>
  
  <p>Thanks in advance</p>