-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
For more details see https://issues.ibexa.co/browse/IBX-6282 and #257 Added support for custom attributes when generating content name schema. Key changes: * Added two new events: * `\Ibexa\Contracts\Core\Event\NameSchema\ResolveNameSchemaEvent` * `\Ibexa\Contracts\Core\Event\NameSchema\ResolveContentNameSchemaEvent` * Changed new `NameSchemaService` method names: * `resolve` => `resolveNameSchema` * `resolveNameSchema` => `resolveContentNameSchema` * Kept BC behavior on legacy `NameSchemaService` helper class --------- Co-Authored-By: Paweł Niedzielski <[email protected]> Co-Authored-By: Andrew Longosz <[email protected]>
- Loading branch information
1 parent
dbaf4fd
commit 3e143a0
Showing
20 changed files
with
710 additions
and
380 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
src/contracts/Event/NameSchema/AbstractNameSchemaEvent.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
|
||
/** | ||
* @copyright Copyright (C) Ibexa AS. All rights reserved. | ||
* @license For full copyright and license information view LICENSE file distributed with this source code. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Ibexa\Contracts\Core\Event\NameSchema; | ||
|
||
use Ibexa\Contracts\Core\Repository\Values\ContentType\ContentType; | ||
|
||
abstract class AbstractNameSchemaEvent extends AbstractSchemaEvent | ||
{ | ||
private ContentType $contentType; | ||
|
||
/** @var array<int|string, array<string, \Ibexa\Contracts\Core\FieldType\Value>> */ | ||
private array $fieldMap; | ||
|
||
/** @var array<string> */ | ||
private array $languageCodes; | ||
|
||
/** | ||
* @param array<string, array<int, string>> $schemaIdentifiers | ||
* @param array<int|string, array<string, \Ibexa\Contracts\Core\FieldType\Value>> $fieldMap | ||
* @param array<string> $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; | ||
} | ||
|
||
/** @return array<int|string, array<string, \Ibexa\Contracts\Core\FieldType\Value>> */ | ||
public function getFieldMap(): array | ||
{ | ||
return $this->fieldMap; | ||
} | ||
|
||
/** @return array<string> */ | ||
public function getLanguageCodes(): array | ||
{ | ||
return $this->languageCodes; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
/** | ||
* @copyright Copyright (C) Ibexa AS. All rights reserved. | ||
* @license For full copyright and license information view LICENSE file distributed with this source code. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Ibexa\Contracts\Core\Event\NameSchema; | ||
|
||
use Symfony\Contracts\EventDispatcher\Event; | ||
|
||
abstract class AbstractSchemaEvent extends Event | ||
{ | ||
/** @var array<string, array<int, string>> */ | ||
private array $schemaIdentifiers; | ||
|
||
/** @var array<string, array<string, string>> */ | ||
private array $tokenValues = []; | ||
|
||
/** | ||
* @param array<string, array<int, string>> $schemaIdentifiers | ||
*/ | ||
public function __construct(array $schemaIdentifiers) | ||
{ | ||
$this->schemaIdentifiers = $schemaIdentifiers; | ||
} | ||
|
||
/** | ||
* @return array<string, array<string, string>> | ||
*/ | ||
final public function getTokenValues(): array | ||
{ | ||
return $this->tokenValues; | ||
} | ||
|
||
/** | ||
* @param array<string, array<string, string>> $names | ||
*/ | ||
final public function setTokenValues(array $names): void | ||
{ | ||
$this->tokenValues = $names; | ||
} | ||
|
||
/** | ||
* @return array<string, array<int, string>> | ||
*/ | ||
public function getSchemaIdentifiers(): array | ||
{ | ||
return $this->schemaIdentifiers; | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/contracts/Event/NameSchema/ContentAwareEventInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
/** | ||
* @copyright Copyright (C) Ibexa AS. All rights reserved. | ||
* @license For full copyright and license information view LICENSE file distributed with this source code. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Ibexa\Contracts\Core\Event\NameSchema; | ||
|
||
use Ibexa\Contracts\Core\Repository\Values\Content\Content; | ||
|
||
interface ContentAwareEventInterface | ||
{ | ||
public function getContent(): Content; | ||
} |
38 changes: 38 additions & 0 deletions
38
src/contracts/Event/NameSchema/ResolveContentNameSchemaEvent.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
/** | ||
* @copyright Copyright (C) Ibexa AS. All rights reserved. | ||
* @license For full copyright and license information view LICENSE file distributed with this source code. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Ibexa\Contracts\Core\Event\NameSchema; | ||
|
||
use Ibexa\Contracts\Core\Repository\Values\Content\Content; | ||
use Ibexa\Contracts\Core\Repository\Values\ContentType\ContentType; | ||
|
||
final class ResolveContentNameSchemaEvent extends AbstractNameSchemaEvent implements ContentAwareEventInterface | ||
{ | ||
private Content $content; | ||
|
||
/** | ||
* @param array<string, array<string>> $schemaIdentifiers | ||
* @param array<int|string, array<string, \Ibexa\Contracts\Core\FieldType\Value>> $fieldMap | ||
* @param array<string> $languageCodes | ||
*/ | ||
public function __construct( | ||
Content $content, | ||
array $schemaIdentifiers, | ||
ContentType $contentType, | ||
array $fieldMap, | ||
array $languageCodes | ||
) { | ||
parent::__construct($schemaIdentifiers, $contentType, $fieldMap, $languageCodes); | ||
$this->content = $content; | ||
} | ||
|
||
public function getContent(): Content | ||
{ | ||
return $this->content; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
/** | ||
* @copyright Copyright (C) Ibexa AS. All rights reserved. | ||
* @license For full copyright and license information view LICENSE file distributed with this source code. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Ibexa\Contracts\Core\Event\NameSchema; | ||
|
||
final class ResolveNameSchemaEvent extends AbstractNameSchemaEvent | ||
{ | ||
} |
Oops, something went wrong.