Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
OutputMapper.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
7 
9 
15 
20 {
24  private $outputFactory;
25 
29  private $outputTypes;
30 
34  private $typeFactory;
35 
39  private $config;
40 
46  public function __construct(
47  OutputFactory $outputFactory,
48  TypeFactory $typeFactory,
49  ConfigInterface $config
50  ) {
51  $this->outputFactory = $outputFactory;
52  $this->config = $config;
53  $this->typeFactory = $typeFactory;
54  }
55 
63  public function getOutputType($typeName)
64  {
65  if (!isset($this->outputTypes[$typeName])) {
66  $configElement = $this->config->getConfigElement($typeName);
67  $this->outputTypes[$typeName] = $this->outputFactory->create($configElement);
68  if (!($this->outputTypes[$typeName] instanceof OutputTypeInterface)) {
69  throw new GraphQlInputException(
70  new Phrase("Type '{$typeName}' was requested but is not declared in the GraphQL schema.")
71  );
72  }
73  }
74 
75  return $this->outputTypes[$typeName];
76  }
77 }
$config
Definition: fraud_order.php:17
__construct(OutputFactory $outputFactory, TypeFactory $typeFactory, ConfigInterface $config)