-
Notifications
You must be signed in to change notification settings - Fork 611
/
Address.php
74 lines (66 loc) · 2.15 KB
/
Address.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
/**
* @link https://craftcms.com/
* @copyright Copyright (c) Pixel & Tonic, Inc.
* @license https://craftcms.github.io/license/
*/
namespace craft\gql\arguments\elements;
use Craft;
use craft\base\GqlInlineFragmentFieldInterface;
use craft\elements\Address as AddressElement;
use craft\gql\base\ElementArguments;
use craft\gql\types\QueryArgument;
use GraphQL\Type\Definition\Type;
/**
* Class Address
*
* @author Pixel & Tonic, Inc. <support@pixelandtonic.com>
* @since 4.0.0
*/
class Address extends ElementArguments
{
/**
* @inheritdoc
*/
public static function getArguments(): array
{
return array_merge(parent::getArguments(), self::getContentArguments(), [
'ownerId' => [
'name' => 'ownerId',
'type' => Type::listOf(QueryArgument::getType()),
'description' => 'Narrows the query results based on the addresses’ owners.',
],
'countryCode' => [
'name' => 'countryCode',
'type' => Type::listOf(Type::string()),
'description' => 'Narrows the query results based on the addresses’ country codes.',
],
'administrativeArea' => [
'name' => 'administrativeArea',
'type' => Type::listOf(Type::string()),
'description' => 'Narrows the query results based on the addresses’ administrative areas.',
],
]);
}
/**
* @inheritdoc
*/
public static function getContentArguments(): array
{
$contentArguments = [];
$contentFields = Craft::$app->getFields()->getLayoutByType(AddressElement::class)->getCustomFields();
foreach ($contentFields as $contentField) {
if (!$contentField instanceof GqlInlineFragmentFieldInterface) {
$contentArguments[$contentField->handle] = $contentField->getContentGqlQueryArgumentType();
}
}
return array_merge(parent::getContentArguments(), $contentArguments);
}
/**
* @inheritdoc
*/
public static function getRevisionArguments(): array
{
return [];
}
}