Closed
Description
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
Labels
No labels