Skip to content

Commit

Permalink
Used DecoratingFieldDefinitionMapper for UrlFieldDefinitionMapper, re…
Browse files Browse the repository at this point in the history
…moved php 7.3 from github ci
  • Loading branch information
mateuszdebinski committed Jul 15, 2024
1 parent b278248 commit f0db3d6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 36 deletions.
1 change: 0 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ jobs:
fail-fast: false
matrix:
php:
- '7.3'
- '7.4'
- '8.0'
composer_options: [ "" ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,58 +6,46 @@
*/
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 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
);
}
$type = parent::mapToFieldValueType($fieldDefinition);
if (!$this->canMap($fieldDefinition)) {
return $type;
}

return $type;
}

public function mapToFieldValueResolver(FieldDefinition $fieldDefinition): string
{
return $this->innerMapper->mapToFieldValueResolver($fieldDefinition);
}
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
);
}

public function mapToFieldValueInputType(ContentType $contentType, FieldDefinition $fieldDefinition): ?string
{
return $this->innerMapper->mapToFieldValueInputType($contentType, $fieldDefinition);
return $type;
}

public function mapToFieldValueArgsBuilder(FieldDefinition $fieldDefinition): ?string
protected function getFieldTypeIdentifier(): string
{
return $this->innerMapper->mapToFieldValueArgsBuilder($fieldDefinition);
return self::FIELD_TYPE_IDENTIFIER;
}
}

0 comments on commit f0db3d6

Please sign in to comment.