2014-03-04 35 views
0

我產生一個新的實體訪問級別的翻譯文件 - Symfony2的

php app/console generate:doctrine:entity 

時,我想更新我的數據庫

PHP應用程序/控制檯學說:架構:更新自卸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

一些想法我的朋友們!

+1

給我們您的實體CountryTranslation的declation。 –

+0

如果你看看創建的實體,你能告訴我們'$ id'的類型是什麼嗎? – Javad

回答

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; 

} 
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

該實體已被** php app/console generate:doctrine:entity **修改。我已經遇到過這樣的問題!你會在我的答案中找到正確的實體定義! –

+1

沒關係thk Amine !!! – IsmailJallouli