Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 26 additions & 17 deletions docs/dev/guides/backend-routes.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,36 @@ and is configured through annotations.
// src/Controller/BackendController.php
namespace App\Controller;

use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\HttpFoundation\Response;
use Twig\Environment as TwigEnvironment;

/**
* @Route("/contao", defaults={
* "_scope" = "backend",
* "_token_check" = true,
* "_backend_module" = "my-modules"
* })
* @Route("/contao/my-backend-route",
* name=App\Controller\BackendController::class
* defaults={
* "_scope" = "backend",
* "_token_check" = true,
* "_backend_module" = "my-module"
* }
* )
*/
class BackendController extends AbstractController
{
/**
* @Route("/my-backend-route", name="app.backend-route")
* @Template("my_backend_route.html.twig")
*/
public function backendRouteAction()
private $twig;

public function __construct(TwigEnvironment $twig)
{
return [];
$this->twig = $twig;
}

public function __invoke()
{
return new Response($this->twig->render(
'my_backend_route.html.twig',
[]
));
}
}
```
Expand All @@ -61,12 +70,12 @@ you need to set this to true, in order to get it to work.
the current route in order to highlight the currently active node in the back end menu.
More on this later.

Be sure to have imported your bundles Controllers in your `routing.yml` *before*
the `ContaoCoreBundle` routes.
Be sure to have imported your bundles Controllers in your `routing.yml` *before*
the `ContaoCoreBundle` routes.

```yaml
# config/routing.yml
app:
app.controller:
resource: ../src/Controller
type: annotation
```
Expand All @@ -92,7 +101,7 @@ which must be placed into `/templates`.
{% endblock %}
```

As we extend from `@ContaoCore/Backend/be_page.html.twig` it is worth noting
As we extend from `@ContaoCore/Backend/be_page.html.twig` it is worth noting
that there are three different blocks you can currently use:

* `headline`: This block renders the headline of the document.
Expand Down