You are here

class CompiledRoute in Zircon Profile 8

Same name in this branch
  1. 8 vendor/symfony/routing/CompiledRoute.php \Symfony\Component\Routing\CompiledRoute
  2. 8 core/lib/Drupal/Core/Routing/CompiledRoute.php \Drupal\Core\Routing\CompiledRoute
Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Core/Routing/CompiledRoute.php \Drupal\Core\Routing\CompiledRoute

A compiled route contains derived information from a route object.

Hierarchy

  • class \Symfony\Component\Routing\CompiledRoute implements \Symfony\Component\Routing\Serializable

Expanded class hierarchy of CompiledRoute

File

core/lib/Drupal/Core/Routing/CompiledRoute.php, line 15
Contains \Drupal\Core\Routing\CompiledRoute.

Namespace

Drupal\Core\Routing
View source
class CompiledRoute extends SymfonyCompiledRoute {

  /**
   * 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;

  /**
   * Constructs a new compiled route object.
   *
   * This is a ridiculously long set of constructor parameters, but as this
   * object is little more than a collection of values it's not a serious
   * problem. The parent Symfony class does the same, as well, making it
   * difficult to override differently.
   *
   * @param int $fit
   *   The fitness of the route.
   * @param string $pattern_outline
   *   The pattern outline for this route.
   * @param int $num_parts
   *   The number of parts in the path.
   * @param string $staticPrefix
   *   The static prefix of the compiled route
   * @param string $regex
   *   The regular expression to use to match this route
   * @param array $tokens
   *   An array of tokens to use to generate URL for this route
   * @param array $pathVariables
   *   An array of path variables
   * @param string|null $hostRegex
   *   Host regex
   * @param array $hostTokens
   *   Host tokens
   * @param array $hostVariables
   *   An array of host variables
   * @param array $variables
   *   An array of variables (variables defined in the path and in the host patterns)
   */
  public function __construct($fit, $pattern_outline, $num_parts, $staticPrefix, $regex, array $tokens, array $pathVariables, $hostRegex = null, array $hostTokens = array(), array $hostVariables = array(), array $variables = array()) {
    parent::__construct($staticPrefix, $regex, $tokens, $pathVariables, $hostRegex, $hostTokens, $hostVariables, $variables);
    $this->fit = $fit;
    $this->patternOutline = $pattern_outline;
    $this->numParts = $num_parts;
  }

  /**
   * 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 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();
  }

  /**
   * {@inheritdoc}
   */
  public function serialize() {

    // Calling the parent method is safer than trying to optimize out the extra
    // function calls.
    $data = unserialize(parent::serialize());
    $data['fit'] = $this->fit;
    $data['patternOutline'] = $this->patternOutline;
    $data['numParts'] = $this->numParts;
    return serialize($data);
  }

  /**
   * {@inheritdoc}
   */
  public function unserialize($serialized) {
    parent::unserialize($serialized);
    $data = unserialize($serialized);
    $this->fit = $data['fit'];
    $this->patternOutline = $data['patternOutline'];
    $this->numParts = $data['numParts'];
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CompiledRoute::$fit protected property The fitness of this route.
CompiledRoute::$hostRegex private property
CompiledRoute::$hostTokens private property
CompiledRoute::$hostVariables private property
CompiledRoute::$numParts protected property The number of parts in the path of this route.
CompiledRoute::$pathVariables private property
CompiledRoute::$patternOutline protected property The pattern outline of this route.
CompiledRoute::$regex private property
CompiledRoute::$staticPrefix private property
CompiledRoute::$tokens private property
CompiledRoute::$variables private property
CompiledRoute::getDefaults public function Returns the defaults.
CompiledRoute::getFit public function Returns the fit of this route.
CompiledRoute::getHostRegex public function Returns the host regex.
CompiledRoute::getHostTokens public function Returns the host tokens.
CompiledRoute::getHostVariables public function Returns the host variables.
CompiledRoute::getNumParts public function Returns the number of parts in this route's path.
CompiledRoute::getOptions public function Returns the options.
CompiledRoute::getPathVariables public function Returns the path variables.
CompiledRoute::getPatternOutline public function Returns the pattern outline of this route.
CompiledRoute::getRegex public function Returns the regex.
CompiledRoute::getRequirements public function Returns the requirements.
CompiledRoute::getStaticPrefix public function Returns the static prefix.
CompiledRoute::getTokens public function Returns the tokens.
CompiledRoute::getVariables public function Returns the variables.
CompiledRoute::serialize public function Overrides CompiledRoute::serialize
CompiledRoute::unserialize public function Overrides CompiledRoute::unserialize
CompiledRoute::__construct public function Constructs a new compiled route object. Overrides CompiledRoute::__construct