getRequest() public method

public getRequest ( ) : Request
return Coduo\TuTu\Config\Element\Request
示例#1
0
 /**
  * @param Request $request
  * @param Element $config
  * @return bool
  */
 public function match(Request $request, Element $config)
 {
     if (!count($config->getRequest()->getAllowedMethods())) {
         return true;
     }
     return in_array($request->getMethod(), $config->getRequest()->getAllowedMethods(), true);
 }
示例#2
0
 /**
  * @param Request $request
  * @param Element $config
  * @return boolean
  */
 public function match(Request $request, Element $config)
 {
     if (!$config->getRequest()->hasBody()) {
         return true;
     }
     if (!$this->phpMatcher->match($request->getContent(), $config->getRequest()->getBody())) {
         return false;
     }
     return true;
 }
示例#3
0
 /**
  * @param Request $request
  * @param Element $config
  * @return bool
  */
 public function match(Request $request, Element $config)
 {
     $pathPattern = $config->getRequest()->getPath();
     preg_match_all('#\\{\\w+\\}#', $config->getRequest()->getPath(), $placeholders, PREG_OFFSET_CAPTURE | PREG_SET_ORDER);
     foreach ($placeholders as $placeholderMatch) {
         $placeholder = $placeholderMatch[0][0];
         $pathPattern = str_replace($placeholder, '__PLACEHOLDER__', $pathPattern);
     }
     $pathPattern = '/^' . str_replace('__PLACEHOLDER__', '([^\\/]*)', preg_quote($pathPattern, '/')) . '$/i';
     return 0 !== preg_match($pathPattern, $request->getPathInfo());
 }
示例#4
0
 /**
  * @param Request $request
  * @param Element $config
  * @return boolean
  */
 public function match(Request $request, Element $config)
 {
     if (!$config->getRequest()->hasHeaders()) {
         return true;
     }
     foreach ($config->getRequest()->getHeaders() as $headerName => $headerValuePattern) {
         if (!$request->headers->has($headerName)) {
             return false;
         }
         if (!$this->phpMatcher->match($request->headers->get($headerName), $headerValuePattern)) {
             return false;
         }
     }
     return true;
 }
示例#5
0
 /**
  * @param Request $request
  * @param Element $config
  * @return boolean
  */
 public function match(Request $request, Element $config)
 {
     if (!$config->getRequest()->hasBodyParameters() && !$config->getRequest()->hasQueryParameters()) {
         return true;
     }
     foreach ($config->getRequest()->getQueryParameters() as $name => $valuePattern) {
         if (!$request->query->has($name)) {
             return false;
         }
         if (!$this->phpMatcher->match($request->query->get($name), $valuePattern)) {
             return false;
         }
     }
     foreach ($config->getRequest()->getBodyParameters() as $name => $valuePattern) {
         if (!$request->request->has($name)) {
             return false;
         }
         if (!$this->phpMatcher->match($request->request->get($name), $valuePattern)) {
             return false;
         }
     }
     return true;
 }
示例#6
0
文件: Builder.php 项目: coduo/tutu
 /**
  * @param Element $config
  * @param Request $request
  * @return Response
  */
 public function build(Element $config, Request $request)
 {
     $content = $this->twig->render($config->getResponse()->getContent(), ['request' => $request, 'path' => $this->requestParser->extractPlaceholders($request, $config->getRequest()->getPath())]);
     return new Response($content, $config->getResponse()->getStatus(), $config->getResponse()->getHeaders());
 }