2014-09-01 73 views
0

我下次使用库:是否有可能使gedmo-root字段成为外键?

"gedmo/doctrine-extensions": "2.3.*", 
"stof/doctrine-extensions-bundle": "1.1.*" 

是否有可能使gedmo根字段设置为外键是这样的:

/** 
* @ORM\ManyToOne(targetEntity="SP\EventBundle\Entity\Event") 
* @ORM\JoinColumn(name="event_id", referencedColumnName="id", nullable=false) 
* @Gedmo\TreeRoot 
*/ 
private $event; 

我需要为它的另一个领域?

回答

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; 
} 

$元只包含实体的共同领域,不FK!

相关问题