Skip to content

Commit

Permalink
[DOCS] Improve LoginProviderInterface->modifyView() ReST (#5113)
Browse files Browse the repository at this point in the history
* [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>
  • Loading branch information
linawolf and froemken authored Dec 5, 2024
1 parent b2ffb5a commit cf1ac04
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Documentation/ApiOverview/Backend/LoginProvider.rst
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,16 @@ An implementation of :php-short:`\TYPO3\CMS\Backend\LoginProvider\LoginProviderI
look like this for TYPO3 v13:

.. literalinclude:: _LoginProvider/_MyLoginProvider.php
:caption: EXT:my_extension/Classes/Login/MyLoginProvider.php
:linenos:

The default implementation in :php-short:`\TYPO3\CMS\Backend\LoginProvider\UsernamePasswordLoginProvider`
is a good example. Extensions that need to configure additional template, layout or
partial lookup paths can extend them, see lines 23-28 in the example above.

Consumers of :php-short:`\TYPO3\CMS\Backend\LoginProvider\Event\ModifyPageLayoutOnLoginProviderSelectionEvent`
should use the request instead, and/or should get an instance of
:php-short:`\TYPO3\CMS\Core\Page\PageRenderer` injected as well.

.. _login-provider-view:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use TYPO3\CMS\Backend\LoginProvider\LoginProviderInterface;
use TYPO3\CMS\Core\Page\PageRenderer;
use TYPO3\CMS\Core\View\ViewInterface;
use TYPO3\CMS\Fluid\View\FluidViewAdapter;

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

0 comments on commit cf1ac04

Please sign in to comment.