diff --git a/src/contracts/Event/NameSchema/AbstractContentAwareNameSchemaEvent.php b/src/contracts/Event/NameSchema/AbstractContentAwareNameSchemaEvent.php deleted file mode 100644 index ab89ecba24..0000000000 --- a/src/contracts/Event/NameSchema/AbstractContentAwareNameSchemaEvent.php +++ /dev/null @@ -1,29 +0,0 @@ -content = $content; - } - - public function getContent(): Content - { - return $this->content; - } -} diff --git a/src/contracts/Event/NameSchema/AbstractNameSchemaEvent.php b/src/contracts/Event/NameSchema/AbstractNameSchemaEvent.php index 845e0ec540..3fffff5b9d 100644 --- a/src/contracts/Event/NameSchema/AbstractNameSchemaEvent.php +++ b/src/contracts/Event/NameSchema/AbstractNameSchemaEvent.php @@ -8,35 +8,40 @@ namespace Ibexa\Contracts\Core\Event\NameSchema; -use Symfony\Contracts\EventDispatcher\Event; +use Ibexa\Contracts\Core\Repository\Values\ContentType\ContentType; -abstract class AbstractNameSchemaEvent extends Event +abstract class AbstractNameSchemaEvent extends AbstractSchemaEvent { - /** @var array */ - protected array $schemaIdentifiers; - - /** - * @var array> - */ - protected array $tokenValues = []; - - public function __construct(array $schemaIdentifiers) - { - $this->schemaIdentifiers = $schemaIdentifiers; + private ContentType $contentType; + + private array $fieldMap; + + private array $languageCodes; + + public function __construct( + array $schemaIdentifiers, + ContentType $contentType, + array $fieldMap, + array $languageCodes + ) { + parent::__construct($schemaIdentifiers); + $this->contentType = $contentType; + $this->fieldMap = $fieldMap; + $this->languageCodes = $languageCodes; } - public function getTokenValues(): array + public function getContentType(): ContentType { - return $this->tokenValues; + return $this->contentType; } - public function setTokenValues(array $names): void + public function getFieldMap(): array { - $this->tokenValues = $names; + return $this->fieldMap; } - public function getSchemaIdentifiers(): array + public function getLanguageCodes(): array { - return $this->schemaIdentifiers; + return $this->languageCodes; } } diff --git a/src/contracts/Event/NameSchema/AbstractSchemaEvent.php b/src/contracts/Event/NameSchema/AbstractSchemaEvent.php new file mode 100644 index 0000000000..b1e890ad4d --- /dev/null +++ b/src/contracts/Event/NameSchema/AbstractSchemaEvent.php @@ -0,0 +1,40 @@ + */ + protected array $schemaIdentifiers; + + /** @var array> */ + protected array $tokenValues = []; + + public function __construct(array $schemaIdentifiers) + { + $this->schemaIdentifiers = $schemaIdentifiers; + } + + public function getTokenValues(): array + { + return $this->tokenValues; + } + + public function setTokenValues(array $names): void + { + $this->tokenValues = $names; + } + + public function getSchemaIdentifiers(): array + { + return $this->schemaIdentifiers; + } +} diff --git a/src/contracts/Event/NameSchema/ContentAwareEventInterface.php b/src/contracts/Event/NameSchema/ContentAwareEventInterface.php new file mode 100644 index 0000000000..e8e32c065d --- /dev/null +++ b/src/contracts/Event/NameSchema/ContentAwareEventInterface.php @@ -0,0 +1,15 @@ +content = $content; + } + + public function getContent(): Content + { + return $this->content; + } } diff --git a/src/contracts/Event/NameSchema/ResolveNameSchemaEvent.php b/src/contracts/Event/NameSchema/ResolveNameSchemaEvent.php index 4d42f3e9d5..1e047f8c6b 100644 --- a/src/contracts/Event/NameSchema/ResolveNameSchemaEvent.php +++ b/src/contracts/Event/NameSchema/ResolveNameSchemaEvent.php @@ -8,40 +8,7 @@ namespace Ibexa\Contracts\Core\Event\NameSchema; -use Ibexa\Contracts\Core\Repository\Values\ContentType\ContentType; - final class ResolveNameSchemaEvent extends AbstractNameSchemaEvent { - private ContentType $contentType; - - private array $fieldMap; - - private array $languageCodes; - - public function __construct( - array $schemaIdentifiers, - ContentType $contentType, - array $fieldMap, - array $languageCodes - ) { - parent::__construct($schemaIdentifiers); - $this->contentType = $contentType; - $this->fieldMap = $fieldMap; - $this->languageCodes = $languageCodes; - } - - public function getContentType(): ContentType - { - return $this->contentType; - } - - public function getFieldMap(): array - { - return $this->fieldMap; - } - public function getLanguageCodes(): array - { - return $this->languageCodes; - } } diff --git a/src/contracts/Event/NameSchema/ResolveUrlAliasSchemaEvent.php b/src/contracts/Event/NameSchema/ResolveUrlAliasSchemaEvent.php index 9e35a3cb97..051abf8fcd 100644 --- a/src/contracts/Event/NameSchema/ResolveUrlAliasSchemaEvent.php +++ b/src/contracts/Event/NameSchema/ResolveUrlAliasSchemaEvent.php @@ -8,6 +8,22 @@ namespace Ibexa\Contracts\Core\Event\NameSchema; -final class ResolveUrlAliasSchemaEvent extends AbstractContentAwareNameSchemaEvent +use Ibexa\Contracts\Core\Repository\Values\Content\Content; + +final class ResolveUrlAliasSchemaEvent extends AbstractSchemaEvent implements ContentAwareEventInterface { + protected Content $content; + + public function __construct( + array $schemaIdentifiers, + Content $content + ) { + parent::__construct($schemaIdentifiers); + $this->content = $content; + } + + public function getContent(): Content + { + return $this->content; + } } diff --git a/src/lib/Repository/NameSchema/NameSchemaService.php b/src/lib/Repository/NameSchema/NameSchemaService.php index 0a1d8534a1..7fc39c0d16 100644 --- a/src/lib/Repository/NameSchema/NameSchemaService.php +++ b/src/lib/Repository/NameSchema/NameSchemaService.php @@ -116,8 +116,16 @@ public function resolveNameSchema( return $this->buildNames($event->getTokenValues(), $schemaName); } - public function resolve(string $nameSchema, ContentType $contentType, array $fieldMap, array $languageCodes): array - { + public function resolveContentNameSchema(){ + + } + + public function resolve( + string $nameSchema, + ContentType $contentType, + array $fieldMap, + array $languageCodes + ): array { $schemaIdentifiers = $this->schemaIdentifierExtractor->extract($nameSchema); $event = $this->eventDispatcher->dispatch( new ResolveNameSchemaEvent(