-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Used DecoratingFieldDefinitionMapper for UrlFieldDefinitionMapper, re…
…moved php 7.3 from github ci
- Loading branch information
1 parent
b278248
commit 54e7437
Showing
2 changed files
with
27 additions
and
42 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,7 +42,6 @@ jobs: | |
fail-fast: false | ||
matrix: | ||
php: | ||
- '7.3' | ||
- '7.4' | ||
- '8.0' | ||
composer_options: [ "" ] | ||
|
68 changes: 27 additions & 41 deletions
68
src/Schema/Domain/Content/Mapper/FieldDefinition/UrlFieldDefinitionMapper.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 |
---|---|---|
@@ -1,63 +1,49 @@ | ||
<?php | ||
Check warning on line 1 in src/Schema/Domain/Content/Mapper/FieldDefinition/UrlFieldDefinitionMapper.php GitHub Actions / Run code style check (8.0)
Check warning on line 1 in src/Schema/Domain/Content/Mapper/FieldDefinition/UrlFieldDefinitionMapper.php GitHub Actions / Run code style check (8.0)
Check warning on line 1 in src/Schema/Domain/Content/Mapper/FieldDefinition/UrlFieldDefinitionMapper.php GitHub Actions / Run code style check (8.0)
|
||
|
||
/** | ||
* @copyright Copyright (C) eZ Systems AS. All rights reserved. | ||
* @license For full copyright and license information view LICENSE file distributed with this source code. | ||
*/ | ||
|
||
namespace Ibexa\GraphQL\Schema\Domain\Content\Mapper\FieldDefinition; | ||
|
||
use EzSystems\EzPlatformGraphQL\Schema\Domain\Content\Mapper\FieldDefinition\DecoratingFieldDefinitionMapper; | ||
use EzSystems\EzPlatformGraphQL\Schema\Domain\Content\Mapper\FieldDefinition\FieldDefinitionMapper; | ||
use eZ\Publish\API\Repository\Values\ContentType\ContentType; | ||
use eZ\Publish\API\Repository\Values\ContentType\FieldDefinition; | ||
|
||
class UrlFieldDefinitionMapper implements FieldDefinitionMapper | ||
class UrlFieldDefinitionMapper extends DecoratingFieldDefinitionMapper implements FieldDefinitionMapper | ||
{ | ||
private const FIELD_TYPE_IDENTIFIER = 'ezurl'; | ||
private FieldDefinitionMapper $innerMapper; | ||
private bool $shouldExtendUrlInputType; | ||
|
||
public function __construct(FieldDefinitionMapper $innerMapper, bool $shouldExtendUrlInputType) | ||
{ | ||
$this->innerMapper = $innerMapper; | ||
|
||
public function __construct( | ||
FieldDefinitionMapper $innerMapper, | ||
bool $shouldExtendUrlInputType | ||
) { | ||
parent::__construct($innerMapper); | ||
$this->shouldExtendUrlInputType = $shouldExtendUrlInputType; | ||
} | ||
|
||
public function mapToFieldValueType(FieldDefinition $fieldDefinition): string { | ||
$type = parent::mapToFieldValueType($fieldDefinition); | ||
if (!$this->canMap($fieldDefinition)) { | ||
return $type; | ||
} | ||
|
||
public function mapToFieldDefinitionType(FieldDefinition $fieldDefinition): string | ||
{ | ||
return $this->innerMapper->mapToFieldDefinitionType($fieldDefinition); | ||
} | ||
|
||
public function mapToFieldValueType(FieldDefinition $fieldDefinition): string | ||
{ | ||
$type = $this->innerMapper->mapToFieldValueType($fieldDefinition); | ||
if ($fieldDefinition->fieldTypeIdentifier === self::FIELD_TYPE_IDENTIFIER) { | ||
if ($this->shouldExtendUrlInputType) { | ||
$type = 'UrlFieldValue'; | ||
} else { | ||
@trigger_error( | ||
'The return type `string` for the URL field has been deprecated since version 3.3 ' . | ||
'and will be removed in version 5.0. To start receiving `UrlFieldInput` instead of the deprecated ' . | ||
'`string`, set the parameter `ibexa.graphql.schema.should.extend.ezurl` to `true`.', | ||
E_USER_DEPRECATED | ||
); | ||
} | ||
if ($this->shouldExtendUrlInputType) { | ||
$type = 'UrlFieldValue'; | ||
} else { | ||
@trigger_error( | ||
'The return type `string` for the URL field has been deprecated since version 3.3 '. | ||
'and will be removed in version 5.0. To start receiving `UrlFieldInput` instead of the deprecated '. | ||
'`string`, set the parameter `ibexa.graphql.schema.should.extend.ezurl` to `true`.', | ||
E_USER_DEPRECATED | ||
); | ||
} | ||
|
||
return $type; | ||
} | ||
|
||
public function mapToFieldValueResolver(FieldDefinition $fieldDefinition): string | ||
{ | ||
return $this->innerMapper->mapToFieldValueResolver($fieldDefinition); | ||
} | ||
|
||
public function mapToFieldValueInputType(ContentType $contentType, FieldDefinition $fieldDefinition): ?string | ||
{ | ||
return $this->innerMapper->mapToFieldValueInputType($contentType, $fieldDefinition); | ||
} | ||
|
||
public function mapToFieldValueArgsBuilder(FieldDefinition $fieldDefinition): ?string | ||
{ | ||
return $this->innerMapper->mapToFieldValueArgsBuilder($fieldDefinition); | ||
|
||
protected function getFieldTypeIdentifier(): string { | ||
return self::FIELD_TYPE_IDENTIFIER; | ||
} | ||
} |