public function set($value, $allowNull = false)
{
if ($this->updatingReverseRelationship) {
return null;
}
$value = $this->createEntity($value, $allowNull);
if ($this->isChanged($value)) {
$this->modify();
$oldValue = $this->value;
if ($oldValue === false) {
$primaryValue = $this->getPrimaryValue();
$oldValue = $primaryValue !== null ? $this->getTargetRepository()->getById($primaryValue) : null;
}
$this->updateRelationship($oldValue, $value, $allowNull);
} else {
$this->initReverseRelationship($value);
}
$this->primaryValue = $value && $value->isPersisted() ? $value->getValue('id') : null;
$this->value = $value;
}