Skip to content

Commit 3e143a0

Browse files
kisztofSteveb-palongosz
authored
IBX-6282: Added support for custom name schema attributes (#257)
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]>
1 parent dbaf4fd commit 3e143a0

20 files changed

+710
-380
lines changed

phpstan-baseline.neon

Lines changed: 3 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -5035,31 +5035,6 @@ parameters:
50355035
count: 1
50365036
path: src/contracts/Container/Encore/ConfigurationDumper.php
50375037

5038-
-
5039-
message: "#^Method Ibexa\\\\Contracts\\\\Core\\\\Event\\\\ResolveUrlAliasSchemaEvent\\:\\:__construct\\(\\) has parameter \\$schemaIdentifiers with no value type specified in iterable type array\\.$#"
5040-
count: 1
5041-
path: src/contracts/Event/ResolveUrlAliasSchemaEvent.php
5042-
5043-
-
5044-
message: "#^Method Ibexa\\\\Contracts\\\\Core\\\\Event\\\\ResolveUrlAliasSchemaEvent\\:\\:getSchemaIdentifiers\\(\\) return type has no value type specified in iterable type array\\.$#"
5045-
count: 1
5046-
path: src/contracts/Event/ResolveUrlAliasSchemaEvent.php
5047-
5048-
-
5049-
message: "#^Method Ibexa\\\\Contracts\\\\Core\\\\Event\\\\ResolveUrlAliasSchemaEvent\\:\\:getTokenValues\\(\\) return type has no value type specified in iterable type array\\.$#"
5050-
count: 1
5051-
path: src/contracts/Event/ResolveUrlAliasSchemaEvent.php
5052-
5053-
-
5054-
message: "#^Method Ibexa\\\\Contracts\\\\Core\\\\Event\\\\ResolveUrlAliasSchemaEvent\\:\\:setTokenValues\\(\\) has parameter \\$names with no value type specified in iterable type array\\.$#"
5055-
count: 1
5056-
path: src/contracts/Event/ResolveUrlAliasSchemaEvent.php
5057-
5058-
-
5059-
message: "#^Property Ibexa\\\\Contracts\\\\Core\\\\Event\\\\ResolveUrlAliasSchemaEvent\\:\\:\\$schemaIdentifiers type has no value type specified in iterable type array\\.$#"
5060-
count: 1
5061-
path: src/contracts/Event/ResolveUrlAliasSchemaEvent.php
5062-
50635038
-
50645039
message: "#^Method Ibexa\\\\Contracts\\\\Core\\\\FieldType\\\\BinaryBase\\\\PathGenerator\\:\\:getStoragePathForField\\(\\) has no return type specified\\.$#"
50655040
count: 1
@@ -7015,11 +6990,6 @@ parameters:
70156990
count: 1
70166991
path: src/contracts/Repository/LocationService.php
70176992

7018-
-
7019-
message: "#^Method Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\NameSchema\\\\NameSchemaServiceInterface\\:\\:resolveNameSchema\\(\\) return type has no value type specified in iterable type array\\.$#"
7020-
count: 1
7021-
path: src/contracts/Repository/NameSchema/NameSchemaServiceInterface.php
7022-
70236993
-
70246994
message: "#^PHPDoc tag @param for parameter \\$objectStateGroupId with type mixed is not subtype of native type int\\.$#"
70256995
count: 1
@@ -20245,16 +20215,6 @@ parameters:
2024520215
count: 1
2024620216
path: src/lib/Repository/ContentService.php
2024720217

