我生成了一个新实体
php app/console generate:doctrine:entity
当我想更新我的数据库时
php app / console doctrine:schema:update --dump-sql
我有这个错误
HP Fatal error: Access level to Minn\AdsBundle\Entity\CountryTranslation::$id must be protected (as in class ..
我认为翻译捆绑的确切关注:
/NetBeansProjects/tuto/src/Minn/AdsBundle/Entity/CountryTranslation.php
有些想法我的朋友们?!!
答案 0 :(得分:0)
我的实体CountryTranslation:
<?php
namespace Minn\AdsBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Translatable\Entity\MappedSuperclass\AbstractPersonalTranslation;
/**
* @ORM\Entity
* @ORM\Table(
* uniqueConstraints={@ORM\UniqueConstraint(name="lookup_unique_idx", columns={
* "locale", "object_id", "field"
* })}
* )
*/
class CountryTranslation extends AbstractPersonalTranslation {
/*
* Convenient constructor
*
* @param string $locale
* @param string $field
* @param string $value
*/
/*public function __construct($locale, $field, $value) {
$this->setLocale($locale);
$this->setField($field);
$this->setContent($value);
}*/
public function __construct() {
/*this must be an empty one!*/
}
/**
* @ORM\ManyToOne(targetEntity="Country", inversedBy="translations")
* @ORM\JoinColumn(name="object_id", referencedColumnName="id", onDelete="CASCADE")
*/
protected $object;
/**
* @var integer
*/
private $id;
/**
* @var string
*/
private $locale;
/**
* @var string
*/
private $field;
/**
* @var string
*/
private $content;
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set locale
*
* @param string $locale
* @return CountryTranslation
*/
public function setLocale($locale)
{
$this->locale = $locale;
return $this;
}
/**
* Get locale
*
* @return string
*/
public function getLocale()
{
return $this->locale;
}
/**
* Set field
*
* @param string $field
* @return CountryTranslation
*/
public function setField($field)
{
$this->field = $field;
return $this;
}
/**
* Get field
*
* @return string
*/
public function getField()
{
return $this->field;
}
/**
* Set content
*
* @param string $content
* @return CountryTranslation
*/
public function setContent($content)
{
$this->content = $content;
return $this;
}
/**
* Get content
*
* @return string
*/
public function getContent()
{
return $this->content;
}
/**
* Set object
*
* @param \Minn\AdsBundle\Entity\Country $object
* @return CountryTranslation
*/
public function setObject(\Minn\AdsBundle\Entity\Country $object = null)
{
$this->object = $object;
return $this;
}
/**
* Get object
*
* @return \Minn\AdsBundle\Entity\Country
*/
public function getObject()
{
return $this->object;
}
}
答案 1 :(得分:0)
这是定义CountryTranslation的方法:
<?php
namespace Minn\AdsBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Translatable\Entity\MappedSuperclass\AbstractPersonalTranslation;
/**
* @ORM\Entity
* @ORM\Table(
* uniqueConstraints={@ORM\UniqueConstraint(name="lookup_unique_idx", columns={
* "locale", "object_id", "field"
* })}
* )
*/
class CountryTranslation extends AbstractPersonalTranslation {
/*
* Convenient constructor
*
* @param string $locale
* @param string $field
* @param string $value
*/
/*public function __construct($locale, $field, $value) {
$this->setLocale($locale);
$this->setField($field);
$this->setContent($value);
}*/
public function __construct() {
/*this must be an empty one!*/
}
/**
* @ORM\ManyToOne(targetEntity="Country", inversedBy="translations")
* @ORM\JoinColumn(name="object_id", referencedColumnName="id", onDelete="CASCADE")
*/
protected $object;
}