Drupal investigation

CompiledRoute.php 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  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 implements \Serializable
  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. * {@inheritdoc}
  51. */
  52. public function serialize()
  53. {
  54. return serialize(array(
  55. 'vars' => $this->variables,
  56. 'path_prefix' => $this->staticPrefix,
  57. 'path_regex' => $this->regex,
  58. 'path_tokens' => $this->tokens,
  59. 'path_vars' => $this->pathVariables,
  60. 'host_regex' => $this->hostRegex,
  61. 'host_tokens' => $this->hostTokens,
  62. 'host_vars' => $this->hostVariables,
  63. ));
  64. }
  65. /**
  66. * {@inheritdoc}
  67. */
  68. public function unserialize($serialized)
  69. {
  70. $data = unserialize($serialized);
  71. $this->variables = $data['vars'];
  72. $this->staticPrefix = $data['path_prefix'];
  73. $this->regex = $data['path_regex'];
  74. $this->tokens = $data['path_tokens'];
  75. $this->pathVariables = $data['path_vars'];
  76. $this->hostRegex = $data['host_regex'];
  77. $this->hostTokens = $data['host_tokens'];
  78. $this->hostVariables = $data['host_vars'];
  79. }
  80. /**
  81. * Returns the static prefix.
  82. *
  83. * @return string The static prefix
  84. */
  85. public function getStaticPrefix()
  86. {
  87. return $this->staticPrefix;
  88. }
  89. /**
  90. * Returns the regex.
  91. *
  92. * @return string The regex
  93. */
  94. public function getRegex()
  95. {
  96. return $this->regex;
  97. }
  98. /**
  99. * Returns the host regex.
  100. *
  101. * @return string|null The host regex or null
  102. */
  103. public function getHostRegex()
  104. {
  105. return $this->hostRegex;
  106. }
  107. /**
  108. * Returns the tokens.
  109. *
  110. * @return array The tokens
  111. */
  112. public function getTokens()
  113. {
  114. return $this->tokens;
  115. }
  116. /**
  117. * Returns the host tokens.
  118. *
  119. * @return array The tokens
  120. */
  121. public function getHostTokens()
  122. {
  123. return $this->hostTokens;
  124. }
  125. /**
  126. * Returns the variables.
  127. *
  128. * @return array The variables
  129. */
  130. public function getVariables()
  131. {
  132. return $this->variables;
  133. }
  134. /**
  135. * Returns the path variables.
  136. *
  137. * @return array The variables
  138. */
  139. public function getPathVariables()
  140. {
  141. return $this->pathVariables;
  142. }
  143. /**
  144. * Returns the host variables.
  145. *
  146. * @return array The variables
  147. */
  148. public function getHostVariables()
  149. {
  150. return $this->hostVariables;
  151. }
  152. }