| @@ 95-118 (lines=24) @@ | ||
| 92 | $req = ['argv'=>$input->getArguments()]; |
|
| 93 | $requestArray = new ArrayAdaptor($req); |
|
| 94 | $inputs = []; |
|
| 95 | foreach ($this->paramMetas as $k=>$meta){ |
|
| 96 | if($meta->isPassedByReference){ |
|
| 97 | // param PassedByReference is used to output |
|
| 98 | continue; |
|
| 99 | } |
|
| 100 | $source = \JmesPath\search($meta->source, $requestArray); |
|
| 101 | if ($source !== null){ |
|
| 102 | $source = ArrayAdaptor::strip($source); |
|
| 103 | if($source instanceof ParameterBag){ |
|
| 104 | $source = $source->all(); |
|
| 105 | } |
|
| 106 | if($meta->container){ |
|
| 107 | $inputs[$meta->name] = $meta->container->make($source); |
|
| 108 | }else{ |
|
| 109 | $inputs[$meta->name] = $source; |
|
| 110 | } |
|
| 111 | if($meta->validation){ |
|
| 112 | $vld->rule($meta->validation, $meta->name); |
|
| 113 | } |
|
| 114 | }else{ |
|
| 115 | $meta->isOptional or \PhpBoot\abort(new \InvalidArgumentException("the parameter \"{$meta->source}\" is missing")); |
|
| 116 | $inputs[$meta->name] = $meta->default; |
|
| 117 | } |
|
| 118 | } |
|
| 119 | $vld = $vld->withData($inputs); |
|
| 120 | $vld->validate() or \PhpBoot\abort( |
|
| 121 | 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( |
|