refactor: use unified service provider desing
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
@@ -11,19 +11,21 @@ namespace KTXF\Chrono\Service;
|
||||
|
||||
use KTXF\Chrono\Entity\EntityBaseInterface;
|
||||
use KTXF\Chrono\Entity\EntityMutableInterface;
|
||||
use KTXF\Chrono\Entity\EntityPropertiesMutableInterface;
|
||||
use KTXF\Resource\Identifier\CollectionIdentifierInterface;
|
||||
use KTXF\Resource\Identifier\EntityIdentifierInterface;
|
||||
|
||||
/**
|
||||
* Chrono Service Entity Mutable Interface
|
||||
* Service Entity Mutable Interface
|
||||
*
|
||||
* Optional interface for services that support entity CRUD operations.
|
||||
* Provides entity creation, modification, deletion, copying, moving, and flag management.
|
||||
* Optional interface for services that support entity CRUD operations
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*/
|
||||
interface ServiceEntityMutableInterface extends ServiceBaseInterface {
|
||||
interface ServiceEntityMutableInterface {
|
||||
|
||||
public const CAPABILITY_ENTITY_CREATE = 'EntityCreate';
|
||||
public const CAPABILITY_ENTITY_UPDATE = 'EntityUpdate';
|
||||
public const CAPABILITY_ENTITY_MODIFY = 'EntityModify';
|
||||
public const CAPABILITY_ENTITY_DELETE = 'EntityDelete';
|
||||
public const CAPABILITY_ENTITY_COPY = 'EntityCopy';
|
||||
public const CAPABILITY_ENTITY_MOVE = 'EntityMove';
|
||||
@@ -42,36 +44,71 @@ interface ServiceEntityMutableInterface extends ServiceBaseInterface {
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @param string|int $collection collection identifier
|
||||
* @param EntityMutableInterface $entity Entity data
|
||||
* @param array $options additional options
|
||||
* @param CollectionIdentifierInterface $target Target collection identifier
|
||||
* @param EntityPropertiesMutableInterface $properties Entity properties
|
||||
* @param array $options Additional options
|
||||
*
|
||||
* @return EntityBaseInterface Created entity
|
||||
*/
|
||||
public function entityCreate(string|int $collection, EntityMutableInterface $entity, array $options = []): EntityBaseInterface;
|
||||
public function entityCreate(CollectionIdentifierInterface $target, EntityPropertiesMutableInterface $properties, array $options = []): EntityBaseInterface;
|
||||
|
||||
/**
|
||||
* Modifies an existing entity
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @param string|int $collection Collection identifier
|
||||
* @param string|int $identifier Entity identifier
|
||||
* @param EntityMutableInterface $entity Entity data
|
||||
* @param EntityIdentifierInterface $target Target entity identifier
|
||||
* @param EntityPropertiesMutableInterface $properties Entity properties to update
|
||||
*
|
||||
* @return EntityBaseInterface Modified entity
|
||||
*/
|
||||
public function entityUpdate(string|int $collection, string|int $identifier, EntityMutableInterface $entity): EntityBaseInterface;
|
||||
public function entityModify(EntityIdentifierInterface $target, EntityPropertiesMutableInterface $properties): EntityBaseInterface;
|
||||
|
||||
/**
|
||||
* Deletes an existing entity in the specified collection
|
||||
* Deletes entities
|
||||
*
|
||||
* @since 2026.04.01
|
||||
*
|
||||
* @param EntityIdentifierInterface ...$targets Source entities to delete
|
||||
*
|
||||
* @return array<string, array{
|
||||
* disposition: 'moved'|'deleted'|'error',
|
||||
* destination: ?CollectionIdentifierInterface,
|
||||
* mutation: EntityIdentifierInterface
|
||||
* }> Results keyed by source entity identifier
|
||||
*/
|
||||
public function entityDelete(EntityIdentifierInterface ...$targets): array;
|
||||
|
||||
/**
|
||||
* Moves entities to another collection
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @param CollectionIdentifierInterface $target Target collection identifier
|
||||
* @param EntityIdentifierInterface ...$sources Source entities to move
|
||||
*
|
||||
* @return array<string, array{
|
||||
* disposition: 'moved'|'error',
|
||||
* destination: ?CollectionIdentifierInterface,
|
||||
* mutation: EntityIdentifierInterface
|
||||
* }> Results keyed by source entity identifier
|
||||
*/
|
||||
public function entityMove(CollectionIdentifierInterface $target, EntityIdentifierInterface ...$sources): array;
|
||||
|
||||
/**
|
||||
* Copies entities to another collection
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @param string|int $collection Collection identifier
|
||||
* @param string|int $identifier Entity identifier to delete
|
||||
* @param CollectionIdentifierInterface $target Target collection identifier
|
||||
* @param EntityIdentifierInterface ...$sources Source entities to copy
|
||||
*
|
||||
* @return EntityBaseInterface Deleted entity
|
||||
* @return array<string, array{
|
||||
* disposition: 'copied'|'error',
|
||||
* destination: ?CollectionIdentifierInterface,
|
||||
* mutation: EntityIdentifierInterface
|
||||
* }> Results keyed by source entity identifier
|
||||
*/
|
||||
public function entityDelete(string|int $collection, string|int $identifier): EntityBaseInterface;
|
||||
public function entityCopy(CollectionIdentifierInterface $target, EntityIdentifierInterface ...$sources): array;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user