In my php class (symfony2 entity class) I have class variable avaliable:
protected $avaliabletags = array();
Than in constructor I am putting data into that array:
/**
* Constructor
*/
public function __construct()
{
$this->avaliabletags['zatwierdzony']['name'] = "Zatwierdzony";
$this->avaliabletags['zatwierdzony']['role'] = "ROLE_ACCEPTTAG";
$this->avaliabletags['zatwierdzony']['label'] = "";
$this->avaliabletags['finalized']['name'] = "Finalized";
$this->avaliabletags['finalized']['role'] = "ROLE_ACCEPTDOC";
$this->avaliabletags['finalized']['label'] = "";
}
However the above code does not seem to populate class variable.
Using print_r
on $this->avaliabletags
result in array()
What am i doing wrong?
It seems that the problem is connected with the constructor not being called.
According to the doctrine2 documentation Doctrine2 never calls __construct() method of entities. http://www.doctrine-project.org/docs/orm/2.0/en/reference/architecture.html?highlight=construct .
Therefore I change the code into:
/**
* Baza dostepnych tagów
*/
protected $avaliabletags = array(
"zatwierdzony" => array(
"name" => "Zatwierdzony",
"role" => "ROLE_ACCEPTTAG"
),
"finalized" => array(
"name" => "Finalized",
"role" => "ROLE_ACCEPTDOC"
));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.