Skip to content

Commit

Permalink
fix: Prevent fatal error in case of virtual field
Browse files Browse the repository at this point in the history
  • Loading branch information
Nattfarinn committed Dec 20, 2023
1 parent e1f12b3 commit 6c6c4cf
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions eZ/Publish/API/Repository/Values/Content/Field.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ class Field extends ValueObject
/**
* The field id.
*
* @todo may be not needed
* Value of `null` indicates the field is virtual
* and is not persisted (yet).
*
* @var int
* @var int|null
*/
protected $id;

Expand Down Expand Up @@ -58,7 +59,7 @@ class Field extends ValueObject
*/
protected $fieldTypeIdentifier;

public function getId(): int
public function getId(): ?int
{
return $this->id;
}
Expand All @@ -85,4 +86,9 @@ public function getFieldTypeIdentifier(): string
{
return $this->fieldTypeIdentifier;
}

public function isVirtual(): bool
{
return null === $this->id;
}
}

0 comments on commit 6c6c4cf

Please sign in to comment.