public function __set($name, $value)
{
$reflection = $this->getCurrentReflection();
$nativeSetter = $reflection->getSetter('set' . ucfirst($name));
if ($nativeSetter !== null) {
try {
$nativeSetter->invoke($this, $value);
return;
} catch (ReflectionException $e) {
throw new MemberAccessException("Cannot invoke native setter of property '{$name}' in entity " . get_called_class() . '.');
}
}
$property = $reflection->getEntityProperty($name);
if ($property === null) {
throw new MemberAccessException("Cannot access undefined property '{$name}' in entity " . get_called_class() . '.');
}
if (!$property->isWritable()) {
throw new MemberAccessException("Cannot write to read-only property '{$name}' in entity " . get_called_class() . '.');
}
$customSetter = $property->getSetter();
if ($customSetter !== null) {
if (!method_exists($this, $customSetter)) {
throw new InvalidMethodCallException("Missing setter method '{$customSetter}' in entity " . get_called_class() . '.');
}
$this->{$customSetter}($value);
return;
}
$this->set($property, $value);
}