Skip to content

Commit cf1ac04

Browse files
linawolffroemken
andauthored
[DOCS] Improve LoginProviderInterface->modifyView() ReST (#5113)
* [DOCS] Improve LoginProviderInterface->modifyView() ReST Resolves: TYPO3-Documentation/Changelog-To-Doc#1056 Releases: main, 13.4 * Apply suggestions from code review Co-authored-by: Stefan Frömken <froemken@gmail.com> --------- Co-authored-by: Stefan Frömken <froemken@gmail.com>
1 parent b2ffb5a commit cf1ac04

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

Documentation/ApiOverview/Backend/LoginProvider.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,16 @@ An implementation of :php-short:`\TYPO3\CMS\Backend\LoginProvider\LoginProviderI
8989
look like this for TYPO3 v13:
9090

9191
.. literalinclude:: _LoginProvider/_MyLoginProvider.php
92+
:caption: EXT:my_extension/Classes/Login/MyLoginProvider.php
93+
:linenos:
94+
95+
The default implementation in :php-short:`\TYPO3\CMS\Backend\LoginProvider\UsernamePasswordLoginProvider`
96+
is a good example. Extensions that need to configure additional template, layout or
97+
partial lookup paths can extend them, see lines 23-28 in the example above.
98+
99+
Consumers of :php-short:`\TYPO3\CMS\Backend\LoginProvider\Event\ModifyPageLayoutOnLoginProviderSelectionEvent`
100+
should use the request instead, and/or should get an instance of
101+
:php-short:`\TYPO3\CMS\Core\Page\PageRenderer` injected as well.
92102

93103
.. _login-provider-view:
94104

Documentation/ApiOverview/Backend/_LoginProvider/_MyLoginProvider.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use TYPO3\CMS\Backend\LoginProvider\LoginProviderInterface;
88
use TYPO3\CMS\Core\Page\PageRenderer;
99
use TYPO3\CMS\Core\View\ViewInterface;
10+
use TYPO3\CMS\Fluid\View\FluidViewAdapter;
1011

1112
#[Autoconfigure(public: true)]
1213
final readonly class MyLoginProvider implements LoginProviderInterface
@@ -18,6 +19,13 @@ public function __construct(
1819
public function modifyView(ServerRequestInterface $request, ViewInterface $view): string
1920
{
2021
$this->pageRenderer->addJsFile('someFile');
22+
// Custom login provider implementations can add custom fluid lookup paths.
23+
if ($view instanceof FluidViewAdapter) {
24+
$templatePaths = $view->getRenderingContext()->getTemplatePaths();
25+
$templateRootPaths = $templatePaths->getTemplateRootPaths();
26+
$templateRootPaths[] = 'EXT:my_extension/Resources/Private/Templates';
27+
$templatePaths->setTemplateRootPaths($templateRootPaths);
28+
}
2129
$view->assign('Some Variable', 'some value');
2230
return 'Login/MyLoginForm';
2331
}

0 commit comments

Comments
 (0)