CompiledRoute.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Routing;
  11. /**
  12. * CompiledRoutes are returned by the RouteCompiler class.
  13. *
  14. * @author Fabien Potencier <fabien@symfony.com>
  15. */
  16. class CompiledRoute
  17. {
  18. private $route;
  19. private $variables;
  20. private $tokens;
  21. private $staticPrefix;
  22. private $regex;
  23. /**
  24. * Constructor.
  25. *
  26. * @param Route $route A original Route instance
  27. * @param string $staticPrefix The static prefix of the compiled route
  28. * @param string $regex The regular expression to use to match this route
  29. * @param array $tokens An array of tokens to use to generate URL for this route
  30. * @param array $variables An array of variables
  31. */
  32. public function __construct(Route $route, $staticPrefix, $regex, array $tokens, array $variables)
  33. {
  34. $this->route = $route;
  35. $this->staticPrefix = $staticPrefix;
  36. $this->regex = $regex;
  37. $this->tokens = $tokens;
  38. $this->variables = $variables;
  39. }
  40. /**
  41. * Returns the Route instance.
  42. *
  43. * @return Route A Route instance
  44. */
  45. public function getRoute()
  46. {
  47. return $this->route;
  48. }
  49. /**
  50. * Returns the static prefix.
  51. *
  52. * @return string The static prefix
  53. */
  54. public function getStaticPrefix()
  55. {
  56. return $this->staticPrefix;
  57. }
  58. /**
  59. * Returns the regex.
  60. *
  61. * @return string The regex
  62. */
  63. public function getRegex()
  64. {
  65. return $this->regex;
  66. }
  67. /**
  68. * Returns the tokens.
  69. *
  70. * @return array The tokens
  71. */
  72. public function getTokens()
  73. {
  74. return $this->tokens;
  75. }
  76. /**
  77. * Returns the variables.
  78. *
  79. * @return array The variables
  80. */
  81. public function getVariables()
  82. {
  83. return $this->variables;
  84. }
  85. /**
  86. * Returns the pattern.
  87. *
  88. * @return string The pattern
  89. */
  90. public function getPattern()
  91. {
  92. return $this->route->getPattern();
  93. }
  94. /**
  95. * Returns the options.
  96. *
  97. * @return array The options
  98. */
  99. public function getOptions()
  100. {
  101. return $this->route->getOptions();
  102. }
  103. /**
  104. * Returns the defaults.
  105. *
  106. * @return array The defaults
  107. */
  108. public function getDefaults()
  109. {
  110. return $this->route->getDefaults();
  111. }
  112. /**
  113. * Returns the requirements.
  114. *
  115. * @return array The requirements
  116. */
  117. public function getRequirements()
  118. {
  119. return $this->route->getRequirements();
  120. }
  121. }