Drest\Mapping\RouteMetaData::getRoutePattern PHP Method

getRoutePattern() public method

Get this routes route pattern
public getRoutePattern ( ) : string
return string $route_pattern
    public function getRoutePattern()
    {
        return $this->route_pattern;
    }

Usage Example

Beispiel #1
0
 /**
  * Get the regex pattern to match the request path
  * @param $basePath
  * @return string
  */
 protected function getMatchRegexPattern($basePath)
 {
     // Convert URL params into regex patterns, construct a regex for this route, init params
     $routePattern = is_null($basePath) ? (string) $this->routeMetaData->getRoutePattern() : '/' . $basePath . '/' . ltrim((string) $this->routeMetaData->getRoutePattern(), '/');
     $patternAsRegex = preg_replace_callback('#:([\\w]+)\\+?#', [$this, 'matchesCallback'], str_replace(')', ')?', $routePattern));
     if (substr($this->routeMetaData->getRoutePattern(), -1) === '/') {
         $patternAsRegex .= '?';
     }
     return $patternAsRegex;
 }