Drupal investigation

RouterGenerateEvent.php 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <?php
  2. /*
  3. * This file is part of the Symfony CMF package.
  4. *
  5. * (c) 2011-2015 Symfony CMF
  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\Cmf\Component\Routing\Event;
  11. use Symfony\Component\EventDispatcher\Event;
  12. use Symfony\Component\Routing\Route;
  13. /**
  14. * Event fired before the dynamic router generates a url for a route.
  15. *
  16. * The name, parameters and absolute properties have the semantics of
  17. * UrlGeneratorInterface::generate()
  18. *
  19. * @author Ben Glassman
  20. *
  21. * @see \Symfony\Component\Routing\Generator\UrlGeneratorInterface::generate()
  22. */
  23. class RouterGenerateEvent extends Event
  24. {
  25. /**
  26. * The name of the route or the Route instance to generate.
  27. *
  28. * @var string|Route
  29. */
  30. private $route;
  31. /**
  32. * The parameters to use when generating the url.
  33. *
  34. * @var array
  35. */
  36. private $parameters;
  37. /**
  38. * The type of reference to be generated (one of the constants in UrlGeneratorInterface).
  39. *
  40. * @var bool|string
  41. */
  42. private $referenceType;
  43. /**
  44. * @param string|Route $route The route name or object
  45. * @param array $parameters The parameters to use
  46. * @param bool|string $referenceType The type of reference to be generated
  47. */
  48. public function __construct($route, $parameters, $referenceType)
  49. {
  50. $this->route = $route;
  51. $this->parameters = $parameters;
  52. $this->referenceType = $referenceType;
  53. }
  54. /**
  55. * Get route name or object.
  56. *
  57. * @return string|Route
  58. */
  59. public function getRoute()
  60. {
  61. return $this->route;
  62. }
  63. /**
  64. * Set route name or object.
  65. *
  66. * @param string|Route $route
  67. */
  68. public function setRoute($route)
  69. {
  70. $this->route = $route;
  71. }
  72. /**
  73. * Get route parameters.
  74. *
  75. * @return array
  76. */
  77. public function getParameters()
  78. {
  79. return $this->parameters;
  80. }
  81. /**
  82. * Set the route parameters.
  83. *
  84. * @param array $parameters
  85. */
  86. public function setParameters(array $parameters)
  87. {
  88. $this->parameters = $parameters;
  89. }
  90. /**
  91. * Set a route parameter.
  92. *
  93. * @param string $key
  94. * @param mixed $value
  95. */
  96. public function setParameter($key, $value)
  97. {
  98. $this->parameters[$key] = $value;
  99. }
  100. /**
  101. * Remove a route parameter by key.
  102. *
  103. * @param string $key
  104. */
  105. public function removeParameter($key)
  106. {
  107. unset($this->parameters[$key]);
  108. }
  109. /**
  110. * The type of reference to be generated (one of the constants in UrlGeneratorInterface).
  111. *
  112. * @return bool|string
  113. */
  114. public function getReferenceType()
  115. {
  116. return $this->referenceType;
  117. }
  118. /**
  119. * The type of reference to be generated (one of the constants in UrlGeneratorInterface).
  120. *
  121. * @param bool|string $referenceType
  122. */
  123. public function setReferenceType($referenceType)
  124. {
  125. $this->referenceType = $referenceType;
  126. }
  127. }