我正在尝试使用A2lix-i18& amp; 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;
}
}
答案 0 :(得分:0)
我重写了默认的addTranslation和removeTranslation函数。现在解决了