diff --git a/src/Attributes/LodataProperty.php b/src/Attributes/LodataProperty.php index 63c5bd7db..67e8f6c44 100644 --- a/src/Attributes/LodataProperty.php +++ b/src/Attributes/LodataProperty.php @@ -6,6 +6,7 @@ use Flat3\Lodata\Annotation\Core\V1\Computed; use Flat3\Lodata\Annotation\Core\V1\Description; +use Flat3\Lodata\Annotation\Core\V1\Immutable; use Flat3\Lodata\DeclaredProperty; use Flat3\Lodata\EntitySet; use Flat3\Lodata\Property; @@ -18,6 +19,7 @@ abstract class LodataProperty protected ?string $source = null; protected bool $key = false; protected bool $computed = false; + protected bool $immutable = false; protected bool $nullable = true; protected ?int $maxLength = null; protected ?int $precision = null; @@ -38,13 +40,15 @@ public function __construct( $scale = null, $alternativeKey = false, $searchable = false, - $filterable = true + $filterable = true, + ?bool $immutable = false ) { $this->name = $name; $this->description = $description; $this->source = $source; $this->key = $key; $this->computed = $computed; + $this->immutable = $immutable; $this->nullable = $nullable; $this->maxLength = $maxLength; $this->precision = $precision; @@ -84,6 +88,11 @@ public function isComputed(): bool return $this->computed; } + public function isImmutable(): bool + { + return $this->immutable; + } + public function isNullable(): bool { return $this->nullable && !$this->key; @@ -158,6 +167,10 @@ public function addProperty(EntitySet $entitySet): Property $property->addAnnotation(new Computed); } + if ($this->isImmutable()) { + $property->addAnnotation(new Immutable); + } + if ($this->hasMaxLength()) { $property->setMaxLength($this->getMaxLength()); } @@ -178,4 +191,4 @@ public function addProperty(EntitySet $entitySet): Property } abstract public function getType(): Type; -} \ No newline at end of file +}