| @@ 22-47 (lines=26) @@ | ||
| 19 | /** |
|
| 20 | * Class ArgumentSystem |
|
| 21 | */ |
|
| 22 | class ArgumentSystem extends System |
|
| 23 | { |
|
| 24 | /** |
|
| 25 | * @param Definition|HasArguments $definition |
|
| 26 | * @param RuleInterface $ast |
|
| 27 | */ |
|
| 28 | public function resolve(Definition $definition, RuleInterface $ast): void |
|
| 29 | { |
|
| 30 | if ($ast instanceof ProvidesArgumentNodes) { |
|
| 31 | foreach ($ast->getArgumentNodes() as $child) { |
|
| 32 | $this->deferred(function () use ($definition, $child) { |
|
| 33 | /** @var Definition\Dependent\ArgumentDefinition $argument */ |
|
| 34 | $argument = $this->process->build($child, $definition); |
|
| 35 | ||
| 36 | $this->linker(function () use ($definition, $argument) { |
|
| 37 | if ($definition->hasArgument($argument->getName())) { |
|
| 38 | throw $this->redeclareException($argument); |
|
| 39 | } |
|
| 40 | ||
| 41 | $definition->withArgument($argument); |
|
| 42 | }); |
|
| 43 | }); |
|
| 44 | } |
|
| 45 | } |
|
| 46 | } |
|
| 47 | } |
|
| 48 | ||
| @@ 22-47 (lines=26) @@ | ||
| 19 | /** |
|
| 20 | * Class FieldSystem |
|
| 21 | */ |
|
| 22 | class FieldSystem extends System |
|
| 23 | { |
|
| 24 | /** |
|
| 25 | * @param Definition|HasFields $definition |
|
| 26 | * @param RuleInterface $ast |
|
| 27 | */ |
|
| 28 | public function resolve(Definition $definition, RuleInterface $ast): void |
|
| 29 | { |
|
| 30 | if ($ast instanceof ProvidesFieldNodes) { |
|
| 31 | foreach ($ast->getFieldNodes() as $child) { |
|
| 32 | $this->deferred(function () use ($definition, $child) { |
|
| 33 | /** @var Definition\Dependent\FieldDefinition $field */ |
|
| 34 | $field = $this->process->build($child, $definition); |
|
| 35 | ||
| 36 | $this->linker(function () use ($definition, $field) { |
|
| 37 | if ($definition->hasField($field->getName())) { |
|
| 38 | throw $this->redeclareException($field); |
|
| 39 | } |
|
| 40 | ||
| 41 | $definition->withField($field); |
|
| 42 | }); |
|
| 43 | }); |
|
| 44 | } |
|
| 45 | } |
|
| 46 | } |
|
| 47 | } |
|
| 48 | ||