Bug #105038
closedLoginProviderInterface - modifyView searches for Templates in cms-backend
100%
Description
Hey,
I'm trying to migrate the ->render call to ->modifyView (the way described in the documentation: https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ApiOverview/Backend/LoginProvider.html#login-provider-interface-migration)
Doing so will always fail, because it's searching for the template in 'cms-backend' and i don't see a way to override this template path.
Thanks in regards,
David
Updated by Garvin Hicking 2 months ago
- Category set to Authentication
- Status changed from New to Needs Feedback
In the modifyView
method you should have your $view
standalone view object. There you should be able to use setTemplatePathAndFilename
to adjust the used template files for rendering, have you tried that?
If that doesn't work maybe you can share your code so we can have a closer look.
Updated by David Hoeckele 2 months ago
the $view of the modifyView method is no longer a StandaloneView , it's an ViewInterface without a setTemplateAndFilename method. The render() method of the ViewInterface says "Optionally receives a template location" - but I think that path is meant inside of the extension and not to override the path here (I tried, it didn't work).
I took a look into the TYPO3\CMS\Backend\Controller\LoginController - the template paths of the modifyView method are hard-coded without an option to override:
$viewFactoryData = new ViewFactoryData(
templateRootPaths: ['EXT:backend/Resources/Private/Templates'],
partialRootPaths: ['EXT:backend/Resources/Private/Partials'],
layoutRootPaths: ['EXT:backend/Resources/Private/Layouts'],
request: $request,
);
It is possible to set a $templatePathAndFilename when creating a new ViewFactoryData - but not afterwards.
My code looks the same as the migration example in the link above.
Updated by Simon Praetorius 2 months ago ยท Edited
Because we're continually decoupling Fluid from the Core, extensions need to start differentiating between View implementations as well. This will probably be a bit more seamless in the future, but for now we also use instanceof
checks in the core, for example in ExtBase internals. So I'd suggest to use something like this in your case:
if ($view instanceof FluidViewAdapter) {
$view->getRenderingContext()->getTemplatePaths()->setTemplatePathAndFilename($yourTemplate);
}
You can also use setTemplateRootPaths
on that object and return the template name, that would probably be even cleaner.
Updated by Christian Kuhn 2 months ago
- Related to Feature #104773: Implement and use a core ViewFactoryInterface added
Updated by Gerrit Code Review 2 months ago
- Status changed from Needs Feedback to Under Review
Patch set 1 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/86209
Updated by Christian Kuhn 2 months ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset 7599167ea1d96e2a96d425792266339741aa2bde.