Exemplo n.º 1
0
 /**
  * @return boolean
  */
 protected final function matchRequest(Request $request)
 {
     $match = false;
     if (!empty($this->hostname) && $this->hostname == $request->getHostname()) {
         $match = true;
     }
     if (!empty($this->uriPathPrefix)) {
         $match = strpos($request->getUri()->getPath(), $this->uriPathPrefix) === 0 ? true : false;
     }
     if ($match) {
         $this->isActive = true;
     }
     return $match;
 }
Exemplo n.º 2
0
 /**
  * @return boolean
  */
 public function matchRequest(Request $request)
 {
     $allowedMethods = $this->getAllowedHttpMethods();
     if (!empty($allowedMethods) && !in_array($request->getMethod(), $allowedMethods)) {
         return false;
     }
     $regExp = $this->getURIMatchRegExp();
     if (!empty($regExp)) {
         $matches = null;
         if (!$request->getUri()->matchUriPath($regExp, $matches)) {
             return false;
         }
         // Fill the URI input container with pattern matches
         array_shift($matches);
         $tmpArray = [];
         foreach ($matches as $itemKey => $itemValue) {
             if (is_integer($itemKey)) {
                 continue;
             }
             $tmpArray[$itemKey] = $itemValue;
         }
         $uriInput = $this->getApplication()->getRequest()->getURIInput();
         $uriInput->merge(Input::create($tmpArray));
         // set default placeholder value
         $routeAnnot = $this->getExtendableInstance()->getRouteAnnotation();
         if ($routeAnnot->hasDefaultItemValue()) {
             $itemValue = isset($matches[1]) ? $matches[1] : $routeAnnot->getDefaultItemValue();
             $uriInput->set($routeAnnot->getDefaultItemKey(), $itemValue);
         }
         return true;
     } else {
         return false;
     }
 }