0

我正在尝试使用 A2lix-i18 和 a2lix-form 建立一个多语言网站,但我似乎遇到了困难。

我能够保留记录,但 translatable_id 永远不会被设置。

关于如何发生这种情况的任何想法?

<?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;
    }
}
4

1 回答 1

0

我覆盖了默认的 addTranslation 和 removeTranslation 函数。现已解决

于 2015-08-10T12:50:36.417 回答