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')
{
}
}
在控制器内不执行任何操作会返回“未捕获的异常 '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...