Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IBX-6282: Added attributes support for generating name schema #257

Merged
merged 37 commits into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
aea8e35
Added attributes support for generating name schema
kisztof Aug 2, 2023
8a23adb
NameSchemaService refactored
kisztof Aug 7, 2023
2b7f420
Changed event structure
kisztof Aug 9, 2023
aca456e
Working solution
kisztof Aug 9, 2023
79cfd82
Fixex code style
kisztof Aug 9, 2023
18f881a
Fixed tests
kisztof Aug 9, 2023
8ea0147
Refactored names
kisztof Aug 9, 2023
db1140b
Fixed code styles
kisztof Aug 9, 2023
2d15853
Fixed code styles
kisztof Aug 9, 2023
c8fe208
Fixed bc
kisztof Aug 9, 2023
214d404
Added language mapping. Fixed tests
kisztof Aug 17, 2023
c447ca1
Fixed Content service
kisztof Aug 17, 2023
cf21465
Fixed name schema generation issue
kisztof Aug 21, 2023
68623ed
Fixes after review
kisztof Aug 22, 2023
893fe92
Fixed styling
kisztof Aug 24, 2023
cdbcde8
Small fixes
kisztof Aug 31, 2023
89acc4e
Fixed issue with ovewriting array key
kisztof Sep 6, 2023
7cfc523
PHP Stan
kisztof Sep 7, 2023
381ad75
Fixed PHPstan issues
kisztof Sep 8, 2023
1cbe919
Regenerated PHPstan baseline
kisztof Sep 8, 2023
8beb942
Regenerated phpstan-baseline.neon
Steveb-p Sep 8, 2023
b1abca7
Regenerated phpstan-baseline.neon
Steveb-p Sep 8, 2023
8d9bee9
Restored deleted files
kisztof Sep 8, 2023
ad47dfa
PHPStan fixes part2
kisztof Sep 11, 2023
bf5cbc1
Updated baseline
kisztof Sep 11, 2023
64ddabe
Fixed content update
kisztof Sep 11, 2023
2e4479c
Fixed languages issue
kisztof Sep 11, 2023
924bdbf
Update src/lib/Repository/NameSchema/NameSchemaService.php
kisztof Sep 13, 2023
d67ffb8
Update src/lib/Repository/EventSubscriber/NameSchemaSubscriber.php
kisztof Sep 13, 2023
e8ba486
Update src/contracts/Event/NameSchema/ResolveContentNameSchemaEvent.php
kisztof Sep 13, 2023
a5c2305
Update src/contracts/Event/NameSchema/ResolveUrlAliasSchemaEvent.php
kisztof Sep 13, 2023
c0da3c7
Changed exception origin
kisztof Sep 13, 2023
f80e64c
Implemented code review suggestions
kisztof Sep 13, 2023
2ac94ed
Update src/lib/Repository/EventSubscriber/NameSchemaSubscriber.php
kisztof Sep 14, 2023
0359960
Removed check if fieldmap is empty
kisztof Sep 14, 2023
b897063
Fixed an issue with overwriting values
kisztof Sep 18, 2023
426d20e
Fixed tests usues
kisztof Sep 18, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
126 changes: 3 additions & 123 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -5035,31 +5035,6 @@ parameters:
count: 1
path: src/contracts/Container/Encore/ConfigurationDumper.php

-
message: "#^Method Ibexa\\\\Contracts\\\\Core\\\\Event\\\\ResolveUrlAliasSchemaEvent\\:\\:__construct\\(\\) has parameter \\$schemaIdentifiers with no value type specified in iterable type array\\.$#"
count: 1
path: src/contracts/Event/ResolveUrlAliasSchemaEvent.php

-
message: "#^Method Ibexa\\\\Contracts\\\\Core\\\\Event\\\\ResolveUrlAliasSchemaEvent\\:\\:getSchemaIdentifiers\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: src/contracts/Event/ResolveUrlAliasSchemaEvent.php

-
message: "#^Method Ibexa\\\\Contracts\\\\Core\\\\Event\\\\ResolveUrlAliasSchemaEvent\\:\\:getTokenValues\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: src/contracts/Event/ResolveUrlAliasSchemaEvent.php

-
message: "#^Method Ibexa\\\\Contracts\\\\Core\\\\Event\\\\ResolveUrlAliasSchemaEvent\\:\\:setTokenValues\\(\\) has parameter \\$names with no value type specified in iterable type array\\.$#"
count: 1
path: src/contracts/Event/ResolveUrlAliasSchemaEvent.php

