refactor: people interfaces to unified design
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
@@ -9,6 +9,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace KTXF\People\Entity;
|
||||
|
||||
use KTXF\Resource\Identifier\EntityIdentifier;
|
||||
use KTXF\Resource\Provider\Node\NodeBaseAbstract;
|
||||
|
||||
/**
|
||||
@@ -20,7 +21,12 @@ use KTXF\Resource\Provider\Node\NodeBaseAbstract;
|
||||
*/
|
||||
abstract class EntityBaseAbstract extends NodeBaseAbstract implements EntityBaseInterface {
|
||||
|
||||
protected EntityPropertiesBaseAbstract $properties;
|
||||
protected string $type = 'people:entity';
|
||||
protected EntityPropertiesBaseInterface $properties;
|
||||
|
||||
protected function nodeIdentifier(): EntityIdentifier {
|
||||
return new EntityIdentifier($this->data[static::PROPERTY_PROVIDER], $this->data[static::PROPERTY_SERVICE], $this->data[static::PROPERTY_COLLECTION], $this->data[static::PROPERTY_IDENTIFIER]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
|
||||
@@ -13,8 +13,6 @@ use KTXF\Resource\Provider\Node\NodeBaseInterface;
|
||||
|
||||
interface EntityBaseInterface extends NodeBaseInterface {
|
||||
|
||||
public const JSON_TYPE = 'people:entity';
|
||||
|
||||
/**
|
||||
* Gets the entity properties
|
||||
*
|
||||
|
||||
@@ -9,6 +9,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace KTXF\People\Entity;
|
||||
|
||||
use KTXF\Resource\Identifier\EntityIdentifier;
|
||||
use KTXF\Resource\Provider\Node\NodeMutableAbstract;
|
||||
use KTXF\Resource\Provider\Node\NodePropertiesMutableInterface;
|
||||
|
||||
@@ -21,9 +22,12 @@ use KTXF\Resource\Provider\Node\NodePropertiesMutableInterface;
|
||||
*/
|
||||
abstract class EntityMutableAbstract extends NodeMutableAbstract implements EntityMutableInterface {
|
||||
|
||||
public const JSON_TYPE = EntityMutableInterface::JSON_TYPE;
|
||||
protected string $type = 'people:entity';
|
||||
protected EntityPropertiesMutableInterface $properties;
|
||||
|
||||
protected EntityPropertiesMutableAbstract $properties;
|
||||
protected function nodeIdentifier(): EntityIdentifier {
|
||||
return new EntityIdentifier($this->data[static::PROPERTY_PROVIDER], $this->data[static::PROPERTY_SERVICE], (string) $this->data[static::PROPERTY_COLLECTION], (string) $this->data[static::PROPERTY_IDENTIFIER]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
@@ -40,7 +44,7 @@ abstract class EntityMutableAbstract extends NodeMutableAbstract implements Enti
|
||||
throw new \InvalidArgumentException('Properties must implement EntityPropertiesMutableInterface');
|
||||
}
|
||||
|
||||
$this->properties->setDataRaw($value->getDataRaw());
|
||||
$this->properties = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -16,8 +16,6 @@ use KTXF\Resource\Provider\Node\NodeMutableInterface;
|
||||
*/
|
||||
interface EntityMutableInterface extends EntityBaseInterface, NodeMutableInterface {
|
||||
|
||||
public const JSON_TYPE = EntityBaseInterface::JSON_TYPE;
|
||||
|
||||
/**
|
||||
* Gets the entity properties (mutable)
|
||||
*
|
||||
|
||||
@@ -13,8 +13,9 @@ use KTXF\Resource\Provider\Node\NodePropertiesBaseAbstract;
|
||||
|
||||
abstract class EntityPropertiesBaseAbstract extends NodePropertiesBaseAbstract implements EntityPropertiesBaseInterface {
|
||||
|
||||
public const JSON_TYPE = EntityPropertiesBaseInterface::JSON_TYPE;
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getDataRaw(): array|string|null {
|
||||
return $this->data[self::PROPERTY_DATA] ?? null;
|
||||
}
|
||||
|
||||
@@ -13,8 +13,6 @@ use KTXF\Resource\Provider\Node\NodePropertiesMutableInterface;
|
||||
|
||||
interface EntityPropertiesMutableInterface extends EntityPropertiesBaseInterface, NodePropertiesMutableInterface {
|
||||
|
||||
public const JSON_TYPE = EntityPropertiesBaseInterface::JSON_TYPE;
|
||||
|
||||
public function setDataRaw(array|string|null $value): static;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user