1
|
|
|
<?php |
2
|
|
|
/******************************************************************************* |
3
|
|
|
* This file is part of the GraphQL Bundle package. |
4
|
|
|
* |
5
|
|
|
* (c) YnloUltratech <[email protected]> |
6
|
|
|
* |
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
8
|
|
|
* file that was distributed with this source code. |
9
|
|
|
******************************************************************************/ |
10
|
|
|
|
11
|
|
|
namespace Ynlo\GraphQLBundle\Definition\Plugin; |
12
|
|
|
|
13
|
|
|
use Ynlo\GraphQLBundle\Component\TaggedServices\TaggedServices; |
14
|
|
|
use Ynlo\GraphQLBundle\Component\TaggedServices\TagSpecification; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* GraphQLDefinitionPluginManager |
18
|
|
|
*/ |
19
|
|
|
class GraphQLDefinitionPluginManager |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* @var DefinitionPluginInterface[] |
23
|
|
|
*/ |
24
|
|
|
protected $extensions; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @var bool |
28
|
|
|
*/ |
29
|
|
|
protected $loaded = false; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @var TaggedServices |
33
|
|
|
*/ |
34
|
|
|
protected $taggedServices; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* ExtensionManager constructor. |
38
|
|
|
* |
39
|
|
|
* @param TaggedServices $taggedServices |
40
|
|
|
*/ |
41
|
|
|
public function __construct(TaggedServices $taggedServices) |
42
|
|
|
{ |
43
|
|
|
$this->taggedServices = $taggedServices; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @return array|DefinitionPluginInterface[] |
48
|
|
|
*/ |
49
|
|
|
public function getExtensions() |
50
|
|
|
{ |
51
|
|
|
if ($this->loaded) { |
52
|
|
|
return $this->extensions; |
53
|
|
|
} |
54
|
|
|
$this->extensions = []; |
55
|
|
|
|
56
|
|
|
/** @var TagSpecification $extensions */ |
57
|
|
|
$taggedServices = $this->taggedServices->findTaggedServices('graphql.definition_extension'); |
58
|
|
|
foreach ($taggedServices as $tagSpecification) { |
59
|
|
|
/** @var DefinitionPluginInterface $extension */ |
60
|
|
|
$extension = $tagSpecification->getService(); |
61
|
|
|
$this->extensions[$extension->getName()] = $extension; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
$this->loaded = true; |
65
|
|
|
|
66
|
|
|
return $this->extensions; |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
|