-
-
Notifications
You must be signed in to change notification settings - Fork 39
/
CustomPostUnionTypeResolver.php
executable file
·69 lines (60 loc) · 2.75 KB
/
CustomPostUnionTypeResolver.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
<?php
declare(strict_types=1);
namespace PoPCMSSchema\CustomPosts\TypeResolvers\UnionType;
use PoP\ComponentModel\RelationalTypeDataLoaders\RelationalTypeDataLoaderInterface;
use PoP\ComponentModel\TypeResolvers\InterfaceType\InterfaceTypeResolverInterface;
use PoP\ComponentModel\TypeResolvers\UnionType\AbstractUnionTypeResolver;
use PoPCMSSchema\CustomPosts\RelationalTypeDataLoaders\UnionType\CustomPostUnionTypeDataLoader;
use PoPCMSSchema\CustomPosts\TypeResolvers\InterfaceType\CustomPostInterfaceTypeResolver;
class CustomPostUnionTypeResolver extends AbstractUnionTypeResolver
{
private ?CustomPostUnionTypeDataLoader $customPostUnionTypeDataLoader = null;
private ?CustomPostInterfaceTypeResolver $customPostInterfaceTypeResolver = null;
final public function setCustomPostUnionTypeDataLoader(CustomPostUnionTypeDataLoader $customPostUnionTypeDataLoader): void
{
$this->customPostUnionTypeDataLoader = $customPostUnionTypeDataLoader;
}
final protected function getCustomPostUnionTypeDataLoader(): CustomPostUnionTypeDataLoader
{
if ($this->customPostUnionTypeDataLoader === null) {
/** @var CustomPostUnionTypeDataLoader */
$customPostUnionTypeDataLoader = $this->instanceManager->getInstance(CustomPostUnionTypeDataLoader::class);
$this->customPostUnionTypeDataLoader = $customPostUnionTypeDataLoader;
}
return $this->customPostUnionTypeDataLoader;
}
final public function setCustomPostInterfaceTypeResolver(CustomPostInterfaceTypeResolver $customPostInterfaceTypeResolver): void
{
$this->customPostInterfaceTypeResolver = $customPostInterfaceTypeResolver;
}
final protected function getCustomPostInterfaceTypeResolver(): CustomPostInterfaceTypeResolver
{
if ($this->customPostInterfaceTypeResolver === null) {
/** @var CustomPostInterfaceTypeResolver */
$customPostInterfaceTypeResolver = $this->instanceManager->getInstance(CustomPostInterfaceTypeResolver::class);
$this->customPostInterfaceTypeResolver = $customPostInterfaceTypeResolver;
}
return $this->customPostInterfaceTypeResolver;
}
public function getTypeName(): string
{
return 'CustomPostUnion';
}
public function getTypeDescription(): ?string
{
return $this->__('Union of \'custom post\' type resolvers', 'customposts');
}
public function getRelationalTypeDataLoader(): RelationalTypeDataLoaderInterface
{
return $this->getCustomPostUnionTypeDataLoader();
}
/**
* @return InterfaceTypeResolverInterface[]
*/
public function getUnionTypeInterfaceTypeResolvers(): array
{
return [
$this->getCustomPostInterfaceTypeResolver(),
];
}
}