[TASK] Make ViewHelpers compilable in ext:extensionmanager 36/39236/3
authorWouter Wolters <typo3@wouterwolters.nl>
Sun, 3 May 2015 11:58:28 +0000 (13:58 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Mon, 4 May 2015 11:57:15 +0000 (13:57 +0200)
Format/ImplodeViewHelper
InstallationStateCssClassViewHelper
TimeSinceLastUpdateViewHelper
Typo3DependencyViewHelper

Resolves: #66774
Releases: master
Change-Id: I5ed2bde90bc95f7c0cc71b001f565e024d403023
Reviewed-on: http://review.typo3.org/39236
Reviewed-by: Andreas Fernandez <typo3@scripting-base.de>
Tested-by: Andreas Fernandez <typo3@scripting-base.de>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/extensionmanager/Classes/ViewHelpers/Format/ImplodeViewHelper.php
typo3/sysext/extensionmanager/Classes/ViewHelpers/InstallationStateCssClassViewHelper.php
typo3/sysext/extensionmanager/Classes/ViewHelpers/TimeSinceLastUpdateViewHelper.php
typo3/sysext/extensionmanager/Classes/ViewHelpers/Typo3DependencyViewHelper.php

index f5a507e..4eba9e8 100644 (file)
@@ -14,13 +14,17 @@ namespace TYPO3\CMS\Extensionmanager\ViewHelpers\Format;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
+use TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface;
+use TYPO3\CMS\Fluid\Core\ViewHelper\Facets\CompilableInterface;
+
 /**
  * View Helper for imploding arrays
  *
  * @author Susanne Moog <typo3@susannemoog.de>
  * @internal
  */
-class ImplodeViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper {
+class ImplodeViewHelper extends AbstractViewHelper implements CompilableInterface {
 
        /**
         * Implodes a string
@@ -31,7 +35,25 @@ class ImplodeViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHel
         * @api
         */
        public function render(array $implode, $delimiter = ', ') {
-               return implode($delimiter, $implode);
+               return self::renderStatic(
+                       array(
+                               'implode' => $implode,
+                               'delimiter' => $delimiter,
+                       ),
+                       $this->buildRenderChildrenClosure(),
+                       $this->renderingContext
+               );
+       }
+
+       /**
+        * @param array $arguments
+        * @param callable $renderChildrenClosure
+        * @param RenderingContextInterface $renderingContext
+        *
+        * @return string
+        */
+       static public function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) {
+               return implode($arguments['delimiter'], $arguments['implode']);
        }
 
 }
index 5eb0c39..1c9a21b 100644 (file)
@@ -14,6 +14,10 @@ namespace TYPO3\CMS\Extensionmanager\ViewHelpers;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
+use TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface;
+use TYPO3\CMS\Fluid\Core\ViewHelper\Facets\CompilableInterface;
+
 /**
  * Returns a string meant to be used as css class stating whether an extension is
  * available or installed
@@ -21,7 +25,7 @@ namespace TYPO3\CMS\Extensionmanager\ViewHelpers;
  * @author Susanne Moog <susanne.moog@typo3.org>
  * @internal
  */
-class InstallationStateCssClassViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper {
+class InstallationStateCssClassViewHelper extends AbstractViewHelper implements CompilableInterface {
 
        /**
         * Returns string meant to be used as css class
@@ -34,6 +38,26 @@ class InstallationStateCssClassViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelp
         * @return string the rendered a tag
         */
        public function render($needle, array $haystack) {
+               return self::renderStatic(
+                       array(
+                               'needle' => $needle,
+                               'haystack' => $haystack,
+                       ),
+                       $this->buildRenderChildrenClosure(),
+                       $this->renderingContext
+               );
+       }
+
+       /**
+        * @param array $arguments
+        * @param callable $renderChildrenClosure
+        * @param RenderingContextInterface $renderingContext
+        *
+        * @return string
+        */
+       static public function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) {
+               $needle = $arguments['needle'];
+               $haystack = $arguments['haystack'];
                if (array_key_exists($needle, $haystack)) {
                        if (isset($haystack[$needle]['installed']) && $haystack[$needle]['installed'] === TRUE) {
                                return 'installed';
index 41ccef6..a92b349 100644 (file)
@@ -14,13 +14,17 @@ namespace TYPO3\CMS\Extensionmanager\ViewHelpers;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
+use TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface;
+use TYPO3\CMS\Fluid\Core\ViewHelper\Facets\CompilableInterface;
+
 /**
  * Shows the elapsed time since the last update of the extension repository
  * from TER in a readable manner.
  *
  * @internal
  */
-class TimeSinceLastUpdateViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper {
+class TimeSinceLastUpdateViewHelper extends AbstractViewHelper implements CompilableInterface {
 
        /**
         * Render method
@@ -29,6 +33,24 @@ class TimeSinceLastUpdateViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\Abs
         * @return string
         */
        public function render($lastUpdateTime) {
+               return self::renderStatic(
+                       array(
+                               'lastUpdateTime' => $lastUpdateTime,
+                       ),
+                       $this->buildRenderChildrenClosure(),
+                       $this->renderingContext
+               );
+       }
+
+       /**
+        * @param array $arguments
+        * @param callable $renderChildrenClosure
+        * @param RenderingContextInterface $renderingContext
+        *
+        * @return string
+        */
+       static public function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) {
+               $lastUpdateTime = $arguments['lastUpdateTime'];
                if (NULL === $lastUpdateTime) {
                        return $GLOBALS['LANG']->sL(
                                'LLL:EXT:extensionmanager/Resources/Private/Language/locallang.xlf:extensionList.updateFromTer.never'
index c74163a..8cfb241 100644 (file)
@@ -18,13 +18,16 @@ use TYPO3\CMS\Core\Utility\MathUtility;
 use TYPO3\CMS\Core\Utility\VersionNumberUtility;
 use TYPO3\CMS\Extensionmanager\Domain\Model\Dependency;
 use TYPO3\CMS\Extensionmanager\Domain\Model\Extension;
+use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
+use TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface;
+use TYPO3\CMS\Fluid\Core\ViewHelper\Facets\CompilableInterface;
 
 /**
  * Shows the version numbers of the TYPO3 dependency, if any
  *
  * @internal
  */
-class Typo3DependencyViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper {
+class Typo3DependencyViewHelper extends AbstractViewHelper implements CompilableInterface {
 
        /**
         * Finds and returns the suitable TYPO3 versions of an extension
@@ -33,12 +36,30 @@ class Typo3DependencyViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\Abstrac
         * @return string
         */
        public function render(Extension $extension) {
+               return self::renderStatic(
+                       array(
+                               'extension' => $extension,
+                       ),
+                       $this->buildRenderChildrenClosure(),
+                       $this->renderingContext
+               );
+       }
+
+       /**
+        * @param array $arguments
+        * @param callable $renderChildrenClosure
+        * @param RenderingContextInterface $renderingContext
+        *
+        * @return string
+        */
+       static public function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) {
+               $extension = $arguments['extension'];
                /** @var Dependency $dependency */
                foreach ($extension->getDependencies() as $dependency) {
                        if ($dependency->getIdentifier() === 'typo3') {
                                $lowestVersion = $dependency->getLowestVersion();
                                $highestVersion = $dependency->getHighestVersion();
-                               $cssClass = $this->isVersionSuitable($lowestVersion, $highestVersion) ? 'success' : 'default';
+                               $cssClass = self::isVersionSuitable($lowestVersion, $highestVersion) ? 'success' : 'default';
                                return
                                        '<span class="label label-' . $cssClass . '">'
                                                . htmlspecialchars($lowestVersion) . ' - ' . htmlspecialchars($highestVersion)
@@ -55,7 +76,7 @@ class Typo3DependencyViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\Abstrac
         * @param string $highestVersion
         * @return bool
         */
-       protected function isVersionSuitable($lowestVersion, $highestVersion) {
+       static protected function isVersionSuitable($lowestVersion, $highestVersion) {
                $numericTypo3Version = VersionNumberUtility::convertVersionNumberToInteger(VersionNumberUtility::getNumericTypo3Version());
                $numericLowestVersion = VersionNumberUtility::convertVersionNumberToInteger($lowestVersion);
                $numericHighestVersion = VersionNumberUtility::convertVersionNumberToInteger($highestVersion);