20248-
-
20249-
message: "#^Parameter \\#2 \\$fieldMap of method Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\NameSchema\\\\NameSchemaServiceInterface\\:\\:resolveNameSchema\\(\\) expects array\\<string, array\\<string, string\\>\\>, array\\<int\\|string, array\\<string, Ibexa\\\\Contracts\\\\Core\\\\FieldType\\\\Value\\>\\> given\\.$#"
20250-
count: 1
20251-
path: src/lib/Repository/ContentService.php
20252-
20253-
-
20254-
message: "#^Parameter \\#3 \\$fieldMap of method Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\NameSchema\\\\NameSchemaServiceInterface\\:\\:resolve\\(\\) expects array\\<string, array\\<string, string\\>\\>, array\\<int\\|string, array\\<string, Ibexa\\\\Contracts\\\\Core\\\\FieldType\\\\Value\\>\\> given\\.$#"
20255-
count: 1
20256-
path: src/lib/Repository/ContentService.php
20257-
2025820218
-
2025920219
message: "#^Parameter \\#3 \\$prioritizedLanguages of method Ibexa\\\\Core\\\\Repository\\\\Mapper\\\\ContentDomainMapper\\:\\:buildContentDomainObjectFromPersistence\\(\\) expects array\\<string\\>, array\\<string\\>\\|null given\\.$#"
2026020220
count: 1
@@ -20336,12 +20296,12 @@ parameters:
2033620296
path: src/lib/Repository/ContentTypeService.php
2033720297

2033820298
-
20339-
message: "#^Parameter \\#1 \\$value of method Ibexa\\\\Contracts\\\\Core\\\\FieldType\\\\FieldType\\:\\:getName\\(\\) expects Ibexa\\\\Contracts\\\\Core\\\\FieldType\\\\Value, Ibexa\\\\Contracts\\\\Core\\\\FieldType\\\\Value\\|null given\\.$#"
20299+
message: "#^Cannot access property \\$fieldTypeIdentifier on Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\ContentType\\\\FieldDefinition\\|null\\.$#"
2034020300
count: 1
20341-
path: src/lib/Repository/EventSubscriber/NameSchemaSubscriber.php
20301+
path: src/lib/Repository/Helper/NameSchemaService.php
2034220302

2034320303
-
20344-
message: "#^Parameter \\#3 \\$fieldMap of method Ibexa\\\\Core\\\\Repository\\\\NameSchema\\\\NameSchemaService\\:\\:resolve\\(\\) expects array\\<string, array\\<string, string\\>\\>, array\\<Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\Content\\\\Field\\> given\\.$#"
20304+
message: "#^Parameter \\#2 \\$fieldDefinition of method Ibexa\\\\Contracts\\\\Core\\\\FieldType\\\\FieldType\\:\\:getName\\(\\) expects Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\ContentType\\\\FieldDefinition, Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\ContentType\\\\FieldDefinition\\|null given\\.$#"
2034520305
count: 1
2034620306
path: src/lib/Repository/Helper/NameSchemaService.php
2034720307

@@ -20645,16 +20605,6 @@ parameters:
2064520605
count: 1
2064620606
path: src/lib/Repository/Mapper/RoleDomainMapper.php
2064720607

20648-
-
20649-
message: "#^Cannot access offset mixed on Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\Content\\\\Field\\.$#"
20650-
count: 1
20651-
path: src/lib/Repository/NameSchema/NameSchemaService.php
20652-
20653-
-
20654-
message: "#^Cannot access property \\$fieldTypeIdentifier on Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\ContentType\\\\FieldDefinition\\|null\\.$#"
20655-
count: 1
20656-
path: src/lib/Repository/NameSchema/NameSchemaService.php
20657-
2065820608
-
2065920609
message: "#^Method Ibexa\\\\Core\\\\Repository\\\\NameSchema\\\\NameSchemaService\\:\\:extractTokens\\(\\) return type has no value type specified in iterable type array\\.$#"
2066020610
count: 1
@@ -20665,26 +20615,6 @@ parameters:
2066520615
count: 1
2066620616
path: src/lib/Repository/NameSchema/NameSchemaService.php
2066720617

