This repository was archived by the owner on Sep 16, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +59
-27
lines changed Expand file tree Collapse file tree 4 files changed +59
-27
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of the Symfony CMF package.
5
+ *
6
+ * (c) 2011-2014 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 \Bundle \RoutingAutoBundle \Controller ;
13
+
14
+ use Symfony \Cmf \Component \RoutingAuto \Model \AutoRouteInterface ;
15
+ use Symfony \Bundle \FrameworkBundle \Controller \Controller ;
16
+ use Symfony \Component \HttpFoundation \RedirectResponse ;
17
+ use Symfony \Component \Routing \RouterInterface ;
18
+
19
+ /**
20
+ * Simple redirecting controller for AutoRouteInterface documents
21
+ *
22
+ * @author Daniel Leech <[email protected] >
23
+ */
24
+ class RedirectController
25
+ {
26
+ /**
27
+ * @var RouterInterface
28
+ */
29
+ protected $ router ;
30
+
31
+ /**
32
+ * @param RouterInterface $router
33
+ */
34
+ public function __construct (RouterInterface $ router )
35
+ {
36
+ $ this ->router = $ router ;
37
+ }
38
+
39
+ /**
40
+ * @param AutoRouteInterface $routeDocument
41
+ */
42
+ public function redirectAction (AutoRouteInterface $ routeDocument )
43
+ {
44
+ $ routeTarget = $ routeDocument ->getRedirectTarget ();
45
+ $ url = $ this ->router ->generate ($ routeTarget );
46
+
47
+ return new RedirectResponse ($ url , 302 );
48
+ }
49
+ }
Original file line number Diff line number Diff line change 86
86
class =" %cmf_routing_auto.metadata.factory.class%"
87
87
factory-service =" cmf_routing_auto.metadata.factory.builder"
88
88
factory-method =" getMetadataFactory"
89
- />
89
+ />
90
+
91
+ <!-- Controller -->
92
+ <service
93
+ id =" cmf_routing_auto.redirect_controller"
94
+ class =" Symfony\Cmf\Bundle\RoutingAutoBundle\Controller\RedirectController"
95
+ >
96
+ <argument type =" service" id =" router" />
97
+ </service >
90
98
</services >
91
99
</container >
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ cmf_routing:
6
6
dynamic :
7
7
enabled : true
8
8
controllers_by_type :
9
- cmf_routing_auto.redirect : Symfony\Cmf\Bundle\RoutingAutoBundle\Tests\Resources\Controller\TestController: :redirectAction
9
+ cmf_routing_auto.redirect : cmf_routing_auto.redirect_controller :redirectAction
10
10
persistence :
11
11
phpcr :
12
12
enabled : true
You can’t perform that action at this time.
0 commit comments