4 * This file is part of the Symfony CMF package.
6 * (c) 2011-2015 Symfony CMF
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Cmf\Component\Routing\Event;
14 use Symfony\Component\EventDispatcher\Event;
15 use Symfony\Component\Routing\Route;
18 * Event fired before the dynamic router generates a url for a route.
20 * The name, parameters and absolute properties have the semantics of
21 * UrlGeneratorInterface::generate()
23 * @author Ben Glassman
25 * @see \Symfony\Component\Routing\Generator\UrlGeneratorInterface::generate()
27 class RouterGenerateEvent extends Event
30 * The name of the route or the Route instance to generate.
37 * The parameters to use when generating the url.
44 * The type of reference to be generated (one of the constants in UrlGeneratorInterface).
48 private $referenceType;
51 * @param string|Route $route The route name or object
52 * @param array $parameters The parameters to use
53 * @param bool|string $referenceType The type of reference to be generated
55 public function __construct($route, $parameters, $referenceType)
57 $this->route = $route;
58 $this->parameters = $parameters;
59 $this->referenceType = $referenceType;
63 * Get route name or object.
65 * @return string|Route
67 public function getRoute()
73 * Set route name or object.
75 * @param string|Route $route
77 public function setRoute($route)
79 $this->route = $route;
83 * Get route parameters.
87 public function getParameters()
89 return $this->parameters;
93 * Set the route parameters.
95 * @param array $parameters
97 public function setParameters(array $parameters)
99 $this->parameters = $parameters;
103 * Set a route parameter.
106 * @param mixed $value
108 public function setParameter($key, $value)
110 $this->parameters[$key] = $value;
114 * Remove a route parameter by key.
118 public function removeParameter($key)
120 unset($this->parameters[$key]);
124 * The type of reference to be generated (one of the constants in UrlGeneratorInterface).
126 * @return bool|string
128 public function getReferenceType()
130 return $this->referenceType;
134 * The type of reference to be generated (one of the constants in UrlGeneratorInterface).
136 * @param bool|string $referenceType
138 public function setReferenceType($referenceType)
140 $this->referenceType = $referenceType;