-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
IBX-7603: Added missing subfield for ezurl
- Loading branch information
1 parent
cff568b
commit 7631350
Showing
4 changed files
with
73 additions
and
0 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
53 changes: 53 additions & 0 deletions
53
src/lib/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,53 @@ | ||
<?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\GraphQL\Schema\Domain\Content\Mapper\FieldDefinition; | ||
|
||
use Ibexa\Contracts\Core\Repository\Values\ContentType\FieldDefinition; | ||
use Ibexa\Contracts\GraphQL\Schema\Domain\Content\Mapper\FieldDefinition\FieldDefinitionMapper; | ||
|
||
final class UrlFieldDefinitionMapper extends DecoratingFieldDefinitionMapper implements FieldDefinitionMapper | ||
{ | ||
private const FIELD_TYPE_IDENTIFIER = 'ezurl'; | ||
|
||
private bool $shouldExtendUrlInputType; | ||
|
||
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; | ||
} | ||
|
||
if ($this->shouldExtendUrlInputType) { | ||
$type = 'UrlFieldValue'; | ||
} else { | ||
@trigger_error( | ||
'The return type `string` for the URL field has been deprecated since version 4.6 ' . | ||
'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; | ||
} | ||
|
||
protected function getFieldTypeIdentifier(): string | ||
{ | ||
return self::FIELD_TYPE_IDENTIFIER; | ||
} | ||
} |