20668-
-
20669-
message: "#^Method Ibexa\\\\Core\\\\Repository\\\\NameSchema\\\\NameSchemaService\\:\\:mergeFieldMap\\(\\) has parameter \\$fieldMap with no value type specified in iterable type array\\.$#"
20670-
count: 1
20671-
path: src/lib/Repository/NameSchema/NameSchemaService.php
20672-
20673-
-
20674-
message: "#^Method Ibexa\\\\Core\\\\Repository\\\\NameSchema\\\\NameSchemaService\\:\\:mergeFieldMap\\(\\) has parameter \\$languageCodes with no value type specified in iterable type array\\.$#"
20675-
count: 1
20676-
path: src/lib/Repository/NameSchema/NameSchemaService.php
20677-
20678-
-
20679-
message: "#^Method Ibexa\\\\Core\\\\Repository\\\\NameSchema\\\\NameSchemaService\\:\\:mergeFieldMap\\(\\) return type has no value type specified in iterable type array\\.$#"
20680-
count: 1
20681-
path: src/lib/Repository/NameSchema/NameSchemaService.php
20682-
20683-
-
20684-
message: "#^Method Ibexa\\\\Core\\\\Repository\\\\NameSchema\\\\NameSchemaService\\:\\:resolveNameSchema\\(\\) return type has no value type specified in iterable type array\\.$#"
20685-
count: 1
20686-
path: src/lib/Repository/NameSchema/NameSchemaService.php
20687-
2068820618
-
2068920619
message: "#^Method Ibexa\\\\Core\\\\Repository\\\\NameSchema\\\\NameSchemaService\\:\\:resolveToken\\(\\) has parameter \\$groupLookupTable with no value type specified in iterable type array\\.$#"
2069020620
count: 1
@@ -20705,26 +20635,11 @@ parameters:
2070520635
count: 1
2070620636
path: src/lib/Repository/NameSchema/NameSchemaService.php
2070720637

20708-
-
20709-
message: "#^Parameter \\#1 \\$value of method Ibexa\\\\Contracts\\\\Core\\\\FieldType\\\\FieldType\\:\\:getName\\(\\) expects Ibexa\\\\Contracts\\\\Core\\\\FieldType\\\\Value, string given\\.$#"
20710-
count: 1
20711-
path: src/lib/Repository/NameSchema/NameSchemaService.php
20712-
20713-
-
20714-
message: "#^Parameter \\#2 \\$fieldDefinition of method Ibexa\\\\Contracts\\\\Core\\\\FieldType\\\\FieldType\\:\\:getName\\(\\) expects Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\ContentType\\\\FieldDefinition, Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\ContentType\\\\FieldDefinition\\|null given\\.$#"
20715-
count: 1
20716-
path: src/lib/Repository/NameSchema/NameSchemaService.php
20717-
2071820638
-
2071920639
message: "#^Property Ibexa\\\\Core\\\\Repository\\\\NameSchema\\\\NameSchemaService\\:\\:\\$settings type has no value type specified in iterable type array\\.$#"
2072020640
count: 1
2072120641
path: src/lib/Repository/NameSchema/NameSchemaService.php
2072220642

20723-
-
20724-
message: "#^Method Ibexa\\\\Core\\\\Repository\\\\NameSchema\\\\SchemaIdentifierExtractor\\:\\:extract\\(\\) should return array\\<string, array\\<string, string\\>\\> but returns array\\<string, array\\<int, string\\>\\>\\.$#"
20725-
count: 1
20726-
path: src/lib/Repository/NameSchema/SchemaIdentifierExtractor.php
20727-
2072820643
-
2072920644
message: "#^Parameter \\#1 \\$module of class Ibexa\\\\Core\\\\Base\\\\Exceptions\\\\UnauthorizedException constructor expects string, int\\<min, \\-1\\>\\|int\\<1, max\\> given\\.$#"
2073020645
count: 1
@@ -58210,41 +58125,6 @@ parameters:
5821058125
count: 2
5821158126
path: tests/lib/Repository/Mapper/ContentLocationMapper/DecoratedLocationServiceTest.php
5821258127

