CompiledRoute.php 3.2 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 $variables;
  19. private $tokens;
  20. private $staticPrefix;
  21. private $regex;
  22. private $pathVariables;
  23. private $hostVariables;
  24. private $hostRegex;
  25. private $hostTokens;
  26. /**
  27. * Constructor.
  28. *
  29. * @param string $staticPrefix The static prefix of the compiled route
  30. * @param string $regex The regular expression to use to match this route
  31. * @param array $tokens An array of tokens to use to generate URL for this route
  32. * @param array $pathVariables An array of path variables
  33. * @param string|null $hostRegex Host regex
  34. * @param array $hostTokens Host tokens
  35. * @param array $hostVariables An array of host variables
  36. * @param array $variables An array of variables (variables defined in the path and in the host patterns)
  37. */
  38. public function __construct($staticPrefix, $regex, array $tokens, array $pathVariables, $hostRegex = null, array $hostTokens = array(), array $hostVariables = array(), array $variables = array())
  39. {
  40. $this->staticPrefix = (string) $staticPrefix;
  41. $this->regex = $regex;
  42. $this->tokens = $tokens;
  43. $this->pathVariables = $pathVariables;
  44. $this->hostRegex = $hostRegex;
  45. $this->hostTokens = $hostTokens;
  46. $this->hostVariables = $hostVariables;
  47. $this->variables = $variables;
  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 host regex
  69. *
  70. * @return string|null The host regex or null
  71. */
  72. public function getHostRegex()
  73. {
  74. return $this->hostRegex;
  75. }
  76. /**
  77. * Returns the tokens.
  78. *
  79. * @return array The tokens
  80. */
  81. public function getTokens()
  82. {
  83. return $this->tokens;
  84. }
  85. /**
  86. * Returns the host tokens.
  87. *
  88. * @return array The tokens
  89. */
  90. public function getHostTokens()
  91. {
  92. return $this->hostTokens;
  93. }
  94. /**
  95. * Returns the variables.
  96. *
  97. * @return array The variables
  98. */
  99. public function getVariables()
  100. {
  101. return $this->variables;
  102. }
  103. /**
  104. * Returns the path variables.
  105. *
  106. * @return array The variables
  107. */
  108. public function getPathVariables()
  109. {
  110. return $this->pathVariables;
  111. }
  112. /**
  113. * Returns the host variables.
  114. *
  115. * @return array The variables
  116. */
  117. public function getHostVariables()
  118. {
  119. return $this->hostVariables;
  120. }
  121. }