0

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;
    } 
}   
11mb
  • 1,339
  • 2
  • 16
  • 33
loicb
  • 587
  • 2
  • 6
  • 24

1 Answers1

1

This looks almost correct, but you miss a mapping on the $code:

/**
 * @PHPCRODM\String(nullable=true)
 */
private $code;

I assume that $code is not language dependant. Otherwise you would need nullable=true,translatable=true

If you also want to have the PHPCR node mapped, you need

/**
 * @PHPCRODM\Node
 */
public $node;
dbu
  • 1,497
  • 9
  • 8