class CompiledRoute

Same name in this branch

Description of CompiledRoute

Hierarchy

Expanded class hierarchy of CompiledRoute

File

drupal/core/lib/Drupal/Core/Routing/CompiledRoute.php, line 15
Definition of Drupal\Core\Routing\CompiledRoute.

Namespace

Drupal\Core\Routing
View source
class CompiledRoute {

  /**
   * The fitness of this route.
   *
   * @var int
   */
  protected $fit;

  /**
   * The pattern outline of this route.
   *
   * @var string
   */
  protected $patternOutline;

  /**
   * The number of parts in the path of this route.
   *
   * @var int
   */
  protected $numParts;

  /**
   * The Route object of which this object is the compiled version.
   *
   * @var Symfony\Component\Routing\Route
   */
  protected $route;

  /**
   * The regular expression to match placeholders out of this path.
   *
   * @var string
   */
  protected $regex;

  /**
   * Constructs a new CompiledRoute object.
   *
   * @param \Symfony\Component\Routing\Route $route
   *   A original Route instance.
   * @param int $fit
   *   The fitness of the route.
   * @param string $fit
   *   The pattern outline for this route.
   * @param int $num_parts
   *   The number of parts in the path.
   * @param string $regex
   *   The regular expression to match placeholders out of this path.
   */
  public function __construct(Route $route, $fit, $pattern_outline, $num_parts, $regex) {
    $this->route = $route;
    $this->fit = $fit;
    $this->patternOutline = $pattern_outline;
    $this->numParts = $num_parts;
    $this->regex = $regex;
  }

  /**
   * Returns the fit of this route.
   *
   * See RouteCompiler for a definition of how the fit is calculated.
   *
   * @return int
   *   The fit of the route.
   */
  public function getFit() {
    return $this->fit;
  }

  /**
   * Returns the number of parts in this route's path.
   *
   * The string "foo/bar/baz" has 3 parts, regardless of how many of them are
   * placeholders.
   *
   * @return int
   *   The number of parts in the path.
   */
  public function getNumParts() {
    return $this->numParts;
  }

  /**
   * Returns the pattern outline of this route.
   *
   * The pattern outline of a route is the path pattern of the route, but
   * normalized such that all placeholders are replaced with %.
   *
   * @return string
   *   The normalized path pattern.
   */
  public function getPatternOutline() {
    return $this->patternOutline;
  }

  /**
   * Returns the placeholder regex.
   *
   * @return string
   *   The regex to locate placeholders in this pattern.
   */
  public function getRegex() {
    return $this->regex;
  }

  /**
   * Returns the Route instance.
   *
   * @return Route
   *   A Route instance.
   */
  public function getRoute() {
    return $this->route;
  }

  /**
   * Returns the pattern.
   *
   * @return string
   *   The pattern.
   */
  public function getPattern() {
    return $this->route
      ->getPattern();
  }

  /**
   * Returns the options.
   *
   * @return array
   *   The options.
   */
  public function getOptions() {
    return $this->route
      ->getOptions();
  }

  /**
   * Returns the defaults.
   *
   * @return array
   *   The defaults.
   */
  public function getDefaults() {
    return $this->route
      ->getDefaults();
  }

  /**
   * Returns the requirements.
   *
   * @return array
   *   The requirements.
   */
  public function getRequirements() {
    return $this->route
      ->getRequirements();
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CompiledRoute::$fit protected property The fitness of this route.
CompiledRoute::$numParts protected property The number of parts in the path of this route.
CompiledRoute::$patternOutline protected property The pattern outline of this route.
CompiledRoute::$regex protected property The regular expression to match placeholders out of this path.
CompiledRoute::$route protected property The Route object of which this object is the compiled version.
CompiledRoute::getDefaults public function Returns the defaults.
CompiledRoute::getFit public function Returns the fit of this route.
CompiledRoute::getNumParts public function Returns the number of parts in this route's path.
CompiledRoute::getOptions public function Returns the options.
CompiledRoute::getPattern public function Returns the pattern.
CompiledRoute::getPatternOutline public function Returns the pattern outline of this route.
CompiledRoute::getRegex public function Returns the placeholder regex.
CompiledRoute::getRequirements public function Returns the requirements.
CompiledRoute::getRoute public function Returns the Route instance.
CompiledRoute::__construct public function Constructs a new CompiledRoute object.