Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/symfony/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Symfony如何覆盖fosrestbundle_Symfony_Fosrestbundle - Fatal编程技术网

Symfony如何覆盖fosrestbundle

Symfony如何覆盖fosrestbundle,symfony,fosrestbundle,Symfony,Fosrestbundle,我需要重写fosrestbundle/Controller/ExceptionController。 为此,我创建了一个控制器: class ExceptionApiController extends ExceptionController { public function showAction(Request $request, $exception, DebugLoggerInterface $logger = null) { $response = p

我需要重写fosrestbundle/Controller/ExceptionController。 为此,我创建了一个控制器:

class ExceptionApiController extends ExceptionController
{

    public function showAction(Request $request, $exception, DebugLoggerInterface $logger = null)
    {
        $response = parent::showAction();

    }
}

但是如何使用$response呢?如何在这方面增加价值?

我建议创建一个新的UserBundle,并扩展FOSUserbundle:

namespace UserBundle;

use Symfony\Bundle\SecurityBundle\DependencyInjection\SecurityExtension;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Bundle\Bundle;

class UserBundle extends Bundle
{
    public function getParent()
    {
        return 'FOSUserBundle';
    }
}
在UserBundle中创建ExceptionController类将覆盖FOSUserBundle中的类