From a6ad1c4b573d89718b9cfadfe4b5c949cf6c7adc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20S=C5=82omka?= Date: Wed, 9 Aug 2023 23:16:52 +0200 Subject: [PATCH] Refactored names --- .../Repository/NameSchema/NameSchemaServiceInterface.php | 4 ++-- src/lib/Repository/ContentService.php | 4 ++-- src/lib/Repository/Helper/NameSchemaService.php | 8 ++++---- src/lib/Repository/NameSchema/NameSchemaService.php | 8 ++------ tests/lib/Repository/NameSchema/NameSchemaServiceTest.php | 4 ++-- tests/lib/Repository/Service/Mock/ContentTest.php | 4 ++-- 6 files changed, 14 insertions(+), 18 deletions(-) diff --git a/src/contracts/Repository/NameSchema/NameSchemaServiceInterface.php b/src/contracts/Repository/NameSchema/NameSchemaServiceInterface.php index 1d27bb149e..ac7ba9fbe5 100644 --- a/src/contracts/Repository/NameSchema/NameSchemaServiceInterface.php +++ b/src/contracts/Repository/NameSchema/NameSchemaServiceInterface.php @@ -29,7 +29,7 @@ public function resolveUrlAliasSchema(Content $content, ContentType $contentType * * @return array */ - public function resolveNameSchema( + public function resolveContentNameSchema( Content $content, array $fieldMap = [], array $languageCodes = [], @@ -46,5 +46,5 @@ public function resolveNameSchema( * * @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException */ - public function resolve(string $nameSchema, ContentType $contentType, array $fieldMap, array $languageCodes): array; + public function resolveNameSchema(string $nameSchema, ContentType $contentType, array $fieldMap, array $languageCodes): array; } diff --git a/src/lib/Repository/ContentService.php b/src/lib/Repository/ContentService.php index 4efca508f1..dd0d6aa939 100644 --- a/src/lib/Repository/ContentService.php +++ b/src/lib/Repository/ContentService.php @@ -739,7 +739,7 @@ public function createContent(APIContentCreateStruct $contentCreateStruct, array $spiContentCreateStruct = new SPIContentCreateStruct( [ - 'name' => $this->nameSchemaService->resolve( + 'name' => $this->nameSchemaService->resolveNameSchema( $contentCreateStruct->contentType->nameSchema, $contentCreateStruct->contentType, $fieldValues, @@ -1406,7 +1406,7 @@ protected function internalUpdateContent( $spiContentUpdateStruct = new SPIContentUpdateStruct( [ - 'name' => $this->nameSchemaService->resolveNameSchema( + 'name' => $this->nameSchemaService->resolveContentNameSchema( $content, $fieldValues, $allLanguageCodes, diff --git a/src/lib/Repository/Helper/NameSchemaService.php b/src/lib/Repository/Helper/NameSchemaService.php index e847cc0a16..002b0179d7 100644 --- a/src/lib/Repository/Helper/NameSchemaService.php +++ b/src/lib/Repository/Helper/NameSchemaService.php @@ -20,7 +20,7 @@ public function resolveUrlAliasSchema(Content $content, ContentType $contentType { $contentType = $contentType ?? $content->getContentType(); - return $this->resolve( + return $this->resolveNameSchema( empty($contentType->urlAliasSchema) ? $contentType->nameSchema : $contentType->urlAliasSchema, $contentType, $content->fields, @@ -28,7 +28,7 @@ public function resolveUrlAliasSchema(Content $content, ContentType $contentType ); } - public function resolveNameSchema( + public function resolveContentNameSchema( Content $content, array $fieldMap = [], array $languageCodes = [], @@ -38,7 +38,7 @@ public function resolveNameSchema( $languageCodes = $languageCodes ?: $content->versionInfo->languageCodes; - return $this->resolve( + return $this->resolveNameSchema( $contentType->nameSchema, $contentType, $this->mergeFieldMap( @@ -50,7 +50,7 @@ public function resolveNameSchema( ); } - public function resolve(string $nameSchema, ContentType $contentType, array $fieldMap, array $languageCodes): array + public function resolveNameSchema(string $nameSchema, ContentType $contentType, array $fieldMap, array $languageCodes): array { [$filteredNameSchema, $groupLookupTable] = $this->filterNameSchema($nameSchema); $tokens = $this->extractTokens($filteredNameSchema); diff --git a/src/lib/Repository/NameSchema/NameSchemaService.php b/src/lib/Repository/NameSchema/NameSchemaService.php index 363c6041b3..89bbe32ef8 100644 --- a/src/lib/Repository/NameSchema/NameSchemaService.php +++ b/src/lib/Repository/NameSchema/NameSchemaService.php @@ -97,7 +97,7 @@ public function resolveUrlAliasSchema(Content $content, ContentType $contentType return $this->buildNames($event->getTokenValues(), $schemaName); } - public function resolveNameSchema( + public function resolveContentNameSchema( Content $content, array $fieldMap = [], array $languageCodes = [], @@ -119,11 +119,7 @@ public function resolveNameSchema( return $this->buildNames($event->getTokenValues(), $schemaName); } - public function resolveContentNameSchema() - { - } - - public function resolve( + public function resolveNameSchema( string $nameSchema, ContentType $contentType, array $fieldMap, diff --git a/tests/lib/Repository/NameSchema/NameSchemaServiceTest.php b/tests/lib/Repository/NameSchema/NameSchemaServiceTest.php index 368714886e..19813b391f 100644 --- a/tests/lib/Repository/NameSchema/NameSchemaServiceTest.php +++ b/tests/lib/Repository/NameSchema/NameSchemaServiceTest.php @@ -125,7 +125,7 @@ public function testResolveNameSchema(array $fieldMap, array $tokenValues, array $event ); - $result = $nameSchemaService->resolveNameSchema($content, $fieldMap, $languageCodes, $contentType); + $result = $nameSchemaService->resolveContentNameSchema($content, $fieldMap, $languageCodes, $contentType); self::assertEquals( $expectedNames, @@ -216,7 +216,7 @@ public function testResolve( $settings ); - $result = $nameSchemaService->resolve( + $result = $nameSchemaService->resolveNameSchema( $nameSchema, $contentType, $content->fields, diff --git a/tests/lib/Repository/Service/Mock/ContentTest.php b/tests/lib/Repository/Service/Mock/ContentTest.php index 5f6a4558c7..bea81d54d1 100644 --- a/tests/lib/Repository/Service/Mock/ContentTest.php +++ b/tests/lib/Repository/Service/Mock/ContentTest.php @@ -1406,7 +1406,7 @@ static function (ValueStub $value) { $languageCodes ); $nameSchemaServiceMock->expects(self::once()) - ->method('resolve') + ->method('resolveNameSchema') ->with( self::equalTo($contentType->nameSchema), self::equalTo($contentType), @@ -3462,7 +3462,7 @@ static function (SPIValue $value) use ($emptyValue) { $languageCodes ); $nameSchemaServiceMock->expects($this->once()) - ->method('resolveNameSchema') + ->method('resolveContentNameSchema') ->with( $this->equalTo($content), $this->equalTo($values),