コード例 #1
0
 public function testStaticRequest()
 {
     $Request = HttpKernel::getRequest();
     $this->assertInstanceOf('MOC\\V\\Core\\HttpKernel\\Component\\IBridgeInterface', $Request);
 }
コード例 #2
0
 /**
  * @return \MOC\V\Core\HttpKernel\Component\IBridgeInterface
  */
 public static function getRequest()
 {
     return HttpKernel::getRequest();
 }
コード例 #3
0
 /**
  * @param callable       $Controller
  * @param RouteParameter $Route
  *
  * @throws MissingParameterException
  * @return array
  */
 private function handleArguments($Controller, RouteParameter $Route)
 {
     $Reflection = new \ReflectionMethod($Controller[0], $Controller[1]);
     $MethodParameters = $Reflection->getParameters();
     $RequestParameters = HttpKernel::getRequest()->getParameterArray();
     $MethodArguments = array();
     /** @var \ReflectionParameter $MethodParameter */
     foreach ((array) $MethodParameters as $MethodParameter) {
         // @codeCoverageIgnoreStart
         if (array_key_exists($MethodParameter->name, $RequestParameters)) {
             $MethodArguments[] = $RequestParameters[$MethodParameter->name];
         } elseif (array_key_exists($MethodParameter->name, $Route->getParameterDefault())) {
             $MethodArguments[] = $Route->getParameterDefault($MethodParameter->name);
         } elseif ($MethodParameter->isDefaultValueAvailable()) {
             $MethodArguments[] = $MethodParameter->getDefaultValue();
         } else {
             throw new MissingParameterException($MethodParameter->name);
         }
         // @codeCoverageIgnoreEnd
     }
     return $MethodArguments;
 }