refactor: use unified service provider desing
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
@@ -40,6 +40,10 @@ abstract class CollectionMutableAbstract extends NodeMutableAbstract implements
|
||||
|
||||
// Copy all property values
|
||||
$this->properties->setLabel($value->getLabel());
|
||||
$this->properties->setDescription($value->getDescription());
|
||||
$this->properties->setRank($value->getRank());
|
||||
$this->properties->setVisibility($value->getVisibility());
|
||||
$this->properties->setColor($value->getColor());
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -20,22 +20,18 @@ use KTXF\Resource\Provider\Node\NodePropertiesBaseAbstract;
|
||||
*/
|
||||
abstract class CollectionPropertiesBaseAbstract extends NodePropertiesBaseAbstract implements CollectionPropertiesBaseInterface {
|
||||
|
||||
public const JSON_TYPE = CollectionPropertiesBaseInterface::JSON_TYPE;
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function content(): CollectionContent {
|
||||
$content = $this->data[self::PROPERTY_CONTENTS] ?? null;
|
||||
if ($content instanceof CollectionContent) {
|
||||
return $content;
|
||||
public function content(): array {
|
||||
$content = $this->data[self::PROPERTY_CONTENT] ?? null;
|
||||
if (is_array($content)) {
|
||||
return array_filter(array_map(function ($item) {
|
||||
return $item instanceof CollectionContent ? $item : CollectionContent::tryFrom($item);
|
||||
}, $content));
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
|
||||
if (is_string($content)) {
|
||||
return CollectionContent::tryFrom($content) ?? CollectionContent::Event;
|
||||
}
|
||||
|
||||
return CollectionContent::Event;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -55,8 +51,8 @@ abstract class CollectionPropertiesBaseAbstract extends NodePropertiesBaseAbstra
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getPriority(): ?int {
|
||||
return $this->data[self::PROPERTY_PRIORITY] ?? null;
|
||||
public function getRank(): ?int {
|
||||
return $this->data[self::PROPERTY_RANK] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -14,15 +14,22 @@ use KTXF\Resource\Provider\Node\NodePropertiesBaseInterface;
|
||||
interface CollectionPropertiesBaseInterface extends NodePropertiesBaseInterface {
|
||||
|
||||
public const JSON_TYPE = 'chrono:collection';
|
||||
public const PROPERTY_CONTENTS = 'content';
|
||||
public const PROPERTY_CONTENT = 'content';
|
||||
|
||||
public const PROPERTY_LABEL = 'label';
|
||||
public const PROPERTY_DESCRIPTION = 'description';
|
||||
public const PROPERTY_PRIORITY = 'priority';
|
||||
public const PROPERTY_RANK = 'rank';
|
||||
public const PROPERTY_VISIBILITY = 'visibility';
|
||||
public const PROPERTY_COLOR = 'color';
|
||||
|
||||
public function content(): CollectionContent;
|
||||
/**
|
||||
* Gets the content type of this collection
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @return CollectionContent[] Returns an array of content types, a single content type, or null if not set
|
||||
*/
|
||||
public function content(): array;
|
||||
|
||||
/**
|
||||
* Gets the human friendly name of this collection (e.g. Personal Calendar)
|
||||
@@ -39,11 +46,11 @@ interface CollectionPropertiesBaseInterface extends NodePropertiesBaseInterface
|
||||
public function getDescription(): ?string;
|
||||
|
||||
/**
|
||||
* Gets the priority of this collection
|
||||
* Gets the rank of this collection
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*/
|
||||
public function getPriority(): ?int;
|
||||
public function getRank(): ?int;
|
||||
|
||||
/**
|
||||
* Gets the visibility of this collection
|
||||
|
||||
@@ -48,8 +48,8 @@ abstract class CollectionPropertiesMutableAbstract extends CollectionPropertiesB
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setPriority(?int $value): static {
|
||||
$this->data[self::PROPERTY_PRIORITY] = $value;
|
||||
public function setRank(?int $value): static {
|
||||
$this->data[self::PROPERTY_RANK] = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,11 +30,11 @@ interface CollectionPropertiesMutableInterface extends CollectionPropertiesBaseI
|
||||
public function setDescription(?string $value): static;
|
||||
|
||||
/**
|
||||
* Sets the priority of this collection
|
||||
* Sets the rank of this collection
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*/
|
||||
public function setPriority(?int $value): static;
|
||||
public function setRank(?int $value): static;
|
||||
|
||||
/**
|
||||
* Sets the visibility of this collection
|
||||
|
||||
Reference in New Issue
Block a user