-
-
Notifications
You must be signed in to change notification settings - Fork 158
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
Render the Contao login page even if the current route is not a Contao page #7077
Conversation
I am not quite sure what to test here. Do you mean a custom controller that has a route starting with |
I tried with namespace App\Controller;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
#[Route(path: '%contao.backend.route_prefix%/test')]
class TestController
{
public function __invoke(): Response
{
return new Response('Hello World!');
}
} But this controller is always rendered, regardless of whether you have a valid back end login or not (as it should, I think?). |
This is not about the back end. I have a custom controller on a custom route, that has |
Ah, I see. I have the same issue within $root = $this->findFirstPublishedRootByHostAndLanguage($request->getHost(), $request->getLocale());
if (null !== $root) {
$root->loadDetails();
$request->attributes->set('pageModel', $root);
$GLOBALS['objPage'] = $root;
} This means after this PR this should not be necessary anymore, correct? |
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 tested it - but it does not work if you set contao.legacy_routing: false
. When Legacy Routing is disabled, Frontend::getRootPageFromUrl()
will simply check for the pageModel
attribute in the current request, which is of course missing.
contao/core-bundle/src/Resources/contao/classes/Frontend.php
Lines 302 to 321 in d26e0ce
public static function getRootPageFromUrl() | |
{ | |
if (!System::getContainer()->getParameter('contao.legacy_routing')) | |
{ | |
$objRequest = System::getContainer()->get('request_stack')->getCurrentRequest(); | |
if ($objRequest instanceof Request) | |
{ | |
$objPage = $objRequest->attributes->get('pageModel'); | |
if ($objPage instanceof PageModel) | |
{ | |
$objPage->loadDetails(); | |
return PageModel::findByPk($objPage->rootId); | |
} | |
} | |
throw new NoRootPageFoundException('No root page found'); | |
} |
Thanks @fritzmg. I have updated the PR to use other means to find the root page. The used method is deprecated, but since this is not going to be merged upstream I think that should be fine. |
Btw. which method do you mean? As far as I can see you did not use any deprecated methods 🤔 |
Wouldn‘t it be easier to backport the |
I don‘t think its a good idea to backport this so late in the patch process… |
Why not? It wouldn‘t break anything and it would ensure upstream mergeability, which is worth much more than following the "no new features in a bugfix release" rule. We could even make the service |
To be fair, it could also reduce duplicate code in Contao 4.13. |
The
That should do it? |
Thank you @aschempp. |
Fixed point 1 of #6805 for Contao 4.13
This must not be merged upstream!