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

Class loading error in createAccessDeniedException() #25595

Copy link
Copy link
Closed
@fgm

Description

@fgm
Issue body actions
Q A
Bug report? yes
Feature request? no
BC Break report? yes
RFC? no
Symfony version 4.0.2

Error still present in FrameworkBundle at commit 0be83d70d0cbef4837d595f30c248f6e8eddf2dc.

When using the Flex skeleton, the generated code includes the framework bundle, in which ControllerTrait reads:

  // in file framework-bundle/Controller/ControllerTrait.php
   // [...]
  use Symfony\Component\Security\Core\Exception\AccessDeniedException;
   // [...]
  protected function createAccessDeniedException(string $message = 'Access Denied.', \Exception $previous = null): AccessDeniedException
  {
      return new AccessDeniedException($message, $previous);
  }

However, this fails because the security component is not required by the skeleton, so the class cannot be loaded.

This causes an error message like:

Attempted to load class "AccessDeniedException" from namespace "Symfony\Component\Security\Core\Exception".
Did you forget a "use" statement for e.g. "Symfony\Component\HttpFoundation\File\Exception\AccessDeniedException" or "Symfony\Component\Finder\Exception\AccessDeniedException"?

Solutions include:

  • add a dependency on the security component to the framework-bundle, which seems to be the most logical choice
  • modify the skeleton to add the security component, but this seems more brittle than the first solution
  • use another AccessDeniedException (there are two already: one in finder and one in http-foundation/file); but this does not seem logical.

I can prepare a PR if desired.

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.