[TASK] Improve LogEntries partial performance 64/51464/2
authorClaus Due <claus@namelesscoder.net>
Mon, 30 Jan 2017 10:06:56 +0000 (11:06 +0100)
committerMarkus Klein <markus.klein@typo3.org>
Mon, 30 Jan 2017 10:52:44 +0000 (11:52 +0100)
This patch avoids `f:switch` in the partial template,
since this ViewHelper is not compilable in the
version provided as override from TYPO3 CMS.

The patch also adds the CompileWithRenderStatic
trait to a ViewHelper used frequently in that partial.

Change-Id: I768e43e7c70a17fef04c28774169d4b3badb310b
Resolves: #79542
Releases: master
Reviewed-on: https://review.typo3.org/51464
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Philipp Gampe <philipp.gampe@typo3.org>
Tested-by: Philipp Gampe <philipp.gampe@typo3.org>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Thomas Hohn <thomas@hohn.dk>
Tested-by: Thomas Hohn <thomas@hohn.dk>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
typo3/sysext/belog/Classes/ViewHelpers/ErrorIconViewHelper.php
typo3/sysext/belog/Resources/Private/Partials/Content/LogEntries.html

index 8e0a7ea..c75633e 100644 (file)
@@ -19,6 +19,7 @@ use TYPO3\CMS\Core\Imaging\IconFactory;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Fluid\ViewHelpers\Be\AbstractBackendViewHelper;
 use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
+use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
 
 /**
  * Display error icon from error integer value
@@ -26,6 +27,8 @@ use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
  */
 class ErrorIconViewHelper extends AbstractBackendViewHelper
 {
+    use CompileWithRenderStatic;
+
     /**
      * As this ViewHelper renders HTML, the output must not be escaped.
      *
@@ -46,18 +49,6 @@ class ErrorIconViewHelper extends AbstractBackendViewHelper
      * Renders an error icon link as known from the TYPO3 backend.
      * Error codes 2 and three are mapped to "error" and 1 is mapped to "warning".
      *
-     * @return string the rendered error icon link
-     */
-    public function render()
-    {
-        return static::renderStatic(
-            $this->arguments,
-            $this->buildRenderChildrenClosure(),
-            $this->renderingContext
-        );
-    }
-
-    /**
      * @param array $arguments
      * @param \Closure $renderChildrenClosure
      * @param RenderingContextInterface $renderingContext
index f393c40..6159f59 100644 (file)
                                                                </f:if>
                                                        </td>
                                                        <td>
-                                                               <f:switch expression="{logItem.error}">
-                                                                       <f:case value="1">
-                                                                               <f:link.action action="deleteMessage" arguments="{errorUid:logItem.uid}" class="btn btn-warning"><f:translate key="actions.deleteWarnings" /></f:link.action>
-                                                                       </f:case>
-                                                                       <f:case value="2">
-                                                                               <f:link.action action="deleteMessage" arguments="{errorUid:logItem.uid}" class="btn btn-danger"><f:translate key="actions.delete" /></f:link.action>
-                                                                       </f:case>
-                                                                       <f:defaultCase />
-                                                               </f:switch>
+                                                               <f:if condition="{logItem.error} == 1">
+                                                                       <f:link.action action="deleteMessage" arguments="{errorUid:logItem.uid}" class="btn btn-warning"><f:translate key="actions.deleteWarnings" /></f:link.action>
+                                                               </f:if>
+                                                               <f:if condition="{logItem.error} == 2">
+                                                                       <f:link.action action="deleteMessage" arguments="{errorUid:logItem.uid}" class="btn btn-danger"><f:translate key="actions.delete" /></f:link.action>
+                                                               </f:if>
                                                        </td>
                                                </tr>
                                        </f:for>