@@ -26,27 +26,36 @@ and is configured through annotations.
26
26
// src/Controller/BackendController.php
27
27
namespace App\Controller;
28
28
29
- use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
30
- use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
31
29
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
30
+ use Symfony\Component\Routing\Annotation\Route;
32
31
use Symfony\Component\HttpFoundation\Response;
32
+ use Twig\Environment as TwigEnvironment;
33
33
34
34
/**
35
- * @Route("/contao", defaults={
36
- * "_scope" = "backend",
37
- * "_token_check" = true,
38
- * "_backend_module" = "my-modules"
39
- * })
35
+ * @Route("/contao/my-backend-route",
36
+ * name=App\Controller\BackendController::class
37
+ * defaults={
38
+ * "_scope" = "backend",
39
+ * "_token_check" = true,
40
+ * "_backend_module" = "my-module"
41
+ * }
42
+ * )
40
43
*/
41
44
class BackendController extends AbstractController
42
45
{
43
- /**
44
- * @Route("/my-backend-route", name="app.backend-route")
45
- * @Template("my_backend_route.html.twig")
46
- */
47
- public function backendRouteAction()
46
+ private $twig;
47
+
48
+ public function __construct(TwigEnvironment $twig)
48
49
{
49
- return [];
50
+ $this->twig = $twig;
51
+ }
52
+
53
+ public function __invoke()
54
+ {
55
+ return new Response($this->twig->render(
56
+ 'my_backend_route.html.twig',
57
+ []
58
+ ));
50
59
}
51
60
}
52
61
```
@@ -61,12 +70,12 @@ you need to set this to true, in order to get it to work.
61
70
the current route in order to highlight the currently active node in the back end menu.
62
71
More on this later.
63
72
64
- Be sure to have imported your bundles Controllers in your ` routing.yml ` * before*
65
- the ` ContaoCoreBundle ` routes.
73
+ Be sure to have imported your bundles Controllers in your ` routing.yml ` * before*
74
+ the ` ContaoCoreBundle ` routes.
66
75
67
76
``` yaml
68
77
# config/routing.yml
69
- app :
78
+ app.controller :
70
79
resource : ../src/Controller
71
80
type : annotation
72
81
` ` `
@@ -92,7 +101,7 @@ which must be placed into `/templates`.
92
101
{% endblock %}
93
102
```
94
103
95
- As we extend from ` @ContaoCore/Backend/be_page.html.twig ` it is worth noting
104
+ As we extend from ` @ContaoCore/Backend/be_page.html.twig ` it is worth noting
96
105
that there are three different blocks you can currently use:
97
106
98
107
* ` headline ` : This block renders the headline of the document.
0 commit comments