58213-
-
58214-
message: "#^Method Ibexa\\\\Tests\\\\Core\\\\Repository\\\\NameSchema\\\\NameSchemaServiceTest\\:\\:getDataForTestResolve\\(\\) return type has no value type specified in iterable type array\\.$#"
58215-
count: 1
58216-
path: tests/lib/Repository/NameSchema/NameSchemaServiceTest.php
58217-
58218-
-
58219-
message: "#^Method Ibexa\\\\Tests\\\\Core\\\\Repository\\\\NameSchema\\\\NameSchemaServiceTest\\:\\:getDataForTestResolveNameSchema\\(\\) return type has no value type specified in iterable type iterable\\.$#"
58220-
count: 1
58221-
path: tests/lib/Repository/NameSchema/NameSchemaServiceTest.php
58222-
58223-
-
58224-
message: "#^Method Ibexa\\\\Tests\\\\Core\\\\Repository\\\\NameSchema\\\\NameSchemaServiceTest\\:\\:getEventDispatcherMock\\(\\) has parameter \\$tokenValues with no value type specified in iterable type array\\.$#"
58225-
count: 1
58226-
path: tests/lib/Repository/NameSchema/NameSchemaServiceTest.php
58227-
58228-
-
58229-
message: "#^Method Ibexa\\\\Tests\\\\Core\\\\Repository\\\\NameSchema\\\\NameSchemaServiceTest\\:\\:testResolve\\(\\) has parameter \\$settings with no value type specified in iterable type array\\.$#"
58230-
count: 1
58231-
path: tests/lib/Repository/NameSchema/NameSchemaServiceTest.php
58232-
58233-
-
58234-
message: "#^PHPDoc tag @return contains unresolvable type\\.$#"
58235-
count: 1
58236-
path: tests/lib/Repository/NameSchema/NameSchemaServiceTest.php
58237-
58238-
-
58239-
message: "#^Parameter \\#2 \\$content of method Ibexa\\\\Tests\\\\Core\\\\Repository\\\\NameSchema\\\\NameSchemaServiceTest\\:\\:buildNameSchemaService\\(\\) expects Ibexa\\\\Core\\\\Repository\\\\Values\\\\Content\\\\Content, Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\Content\\\\Content given\\.$#"
58240-
count: 4
58241-
path: tests/lib/Repository/NameSchema/NameSchemaServiceTest.php
58242-
58243-
-
58244-
message: "#^Parameter \\#3 \\$fieldMap of method Ibexa\\\\Core\\\\Repository\\\\NameSchema\\\\NameSchemaService\\:\\:resolve\\(\\) expects array\\<string, array\\<string, string\\>\\>, array\\<Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\Content\\\\Field\\> given\\.$#"
58245-
count: 1
58246-
path: tests/lib/Repository/NameSchema/NameSchemaServiceTest.php
58247-
5824858128
-
5824958129
message: "#^Method Ibexa\\\\Tests\\\\Core\\\\Repository\\\\PHPUnitConstraint\\\\AllValidationErrorsOccur\\:\\:extractTranslatable\\(\\) has parameter \\$fieldErrors with no value type specified in iterable type array\\.$#"
5825058130
count: 1
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?php
2+
3+
/**
4+
* @copyright Copyright (C) Ibexa AS. All rights reserved.
5+
* @license For full copyright and license information view LICENSE file distributed with this source code.
6+
*/
7+
declare(strict_types=1);
8+
9+
namespace Ibexa\Contracts\Core\Event\NameSchema;
10+
11+
use Ibexa\Contracts\Core\Repository\Values\ContentType\ContentType;
12+
13+
abstract class AbstractNameSchemaEvent extends AbstractSchemaEvent
14+
{
15+
private ContentType $contentType;
16+
17+
/** @var array<int|string, array<string, \Ibexa\Contracts\Core\FieldType\Value>> */
18+
private array $fieldMap;
19+
20+
/** @var array<string> */
21+
private array $languageCodes;
22+
23+
/**
24+
* @param array<string, array<int, string>> $schemaIdentifiers
25+
* @param array<int|string, array<string, \Ibexa\Contracts\Core\FieldType\Value>> $fieldMap
26+
* @param array<string> $languageCodes
27+
*/
28+
public function __construct(
29+
array $schemaIdentifiers,
30+
ContentType $contentType,
31+
array $fieldMap,
32+
array $languageCodes
33+
) {
34+
parent::__construct($schemaIdentifiers);
35+
$this->contentType = $contentType;
36+
$this->fieldMap = $fieldMap;
37+
$this->languageCodes = $languageCodes;
38+
}
39+
40+
public function getContentType(): ContentType
41+
{
42+
return $this->contentType;
43+
}
44+
45+
/** @return array<int|string, array<string, \Ibexa\Contracts\Core\FieldType\Value>> */
46+
public function getFieldMap(): array
47+
{
48+
return $this->fieldMap;
49+
}
50+
51+
/** @return array<string> */
52+
public function getLanguageCodes(): array
53+
{
54+
return $this->languageCodes;
55+
}
56+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?php
2+
3+
/**
4+
* @copyright Copyright (C) Ibexa AS. All rights reserved.
5+
* @license For full copyright and license information view LICENSE file distributed with this source code.
6+
*/
7+
declare(strict_types=1);
8+
9+
namespace Ibexa\Contracts\Core\Event\NameSchema;
10+
11+
use Symfony\Contracts\EventDispatcher\Event;
12+
13+
abstract class AbstractSchemaEvent extends Event
14+
{
15+
/** @var array<string, array<int, string>> */
16+
private array $schemaIdentifiers;
17+
18+
/** @var array<string, array<string, string>> */
19+
private array $tokenValues = [];
20+
21+
/**
22+
* @param array<string, array<int, string>> $schemaIdentifiers
23+
*/
24+
public function __construct(array $schemaIdentifiers)
25+
{
26+
$this->schemaIdentifiers = $schemaIdentifiers;
27+
}
28+
29+
/**
30+
* @return array<string, array<string, string>>
31+
*/
32+
final public function getTokenValues(): array
33+
{
34+
return $this->tokenValues;
35+
}
36+
37+
/**
38+
* @param array<string, array<string, string>> $names
39+
*/
40+
final public function setTokenValues(array $names): void
41+
{
42+
$this->tokenValues = $names;
43+
}
44+
45+
/**
46+
* @return array<string, array<int, string>>
47+
*/
48+
public function getSchemaIdentifiers(): array
49+
{
50+
return $this->schemaIdentifiers;
51+
}
52+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
/**
4+
* @copyright Copyright (C) Ibexa AS. All rights reserved.
5+
* @license For full copyright and license information view LICENSE file distributed with this source code.
6+
*/
7+
declare(strict_types=1);
8+
9+
namespace Ibexa\Contracts\Core\Event\NameSchema;
10+
11+
use Ibexa\Contracts\Core\Repository\Values\Content\Content;
12+
13+
interface ContentAwareEventInterface
14+
{
15+
public function getContent(): Content;
16+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
/**
4+
* @copyright Copyright (C) Ibexa AS. All rights reserved.
5+
* @license For full copyright and license information view LICENSE file distributed with this source code.
6+
*/
7+
declare(strict_types=1);
8+
9+
namespace Ibexa\Contracts\Core\Event\NameSchema;
10+
11+
use Ibexa\Contracts\Core\Repository\Values\Content\Content;
12+
use Ibexa\Contracts\Core\Repository\Values\ContentType\ContentType;
13+
14+
final class ResolveContentNameSchemaEvent extends AbstractNameSchemaEvent implements ContentAwareEventInterface
15+
{
16+
private Content $content;
17+
18+
/**
19+
* @param array<string, array<string>> $schemaIdentifiers
20+
* @param array<int|string, array<string, \Ibexa\Contracts\Core\FieldType\Value>> $fieldMap
21+
* @param array<string> $languageCodes
22+
*/
23+
public function __construct(
24+
Content $content,
25+
array $schemaIdentifiers,
26+
ContentType $contentType,
27+
array $fieldMap,
28+
array $languageCodes
29+
) {
30+
parent::__construct($schemaIdentifiers, $contentType, $fieldMap, $languageCodes);
31+
$this->content = $content;
32+
}
33+
34+
public function getContent(): Content
35+
{
36+
return $this->content;
37+
}
38+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
/**
4+
* @copyright Copyright (C) Ibexa AS. All rights reserved.
5+
* @license For full copyright and license information view LICENSE file distributed with this source code.
6+
*/
7+
declare(strict_types=1);
8+
9+
namespace Ibexa\Contracts\Core\Event\NameSchema;
10+
11+
final class ResolveNameSchemaEvent extends AbstractNameSchemaEvent
12+
{
13+
}

0 commit comments

Comments
 (0)