0

我正在尝试从 symfony 简单的 cms 包中扩展默认的 Page 类。

问题:
自定义属性没有保留。

下面是从 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;
    } 
}   
4

1 回答 1

1

这看起来几乎是正确的,但是您错过了 $code 上的映射:

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

我认为这$code与语言无关。否则你需要nullable=true,translatable=true

如果您还想映射 PHPCR 节点,则需要

/**
 * @PHPCRODM\Node
 */
public $node;
于 2014-05-26T08:10:27.873 回答