| @@ 19-69 (lines=51) @@ | ||
| 16 | /** |
|
| 17 | * ExtensionManager |
|
| 18 | */ |
|
| 19 | class DefinitionExtensionManager |
|
| 20 | { |
|
| 21 | /** |
|
| 22 | * @var DefinitionExtensionInterface[] |
|
| 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|DefinitionExtensionInterface[] |
|
| 48 | */ |
|
| 49 | public function getExtensions() |
|
| 50 | { |
|
| 51 | if ($this->loaded) { |
|
| 52 | return $this->extensions; |
|
| 53 | ||
| 54 | } |
|
| 55 | $this->extensions = []; |
|
| 56 | ||
| 57 | /** @var TagSpecification $extensions */ |
|
| 58 | $taggedServices = $this->taggedServices->findTaggedServices('graphql.definition_extension'); |
|
| 59 | foreach ($taggedServices as $tagSpecification) { |
|
| 60 | /** @var DefinitionExtensionInterface $extension */ |
|
| 61 | $extension = $tagSpecification->getService(); |
|
| 62 | $this->extensions[$extension->getName()] = $extension; |
|
| 63 | } |
|
| 64 | ||
| 65 | $this->loaded = true; |
|
| 66 | ||
| 67 | return $this->extensions; |
|
| 68 | } |
|
| 69 | } |
|
| 70 | ||
| @@ 19-69 (lines=51) @@ | ||
| 16 | /** |
|
| 17 | * ExtensionManager |
|
| 18 | */ |
|
| 19 | class ExtensionManager |
|
| 20 | { |
|
| 21 | /** |
|
| 22 | * @var GraphQLExtensionInterface[] |
|
| 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|GraphQLExtensionInterface[] |
|
| 48 | */ |
|
| 49 | public function getExtensions() |
|
| 50 | { |
|
| 51 | if ($this->loaded) { |
|
| 52 | return $this->extensions; |
|
| 53 | ||
| 54 | } |
|
| 55 | $this->extensions = []; |
|
| 56 | ||
| 57 | /** @var TagSpecification $extensions */ |
|
| 58 | $taggedServices = $this->taggedServices->findTaggedServices('graphql.extension'); |
|
| 59 | foreach ($taggedServices as $tagSpecification) { |
|
| 60 | /** @var GraphQLExtensionInterface $extension */ |
|
| 61 | $extension = $tagSpecification->getService(); |
|
| 62 | $this->extensions[] = $extension; |
|
| 63 | } |
|
| 64 | ||
| 65 | $this->loaded = true; |
|
| 66 | ||
| 67 | return $this->extensions; |
|
| 68 | } |
|
| 69 | } |
|
| 70 | ||