Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[2.3][doc] forward() method for http_kernel service should be removed / updated from the doc #8783

Copy link
Copy link
Closed
@Maxwell2022

Description

@Maxwell2022
Issue body actions

I have an Access Denied Handler that is redirecting denied access exception to a controller to render the exception.

It use to work correctly, but I just notice that it's not anymore.

The error I get is:

FatalErrorException: Error: Call to undefined method Symfony\Component\HttpKernel\DependencyInjection\ContainerAwareHttpKernel::forward() in /var/www/src/Acme/CoreBundle/Security/Authorization/Handler/AccessDeniedHandler.php line 30

Here is my service definition:

   acme.security.access_denied_handler:
        class: Acme\CoreBundle\Security\Authorization\Handler\AccessDeniedHandler
        arguments: [@http_kernel]
        tags:
            - { name: kernel.event_listener, event: security.kernel_response, method: handle }

And the class:

<?php

namespace Acme\CoreBundle\Security\Authorization\Handler;

use Symfony\Component\Security\Http\Authorization\AccessDeniedHandlerInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\HttpKernelInterface;

class AccessDeniedHandler implements AccessDeniedHandlerInterface
{
    private $kernel;

    public function __construct(HttpKernelInterface $http_kernel)
    {
        $this->kernel = $http_kernel;
    }

    /**
     * Handles an access denied failure.
     *
     * @param Request               $request
     * @param AccessDeniedException $accessDeniedException
     *
     * @return Response may return null
     */
    public function handle(Request $request, AccessDeniedException $accessDeniedException)
    {
        return $this->kernel->forward('AcmeCoreBundle:Default:accessDenied', array(
            'exception' => $accessDeniedException
        ));
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.