Und zwar möchte ich ein twig template ausgeben
PHP-Code:
return new Response($this->twig->render(
'../Resources/contao/templates/my_backend_route.html.twig,
[]
));
Fehlermeldung :
Looks like you try to load a template outside configured directories (../Resources/contao/templates/my_backend_route.html.twig).
ich weiss nicht wie die pfadangabe mache sodass das template in meinem Bundle "templates" ordner gefunden wird...
PHP-Code:
<?php
// src/Controller/BackendController.php
namespace Acme\ContaoHelloWorldBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\HttpFoundation\Response;
use Twig\Environment as TwigEnvironment;
/**
* @Route("/contao/my-backend-route",
* name=BackendController::class,
* defaults={"_scope": "backend"}
* )
*/
class BackendController extends AbstractController
{
private $twig;
public function __construct(TwigEnvironment $twig)
{
$this->twig = $twig;
}
public function __invoke(): Response
{
return new Response($this->twig->render(
'@Acme/ContaoHelloWorldBundle/my_backend_route.html.twig',
[]
));
}
}
Ich habe versucht die ressource über meinen Namespace bzw logical path so zu laden wie hier beschrieben
https://symfony.com/doc/current/bund...html#resources
funktioniert leider uach nicht.
EDIT : hab über stackoverflow rausgefunden wie contao die Namespaces erstellt
@ContaoHelloWorld hat dann funktioniert.
Lesezeichen