Dashboard sipadu mbip
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CompiledRoute.php 4.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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. * @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 $pathVariables An array of path variables
  31. * @param string|null $hostRegex Host regex
  32. * @param array $hostTokens Host tokens
  33. * @param array $hostVariables An array of host variables
  34. * @param array $variables An array of variables (variables defined in the path and in the host patterns)
  35. */
  36. public function __construct(string $staticPrefix, string $regex, array $tokens, array $pathVariables, string $hostRegex = null, array $hostTokens = [], array $hostVariables = [], array $variables = [])
  37. {
  38. $this->staticPrefix = $staticPrefix;
  39. $this->regex = $regex;
  40. $this->tokens = $tokens;
  41. $this->pathVariables = $pathVariables;
  42. $this->hostRegex = $hostRegex;
  43. $this->hostTokens = $hostTokens;
  44. $this->hostVariables = $hostVariables;
  45. $this->variables = $variables;
  46. }
  47. public function __serialize(): array
  48. {
  49. return [
  50. 'vars' => $this->variables,
  51. 'path_prefix' => $this->staticPrefix,
  52. 'path_regex' => $this->regex,
  53. 'path_tokens' => $this->tokens,
  54. 'path_vars' => $this->pathVariables,
  55. 'host_regex' => $this->hostRegex,
  56. 'host_tokens' => $this->hostTokens,
  57. 'host_vars' => $this->hostVariables,
  58. ];
  59. }
  60. /**
  61. * @internal since Symfony 4.3
  62. * @final since Symfony 4.3
  63. */
  64. public function serialize()
  65. {
  66. return serialize($this->__serialize());
  67. }
  68. public function __unserialize(array $data): void
  69. {
  70. $this->variables = $data['vars'];
  71. $this->staticPrefix = $data['path_prefix'];
  72. $this->regex = $data['path_regex'];
  73. $this->tokens = $data['path_tokens'];
  74. $this->pathVariables = $data['path_vars'];
  75. $this->hostRegex = $data['host_regex'];
  76. $this->hostTokens = $data['host_tokens'];
  77. $this->hostVariables = $data['host_vars'];
  78. }
  79. /**
  80. * @internal since Symfony 4.3
  81. * @final since Symfony 4.3
  82. */
  83. public function unserialize($serialized)
  84. {
  85. $this->__unserialize(unserialize($serialized, ['allowed_classes' => false]));
  86. }
  87. /**
  88. * Returns the static prefix.
  89. *
  90. * @return string The static prefix
  91. */
  92. public function getStaticPrefix()
  93. {
  94. return $this->staticPrefix;
  95. }
  96. /**
  97. * Returns the regex.
  98. *
  99. * @return string The regex
  100. */
  101. public function getRegex()
  102. {
  103. return $this->regex;
  104. }
  105. /**
  106. * Returns the host regex.
  107. *
  108. * @return string|null The host regex or null
  109. */
  110. public function getHostRegex()
  111. {
  112. return $this->hostRegex;
  113. }
  114. /**
  115. * Returns the tokens.
  116. *
  117. * @return array The tokens
  118. */
  119. public function getTokens()
  120. {
  121. return $this->tokens;
  122. }
  123. /**
  124. * Returns the host tokens.
  125. *
  126. * @return array The tokens
  127. */
  128. public function getHostTokens()
  129. {
  130. return $this->hostTokens;
  131. }
  132. /**
  133. * Returns the variables.
  134. *
  135. * @return array The variables
  136. */
  137. public function getVariables()
  138. {
  139. return $this->variables;
  140. }
  141. /**
  142. * Returns the path variables.
  143. *
  144. * @return array The variables
  145. */
  146. public function getPathVariables()
  147. {
  148. return $this->pathVariables;
  149. }
  150. /**
  151. * Returns the host variables.
  152. *
  153. * @return array The variables
  154. */
  155. public function getHostVariables()
  156. {
  157. return $this->hostVariables;
  158. }
  159. }