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 <daniel@dantleech.com>
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 8686 class =" %cmf_routing_auto.metadata.factory.class%"
8787 factory-service =" cmf_routing_auto.metadata.factory.builder"
8888 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 >
9098 </services >
9199</container >
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ cmf_routing:
66 dynamic :
77 enabled : true
88 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
1010 persistence :
1111 phpcr :
1212 enabled : true
You can’t perform that action at this time.
0 commit comments