I'm trying to extend the default Page class from symfony simple cms bundle.
The problem:
The custom property is not persisted.
Below is the code of the class which extends from BasePage.
use Doctrine\ODM\PHPCR\Mapping\Annotations\Document;
use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM;
use Symfony\Cmf\Bundle\SimpleCmsBundle\Doctrine\Phpcr\Page as BasePage;
/**
* {@inheritDoc}
* @PHPCRODM\Document(referenceable=true)
*/
class Product extends BasePage
{
public $node;
/**
* @var string(nullable=true)
*/
private $code;
/**
* Get Code
* @return string
*/
public function getCode()
{
return $this->code;
}
/**
* Set code
* @return Product
*/
public function setCode($code)
{
$this->code = $code;
return $this;
}
}
This looks almost correct, but you miss a mapping on the $code:
I assume that
$code
is not language dependant. Otherwise you would neednullable=true,translatable=true
If you also want to have the PHPCR node mapped, you need