Browse Source

uncache the username id partial

Olivier Massot 4 years ago
parent
commit
cbd2ca245c

+ 39 - 0
ot_templating/Classes/ViewHelpers/Request/GetFeUserViewHelper.php

@@ -0,0 +1,39 @@
+<?php
+
+namespace Opentalent\OtTemplating\ViewHelpers\Request;
+
+use Closure;
+use Opentalent\OtCore\ViewHelpers\OtAbstractViewHelper;
+use Opentalent\OtCore\Website\OtWebsiteRepository;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Extbase\Object\ObjectManager;
+use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
+
+/**
+ *   Returns the current Typo3 Fe User if any (FE only)
+ *
+ *     {namespace ot=Opentalent\OtTemplating\ViewHelpers}
+ *
+ *     {ot:request.getFeUser()}
+ *
+ * @package Opentalent\OtTemplating\ViewHelpers
+ */
+class GetFeUserViewHelper extends OtAbstractViewHelper {
+
+    /**
+     * -- This method is expected by Fluid --
+     * Renders the content as html
+     *
+     * @param array $arguments
+     * @param Closure $renderChildrenClosure
+     * @param RenderingContextInterface $renderingContext
+     * @return string|null
+     */
+    public static function renderStatic(
+        array $arguments,
+        Closure $renderChildrenClosure,
+        RenderingContextInterface $renderingContext
+    ) {
+        return $GLOBALS['TSFE']->fe_user->user;
+    }
+}

+ 1 - 1
ot_templating/Resources/Private/Partials/Classic/Topbar.html

@@ -13,7 +13,7 @@
 
     <h1 class="topbar-title">{settings.structureName}</h1>
 
-    <v:render.uncache partial="Classic/UserToolbar" arguments="{_all}" />
+    <v:render.uncache partial="Classic/UserToolbar" />
 
     <f:comment><!-- Si un networkLogo est définit, affiche le logo du réseau --></f:comment>
     <f:if condition="{settings.networkLogo} != ''">

+ 2 - 1
ot_templating/Resources/Private/Partials/Classic/UserToolbar.html

@@ -6,11 +6,12 @@
 <div class="user-toolbar">
     <f:security.ifAuthenticated>
         <f:then>
+            <v:variable.set name="feuser" value="{ot:request.getFeUser()}"/>
 
             <div class="dropdown">
                 <a href="#" class="user-toolbar-username">
                     <i class="fa fa-user"></i>
-                    {user.username}
+                    {feuser.username}
                     <i class="fa fa-caret-down"></i>
                 </a>
 

+ 1 - 1
ot_templating/Resources/Private/Partials/Modern/Topbar.html

@@ -34,7 +34,7 @@
             </div>
             <div class="col-lg-6 col-md-6">
                 <div class="topbar-social text-center text-md-right text-bold">
-                    <v:render.uncache partial="Modern/UserToolbar" arguments="{_all}" />
+                    <v:render.uncache partial="Modern/UserToolbar" />
                     <f:render partial="Modern/SocialBar" arguments="{_all}" />
                 </div>
             </div>

+ 3 - 1
ot_templating/Resources/Private/Partials/Modern/UserToolbar.html

@@ -6,8 +6,10 @@
 <ul>
     <f:security.ifAuthenticated>
         <f:then>
+            <v:variable.set name="feuser" value="{ot:request.getFeUser()}"/>
+
             <li>
-                <span><f:translate key="welcome"/> <b>{user.username}</b>!</span>
+                <span><f:translate key="welcome"/> <b>{feuser.username}</b>!</span>
             </li>
             <li>
                 <a href="{settings.opentalentDashboardUrl}">