-
-
Notifications
You must be signed in to change notification settings - Fork 160
Fix back end route controller example #225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -26,27 +26,39 @@ and is configured through annotations. | |||||||||
// src/Controller/BackendController.php | ||||||||||
namespace App\Controller; | ||||||||||
fritzmg marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
|
||||||||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; | ||||||||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; | ||||||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | ||||||||||
use Symfony\Component\Routing\Annotation\Route; | ||||||||||
use Symfony\Component\HttpFoundation\Response; | ||||||||||
use Twig\Environment as TwigEnvironment; | ||||||||||
|
||||||||||
/** | ||||||||||
* @Route("/contao", defaults={ | ||||||||||
* "_scope" = "backend", | ||||||||||
* "_token_check" = true, | ||||||||||
* "_backend_module" = "my-modules" | ||||||||||
* }) | ||||||||||
* @Route("/contao//my-backend-route", | ||||||||||
aschempp marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
aschempp marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||
* name="app.backend-route" | ||||||||||
|
* name="app.backend-route" | |
* name=App\Action\BackendAction::class, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have never seen a route with a class name, not sure this works (and is best practice?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes this works and is much more useful as you can then simply write
$this->router->generate(BackendAction::class)
in PHP.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a trailing comma missing after name=""
which leads to AnnotationException.php line 42: [Syntax Error] Expected Doctrine\Common\Annotations\DocLexer::T_CLOSE_PARENTHESIS, got 'defaults'
error
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* name="app.backend-route" | |
* name=App\Controller\BackendController::class |
aschempp marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This whole annotation block is not needed anymore, is it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This still needs to be removed.
Uh oh!
There was an error while loading. Please reload this page.