| @@ -9,8 +9,11 @@ | ||
| 9 | 9 | { |
| 10 | 10 | private $input; |
| 11 | 11 | private $output; |
| 12 | 12 | private $errors; |
| 13 | + private $staticContextParams = []; | |
| 14 | + private $contextParams; | |
| 15 | + private $operationContextParams = []; | |
| 13 | 16 | public function __construct(array $definition, ShapeMap $shapeMap) |
| 14 | 17 | { |
| 15 | 18 | $definition['type'] = 'structure'; |
| 16 | 19 | if (!isset($definition['http']['method'])) { |
| @@ -18,9 +21,16 @@ | ||
| 18 | 21 | } |
| 19 | 22 | if (!isset($definition['http']['requestUri'])) { |
| 20 | 23 | $definition['http']['requestUri'] = '/'; |
| 21 | 24 | } |
| 25 | + if (isset($definition['staticContextParams'])) { | |
| 26 | + $this->staticContextParams = $definition['staticContextParams']; | |
| 27 | + } | |
| 28 | + if (isset($definition['operationContextParams'])) { | |
| 29 | + $this->operationContextParams = $definition['operationContextParams']; | |
| 30 | + } | |
| 22 | 31 | parent::__construct($definition, $shapeMap); |
| 32 | + $this->contextParams = $this->setContextParams(); | |
| 23 | 33 | } |
| 24 | 34 | /** |
| 25 | 35 | * Returns an associative array of the HTTP attribute of the operation: |
| 26 | 36 | * |
| @@ -82,6 +92,47 @@ | ||
| 82 | 92 | $this->errors = []; |
| 83 | 93 | } |
| 84 | 94 | } |
| 85 | 95 | return $this->errors; |
| 96 | + } | |
| 97 | + /** | |
| 98 | + * Gets static modeled static values used for | |
| 99 | + * endpoint resolution. | |
| 100 | + * | |
| 101 | + * @return array | |
| 102 | + */ | |
| 103 | + public function getStaticContextParams() | |
| 104 | + { | |
| 105 | + return $this->staticContextParams; | |
| 106 | + } | |
| 107 | + /** | |
| 108 | + * Gets definition of modeled dynamic values used | |
| 109 | + * for endpoint resolution | |
| 110 | + * | |
| 111 | + * @return array | |
| 112 | + */ | |
| 113 | + public function getContextParams() | |
| 114 | + { | |
| 115 | + return $this->contextParams; | |
| 116 | + } | |
| 117 | + /** | |
| 118 | + * Gets definition of modeled dynamic values used | |
| 119 | + * for endpoint resolution | |
| 120 | + * | |
| 121 | + * @return array | |
| 122 | + */ | |
| 123 | + public function getOperationContextParams() : array | |
| 124 | + { | |
| 125 | + return $this->operationContextParams; | |
| 126 | + } | |
| 127 | + private function setContextParams() | |
| 128 | + { | |
| 129 | + $members = $this->getInput()->getMembers(); | |
| 130 | + $contextParams = []; | |
| 131 | + foreach ($members as $name => $shape) { | |
| 132 | + if (!empty($contextParam = $shape->getContextParam())) { | |
| 133 | + $contextParams[$contextParam['name']] = ['shape' => $name, 'type' => $shape->getType()]; | |
| 134 | + } | |
| 135 | + } | |
| 136 | + return $contextParams; | |
| 86 | 137 | } |
| 87 | 138 | } |