namespace etc...
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Bundle\TwigBundle\Controller\ExceptionController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\HttpKernel;
use Symfony\Component\HttpKernel\Exception\FlattenException;
use Symfony\Component\HttpKernel\Log\DebugLoggerInterface;
use Symfony\Component\HttpFoundation\Response;
class MyExceptionController extends ExceptionController
{
public function showAction(Request $request, FlattenException $exception, DebugLoggerInterface $logger = null, $format = 'html')
{
}
}
コントローラー内で何もしないと、「Uncaught exception 'Symfony\Component\Routing\Exception\ResourceNotFoundException' in...」エラーが返されます。それが正しいのか、それとも別の問題なのかはわかりません。通常のアクションを実行するだけだと思います。
domain.com/page にアクセスした場合とまったく同じように、指定されたルートが表示されるようにするだけです。
私はこれを試しました:
$httpKernel = $this->container->get('kernel');
$response = $httpKernel->forward('AcmeMyBundle:Default:pageAction');
$this->setResponse(new Response($response));
...しかし、このエラーが発生します:
Call to a member function get() on a non-object in...