| @@ 101-124 (lines=24) @@ | ||
| 98 | $req = ['argv'=>$input->getArguments()]; |
|
| 99 | $requestArray = new ArrayAdaptor($req); |
|
| 100 | $inputs = []; |
|
| 101 | foreach ($this->paramMetas as $k=>$meta){ |
|
| 102 | if($meta->isPassedByReference){ |
|
| 103 | // param PassedByReference is used to output |
|
| 104 | continue; |
|
| 105 | } |
|
| 106 | $source = \JmesPath\search($meta->source, $requestArray); |
|
| 107 | if ($source !== null){ |
|
| 108 | $source = ArrayAdaptor::strip($source); |
|
| 109 | if($source instanceof ParameterBag){ |
|
| 110 | $source = $source->all(); |
|
| 111 | } |
|
| 112 | if($meta->container){ |
|
| 113 | $inputs[$meta->name] = $meta->container->make($source); |
|
| 114 | }else{ |
|
| 115 | $inputs[$meta->name] = $source; |
|
| 116 | } |
|
| 117 | if($meta->validation){ |
|
| 118 | $vld->rule($meta->validation, $meta->name); |
|
| 119 | } |
|
| 120 | }else{ |
|
| 121 | $meta->isOptional or \PhpBoot\abort(new \InvalidArgumentException("the parameter \"{$meta->source}\" is missing")); |
|
| 122 | $inputs[$meta->name] = $meta->default; |
|
| 123 | } |
|
| 124 | } |
|
| 125 | $vld = $vld->withData($inputs); |
|
| 126 | $vld->validate() or \PhpBoot\abort( |
|
| 127 | new \InvalidArgumentException( |
|
| @@ 35-58 (lines=24) @@ | ||
| 32 | $req = ['request'=>$request]; |
|
| 33 | $requestArray = new ArrayAdaptor($req); |
|
| 34 | $inputs = []; |
|
| 35 | foreach ($this->paramMetas as $k=>$meta){ |
|
| 36 | if($meta->isPassedByReference){ |
|
| 37 | // param PassedByReference is used to output |
|
| 38 | continue; |
|
| 39 | } |
|
| 40 | $source = \JmesPath\search($meta->source, $requestArray); |
|
| 41 | if ($source !== null){ |
|
| 42 | $source = ArrayAdaptor::strip($source); |
|
| 43 | if($source instanceof ParameterBag){ |
|
| 44 | $source = $source->all(); |
|
| 45 | } |
|
| 46 | if($meta->container){ |
|
| 47 | $inputs[$meta->name] = $meta->container->make($source); |
|
| 48 | }else{ |
|
| 49 | $inputs[$meta->name] = $source; |
|
| 50 | } |
|
| 51 | if($meta->validation){ |
|
| 52 | $vld->rule($meta->validation, $meta->name); |
|
| 53 | } |
|
| 54 | }else{ |
|
| 55 | $meta->isOptional or \PhpBoot\abort(new BadRequestHttpException("the parameter \"{$meta->source}\" is missing")); |
|
| 56 | $inputs[$meta->name] = $meta->default; |
|
| 57 | } |
|
| 58 | } |
|
| 59 | $vld = $vld->withData($inputs); |
|
| 60 | $vld->validate() or \PhpBoot\abort( |
|
| 61 | new \InvalidArgumentException( |
|