-
message: "#^Property Ibexa\\\\Contracts\\\\Core\\\\Event\\\\ResolveUrlAliasSchemaEvent\\:\\:\\$schemaIdentifiers type has no value type specified in iterable type array\\.$#"
count: 1
path: src/contracts/Event/ResolveUrlAliasSchemaEvent.php

-
message: "#^Method Ibexa\\\\Contracts\\\\Core\\\\FieldType\\\\BinaryBase\\\\PathGenerator\\:\\:getStoragePathForField\\(\\) has no return type specified\\.$#"
count: 1
Expand Down Expand Up @@ -7015,11 +6990,6 @@ parameters:
count: 1
path: src/contracts/Repository/LocationService.php

-
message: "#^Method Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\NameSchema\\\\NameSchemaServiceInterface\\:\\:resolveNameSchema\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: src/contracts/Repository/NameSchema/NameSchemaServiceInterface.php

-
message: "#^PHPDoc tag @param for parameter \\$objectStateGroupId with type mixed is not subtype of native type int\\.$#"
count: 1
Expand Down Expand Up @@ -20245,16 +20215,6 @@ parameters:
count: 1
path: src/lib/Repository/ContentService.php

-
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\\.$#"
count: 1
path: src/lib/Repository/ContentService.php

-
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\\.$#"
count: 1
path: src/lib/Repository/ContentService.php

-
message: "#^Parameter \\#3 \\$prioritizedLanguages of method Ibexa\\\\Core\\\\Repository\\\\Mapper\\\\ContentDomainMapper\\:\\:buildContentDomainObjectFromPersistence\\(\\) expects array\\<string\\>, array\\<string\\>\\|null given\\.$#"
count: 1
Expand Down Expand Up @@ -20336,12 +20296,12 @@ parameters:
path: src/lib/Repository/ContentTypeService.php

-
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\\.$#"
message: "#^Cannot access property \\$fieldTypeIdentifier on Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\ContentType\\\\FieldDefinition\\|null\\.$#"
count: 1
path: src/lib/Repository/EventSubscriber/NameSchemaSubscriber.php
path: src/lib/Repository/Helper/NameSchemaService.php

-
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\\.$#"
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\\.$#"
count: 1
path: src/lib/Repository/Helper/NameSchemaService.php

Expand Down Expand Up @@ -20645,16 +20605,6 @@ parameters:
count: 1
path: src/lib/Repository/Mapper/RoleDomainMapper.php

-
message: "#^Cannot access offset mixed on Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\Content\\\\Field\\.$#"
count: 1
path: src/lib/Repository/NameSchema/NameSchemaService.php

-
message: "#^Cannot access property \\$fieldTypeIdentifier on Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\ContentType\\\\FieldDefinition\\|null\\.$#"
count: 1
path: src/lib/Repository/NameSchema/NameSchemaService.php

-
message: "#^Method Ibexa\\\\Core\\\\Repository\\\\NameSchema\\\\NameSchemaService\\:\\:extractTokens\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
Expand All @@ -20665,26 +20615,6 @@ parameters:
count: 1
path: src/lib/Repository/NameSchema/NameSchemaService.php

-
message: "#^Method Ibexa\\\\Core\\\\Repository\\\\NameSchema\\\\NameSchemaService\\:\\:mergeFieldMap\\(\\) has parameter \\$fieldMap with no value type specified in iterable type array\\.$#"
count: 1
path: src/lib/Repository/NameSchema/NameSchemaService.php

-
message: "#^Method Ibexa\\\\Core\\\\Repository\\\\NameSchema\\\\NameSchemaService\\:\\:mergeFieldMap\\(\\) has parameter \\$languageCodes with no value type specified in iterable type array\\.$#"
count: 1
path: src/lib/Repository/NameSchema/NameSchemaService.php

-
message: "#^Method Ibexa\\\\Core\\\\Repository\\\\NameSchema\\\\NameSchemaService\\:\\:mergeFieldMap\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: src/lib/Repository/NameSchema/NameSchemaService.php

-
message: "#^Method Ibexa\\\\Core\\\\Repository\\\\NameSchema\\\\NameSchemaService\\:\\:resolveNameSchema\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: src/lib/Repository/NameSchema/NameSchemaService.php

-
message: "#^Method Ibexa\\\\Core\\\\Repository\\\\NameSchema\\\\NameSchemaService\\:\\:resolveToken\\(\\) has parameter \\$groupLookupTable with no value type specified in iterable type array\\.$#"
count: 1
Expand All @@ -20705,26 +20635,11 @@ parameters:
count: 1
path: src/lib/Repository/NameSchema/NameSchemaService.php

