-
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.
IBX-7603: A new flag has been introduced that generates a different s…
…chema for ezurl
- Loading branch information
1 parent
f616e1f
commit b278248
Showing
5 changed files
with
73 additions
and
4 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
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
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
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
63 changes: 63 additions & 0 deletions
63
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 |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php | ||
|
||
/** | ||
* @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\FieldDefinitionMapper; | ||
use eZ\Publish\API\Repository\Values\ContentType\ContentType; | ||
use eZ\Publish\API\Repository\Values\ContentType\FieldDefinition; | ||
|
||
class UrlFieldDefinitionMapper implements FieldDefinitionMapper | ||
{ | ||
private const FIELD_TYPE_IDENTIFIER = 'ezurl'; | ||
private FieldDefinitionMapper $innerMapper; | ||
private bool $shouldExtendUrlInputType; | ||
|
||
public function __construct(FieldDefinitionMapper $innerMapper, bool $shouldExtendUrlInputType) | ||
{ | ||
$this->innerMapper = $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 | ||
); | ||
} | ||
} | ||
|
||
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); | ||
} | ||
} |