No relation between messages and messages_translation

68 views Asked by At

I'm trying to get a multilingual site up with A2lix-i18 & a2lix-form, but I've seem to hit a bump.

I'm able to persist the records, but the translatable_id never gets set.

Any ideas on how this could be occuring?

<?php


//Message.php    

namespace AppBundle\Entity;

use Doctrine\ORM\Mapping as ORM;


/**
 * @ORM\Entity
 * @ORM\Table(name="messages")
 */

class Message
{
    use \A2lix\I18nDoctrineBundle\Doctrine\ORM\Util\Translatable;
    /**
     * @ORM\Column(type="guid")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="UUID")
     */
    protected $id;


    /**
     * @ORM\Column(type="datetime")
     */
    protected $created;

    /**
     * @ORM\OneToOne(targetEntity="User")
     * @ORM\JoinColumn(name="author_id", referencedColumnName="id")
     */
    protected $author;

    /**
     */
    protected $translations;

    public function getTranslations(){
        return $this->translations;
    }

    public function addTranslation($translation){
        $this->translations[] = $translation;
    }

    public function __construct(){
        $this->created = new \DateTime();
        $this->translations = new \Doctrine\Common\Collections\ArrayCollection();
    }


    /**
     * Get id
     *
     * @return guid 
     */
    public function getId()
    {
        return $this->id;
    }


    public function getCreated()
    {
        return $this->created;
    }

    public function setCreated($created)
    {
        $this->created = $created;

        return $this;
    }

    /**
     * Set author
     *
     * @param \AppBundle\Entity\User $author
     * @return Message
     */
    public function setAuthor(\AppBundle\Entity\User $author = null)
    {
        $this->author = $author;

        return $this;
    }

    /**
     * Get author
     *
     * @return \AppBundle\Entity\User 
     */
    public function getAuthor()
    {
        return $this->author;
    }

    public function setTranslatable($translatable)
    {
        $this->translatable = $translatable;
    }
}

-

//MessageTranslation.php

namespace AppBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity
 */

class MessageTranslation implements \A2lix\I18nDoctrineBundle\Doctrine\Interfaces\ManyLocalesInterface
{
    use \A2lix\I18nDoctrineBundle\Doctrine\ORM\Util\Translation;
    /**
     * @ORM\Column(type="text")
     */
    protected $message;

    /**
     * Set message
     *
     * @param string $message
     * @return MessageTranslation
     */
    public function setMessage($message)
    {
        $this->message = $message;

        return $this;
    }

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

    /**
     * Get id
     *
     * @return integer 
     */
    public function getId()
    {
        return $this->id;
    }

    public function setId($id){
        $this->id = $id;
    }
    /**
     * Set locale
     *
     * @param string $locale
     * @return MessageTranslation
     */
    public function setLocales($locales)
    {
        $this->locales = $locales;

        return $this;
    }

    /**
     * Get locale
     *
     * @return string 
     */
    public function getLocales()
    {
        return $this->locales;
    }

    public function setTranslatable($translatable)
    {
        $this->translatable = $translatable;
    }

    public function getTranslatable()
    {
        return $this->translatable;
    }
}
1

There are 1 answers

0
nielsvermaut On

I was overriding the default addTranslation and removeTranslation functions. Solved now