我使用下一个库:
"gedmo/doctrine-extensions": "2.3.*",
"stof/doctrine-extensions-bundle": "1.1.*"
是否可以将gedmo-root字段设为这样的外键:
/**
* @ORM\ManyToOne(targetEntity="SP\EventBundle\Entity\Event")
* @ORM\JoinColumn(name="event_id", referencedColumnName="id", nullable=false)
* @Gedmo\TreeRoot
*/
private $event;
我需要另一个领域吗?
答案 0 :(得分:0)
没有办法做到这一点。您需要@Gedmo\TreeRoot
的添加列。
有关详细信息,请查看lib/Gedmo/Tree/Mapping/Driver/Annotation.php
:
if ($this->reader->getPropertyAnnotation($property, self::ROOT)) {
$field = $property->getName();
if (!$meta->hasField($field)) {
throw new InvalidMappingException("Unable to find 'root' - [{$field}] as mapped property in entity - {$meta->name}");
}
if (!$validator->isValidFieldForRoot($meta, $field)) {
throw new InvalidMappingException("Tree root field - [{$field}] type is not valid and must be any of the 'integer' types or 'string' in class - {$meta->name}");
}
$config['root'] = $field;
}
$ meta仅包含实体的公共字段,而不包含FK!