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