-
message: "#^Parameter \\#1 \\$value of method Ibexa\\\\Contracts\\\\Core\\\\FieldType\\\\FieldType\\:\\:getName\\(\\) expects Ibexa\\\\Contracts\\\\Core\\\\FieldType\\\\Value, string given\\.$#"
count: 1
path: src/lib/Repository/NameSchema/NameSchemaService.php

-
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\\.$#"
count: 1
path: src/lib/Repository/NameSchema/NameSchemaService.php

-
message: "#^Property Ibexa\\\\Core\\\\Repository\\\\NameSchema\\\\NameSchemaService\\:\\:\\$settings type has no value type specified in iterable type array\\.$#"
count: 1
path: src/lib/Repository/NameSchema/NameSchemaService.php

-
message: "#^Method Ibexa\\\\Core\\\\Repository\\\\NameSchema\\\\SchemaIdentifierExtractor\\:\\:extract\\(\\) should return array\\<string, array\\<string, string\\>\\> but returns array\\<string, array\\<int, string\\>\\>\\.$#"
count: 1
path: src/lib/Repository/NameSchema/SchemaIdentifierExtractor.php

-
message: "#^Parameter \\#1 \\$module of class Ibexa\\\\Core\\\\Base\\\\Exceptions\\\\UnauthorizedException constructor expects string, int\\<min, \\-1\\>\\|int\\<1, max\\> given\\.$#"
count: 1
Expand Down Expand Up @@ -58210,41 +58125,6 @@ parameters:
count: 2
path: tests/lib/Repository/Mapper/ContentLocationMapper/DecoratedLocationServiceTest.php

-
message: "#^Method Ibexa\\\\Tests\\\\Core\\\\Repository\\\\NameSchema\\\\NameSchemaServiceTest\\:\\:getDataForTestResolve\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: tests/lib/Repository/NameSchema/NameSchemaServiceTest.php

-
message: "#^Method Ibexa\\\\Tests\\\\Core\\\\Repository\\\\NameSchema\\\\NameSchemaServiceTest\\:\\:getDataForTestResolveNameSchema\\(\\) return type has no value type specified in iterable type iterable\\.$#"
count: 1
path: tests/lib/Repository/NameSchema/NameSchemaServiceTest.php

-
message: "#^Method Ibexa\\\\Tests\\\\Core\\\\Repository\\\\NameSchema\\\\NameSchemaServiceTest\\:\\:getEventDispatcherMock\\(\\) has parameter \\$tokenValues with no value type specified in iterable type array\\.$#"
count: 1
path: tests/lib/Repository/NameSchema/NameSchemaServiceTest.php

-
message: "#^Method Ibexa\\\\Tests\\\\Core\\\\Repository\\\\NameSchema\\\\NameSchemaServiceTest\\:\\:testResolve\\(\\) has parameter \\$settings with no value type specified in iterable type array\\.$#"
count: 1
path: tests/lib/Repository/NameSchema/NameSchemaServiceTest.php

-
message: "#^PHPDoc tag @return contains unresolvable type\\.$#"
count: 1
path: tests/lib/Repository/NameSchema/NameSchemaServiceTest.php

-
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\\.$#"
count: 4
path: tests/lib/Repository/NameSchema/NameSchemaServiceTest.php

-
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\\.$#"
count: 1
path: tests/lib/Repository/NameSchema/NameSchemaServiceTest.php

-
message: "#^Method Ibexa\\\\Tests\\\\Core\\\\Repository\\\\PHPUnitConstraint\\\\AllValidationErrorsOccur\\:\\:extractTranslatable\\(\\) has parameter \\$fieldErrors with no value type specified in iterable type array\\.$#"
count: 1
Expand Down
56 changes: 56 additions & 0 deletions src/contracts/Event/NameSchema/AbstractNameSchemaEvent.php
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;
}
}
52 changes: 52 additions & 0 deletions src/contracts/Event/NameSchema/AbstractSchemaEvent.php
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
Steveb-p marked this conversation as resolved.
Show resolved Hide resolved
{
return $this->schemaIdentifiers;
}
}
16 changes: 16 additions & 0 deletions src/contracts/Event/NameSchema/ContentAwareEventInterface.php
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 src/contracts/Event/NameSchema/ResolveContentNameSchemaEvent.php
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;
}
}
13 changes: 13 additions & 0 deletions src/contracts/Event/NameSchema/ResolveNameSchemaEvent.php
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
{
}
Loading
Loading