Commit 2a6783b9 authored by Thomas Löffler's avatar Thomas Löffler

Easier handling to get pids for ajaxlogin

parent 4d29c93e
......@@ -14,10 +14,14 @@ namespace T3o\T3olayout\Middlewares;
* The TYPO3 project - inspiring people to share!
*/
use GuzzleHttp\Psr7\Response;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\MiddlewareInterface;
use Psr\Http\Server\RequestHandlerInterface;
use TYPO3\CMS\Core\Configuration\ExtensionConfiguration;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Fluid\View\StandaloneView;
class FlyOutAjaxLogin implements MiddlewareInterface
{
......@@ -27,35 +31,23 @@ class FlyOutAjaxLogin implements MiddlewareInterface
return $handler->handle($request);
}
$objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class);
$configurationManager = $objectManager->get(\TYPO3\CMS\Extbase\Configuration\ConfigurationManager::class);
$typoScriptSetup = $configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT);
$contentObjectRenderer = $objectManager->get(\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::class);
$loginPid = $contentObjectRenderer->cObjGetSingle(
$typoScriptSetup['lib.']['loginPid'],
$typoScriptSetup['lib.']['loginPid.']
);
$loginFormPid = $contentObjectRenderer->cObjGetSingle(
$typoScriptSetup['lib.']['loginFormPid'],
$typoScriptSetup['lib.']['loginFormPid.']
);
$extensionConfiguration = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get('t3olayout');
$feUser = $request->getAttribute('frontend.user');
$menuBarTemplate = $objectManager->get(\TYPO3\CMS\Fluid\View\StandaloneView::class);
$menuBarTemplate = GeneralUtility::makeInstance(StandaloneView::class);
$menuBarTemplate->setTemplatePathAndFilename('EXT:t3olayout/Resources/Private/Templates/Felogin/MenuBarAjaxLogin.html');
$menuBarTemplate->assign('user', $feUser->user);
$menuBarTemplate->assign('loginPid', $loginPid);
$menuBarTemplate->assign('loginFormPid', $loginFormPid);
$menuBarTemplate->assign('loginPid', $extensionConfiguration['loginPid']);
$menuBarTemplate->assign('loginFormPid', $extensionConfiguration['loginFormPid']);
$returnValue = [
'loginPid' => $loginPid,
'loginFormPid' => $loginFormPid,
'loginPid' => $extensionConfiguration['loginPid'],
'loginFormPid' => $extensionConfiguration['loginFormPid'],
'loggedIn' => $feUser->user['ses_userid'] > 0,
'menuBarTemplate' => $menuBarTemplate->render()
];
$response = new \GuzzleHttp\Psr7\Response();
$response = new Response();
$response->getBody()->write(json_encode($returnValue));
return $response;
......
#
# Extension Configuration template
#
# cat=Login; type=int+; label=PID with users
loginPid =
# cat=Login; type=int+; label=PID with login form
loginFormPid =
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment