refactor: use unified service provider desing
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user