[TASK] Move ViewHelper arguments to initializeArguments() in ext:beuser 70/48770/6
authorWouter Wolters <typo3@wouterwolters.nl>
Fri, 1 Jul 2016 12:27:22 +0000 (14:27 +0200)
committerSusanne Moog <typo3@susannemoog.de>
Thu, 21 Jul 2016 05:33:40 +0000 (07:33 +0200)
Resolves: #76909
Releases: master
Change-Id: Iadc46b0281bce3671be2c84aa5cf5ba276ecee47
Reviewed-on: https://review.typo3.org/48770
Tested-by: Bamboo TYPO3com <info@typo3.com>
Reviewed-by: Joerg Boesche <typo3@joergboesche.de>
Tested-by: Joerg Boesche <typo3@joergboesche.de>
Reviewed-by: Susanne Moog <typo3@susannemoog.de>
Tested-by: Susanne Moog <typo3@susannemoog.de>
typo3/sysext/beuser/Classes/ViewHelpers/ArrayElementViewHelper.php
typo3/sysext/beuser/Classes/ViewHelpers/Display/PagesViewHelper.php
typo3/sysext/beuser/Classes/ViewHelpers/Display/SysFileMountsViewHelper.php
typo3/sysext/beuser/Classes/ViewHelpers/Display/SysLanguageViewHelper.php
typo3/sysext/beuser/Classes/ViewHelpers/EditRecordViewHelper.php
typo3/sysext/beuser/Classes/ViewHelpers/IssueCommandViewHelper.php
typo3/sysext/beuser/Classes/ViewHelpers/PermissionsViewHelper.php
typo3/sysext/beuser/Classes/ViewHelpers/RemoveUserViewHelper.php
typo3/sysext/beuser/Classes/ViewHelpers/SpriteIconForRecordViewHelper.php
typo3/sysext/beuser/Classes/ViewHelpers/SwitchUserViewHelper.php

index 3ef14b7..88d50b8 100644 (file)
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Beuser\ViewHelpers;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Beuser\Exception;
 use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
 use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
 
@@ -23,24 +24,24 @@ use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
 class ArrayElementViewHelper extends AbstractViewHelper
 {
     /**
+     * Initializes the arguments
+     */
+    public function initializeArguments()
+    {
+        parent::initializeArguments();
+        $this->registerArgument('array', 'array', 'Array to search in', true);
+        $this->registerArgument('key', 'string', 'Key to return its value', true);
+        $this->registerArgument('subKey', 'string', 'If result of key access is an array, subkey can be used to fetch an element from this again', false, '');
+    }
+
+    /**
      * Return array element by key. Accessed values must be scalar (string, int, float or double)
      *
-     * @param array $array Array to search in
-     * @param string $key Key to return its value
-     * @param string $subKey If result of key access is an array, subkey can be used to fetch an element from this again
      * @return string
      */
-    public function render(array $array, $key, $subKey = '')
+    public function render()
     {
-        return static::renderStatic(
-            array(
-                'array' => $array,
-                'key' => $key,
-                'subKey' => $subKey
-            ),
-            $this->buildRenderChildrenClosure(),
-            $this->renderingContext
-        );
+        return static::renderStatic($this->arguments, $this->buildRenderChildrenClosure(), $this->renderingContext);
     }
 
     /**
@@ -49,7 +50,7 @@ class ArrayElementViewHelper extends AbstractViewHelper
      * @param array $arguments
      * @param \Closure $renderChildrenClosure
      * @param RenderingContextInterface $renderingContext
-     * @throws \TYPO3\CMS\Beuser\Exception
+     * @throws Exception
      * @return string
      */
     public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
@@ -65,10 +66,7 @@ class ArrayElementViewHelper extends AbstractViewHelper
             }
         }
         if (!is_scalar($result)) {
-            throw new \TYPO3\CMS\Beuser\Exception(
-                'Only scalar return values (string, int, float or double) are supported.',
-                1382284105
-            );
+            throw new Exception('Only scalar return values (string, int, float or double) are supported.', 1382284105);
         }
         return $result;
     }
index 61c73ef..71ea39a 100644 (file)
@@ -33,20 +33,22 @@ class PagesViewHelper extends AbstractViewHelper
     protected $escapeOutput = false;
 
     /**
+     * Initializes the arguments
+     */
+    public function initializeArguments()
+    {
+        parent::initializeArguments();
+        $this->registerArgument('uids', 'string', '', false, '');
+    }
+
+    /**
      * Render unordered list for pages
      *
-     * @param string $uids
      * @return string
      */
-    public function render($uids = '')
+    public function render()
     {
-        return static::renderStatic(
-            array(
-                'uids' => $uids,
-            ),
-            $this->buildRenderChildrenClosure(),
-            $this->renderingContext
-        );
+        return static::renderStatic($this->arguments, $this->buildRenderChildrenClosure(), $this->renderingContext);
     }
 
     /**
index cc7a059..11ce0cf 100644 (file)
@@ -33,20 +33,22 @@ class SysFileMountsViewHelper extends AbstractViewHelper
     protected $escapeOutput = false;
 
     /**
+     * Initializes the arguments
+     */
+    public function initializeArguments()
+    {
+        parent::initializeArguments();
+        $this->registerArgument('uids', 'string', '', false, '');
+    }
+
+    /**
      * Render unordered list for sys_filemounts
      *
-     * @param string $uids
      * @return string
      */
-    public function render($uids = '')
+    public function render()
     {
-        return static::renderStatic(
-            array(
-                'uids' => $uids,
-            ),
-            $this->buildRenderChildrenClosure(),
-            $this->renderingContext
-        );
+        return static::renderStatic($this->arguments, $this->buildRenderChildrenClosure(), $this->renderingContext);
     }
 
     /**
index 688142a..26b4a58 100644 (file)
@@ -33,20 +33,22 @@ class SysLanguageViewHelper extends AbstractViewHelper
     protected $escapeOutput = false;
 
     /**
+     * Initializes the arguments
+     */
+    public function initializeArguments()
+    {
+        parent::initializeArguments();
+        $this->registerArgument('uids', 'string', '', false, '');
+    }
+
+    /**
      * Render unordered list for sys_language
      *
-     * @param string $uids
      * @return string
      */
-    public function render($uids = '')
+    public function render()
     {
-        return static::renderStatic(
-            array(
-                'uids' => $uids,
-            ),
-            $this->buildRenderChildrenClosure(),
-            $this->renderingContext
-        );
+        return static::renderStatic($this->arguments, $this->buildRenderChildrenClosure(), $this->renderingContext);
     }
 
     /**
index 713851e..33a5512 100644 (file)
@@ -27,21 +27,23 @@ use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
 class EditRecordViewHelper extends AbstractViewHelper
 {
     /**
+     * Initializes the arguments
+     */
+    public function initializeArguments()
+    {
+        parent::initializeArguments();
+        $this->registerArgument('parameters', 'string', 'Is a set of GET params to send to FormEngine', true);
+    }
+
+    /**
      * Returns a URL to link to FormEngine
      *
-     * @param string $parameters Is a set of GET params to send to FormEngine
      * @return string URL to FormEngine module + parameters
      * @see \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl()
      */
-    public function render($parameters)
+    public function render()
     {
-        return static::renderStatic(
-            array(
-                'parameters' => $parameters
-            ),
-            $this->buildRenderChildrenClosure(),
-            $this->renderingContext
-        );
+        return static::renderStatic($this->arguments, $this->buildRenderChildrenClosure(), $this->renderingContext);
     }
 
     /**
index 7dcb825..e32a6e9 100644 (file)
@@ -27,24 +27,24 @@ use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
 class IssueCommandViewHelper extends AbstractViewHelper
 {
     /**
+     * Initializes the arguments
+     */
+    public function initializeArguments()
+    {
+        parent::initializeArguments();
+        $this->registerArgument('parameters', 'string', 'Is a set of GET params to send to tce_db.php. Example: "&cmd[tt_content][123][move]=456" or "&data[tt_content][123][hidden]=1&data[tt_content][123][title]=Hello%20World', true);
+        $this->registerArgument('redirectUrl', 'string', 'Redirect URL if any other that \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv(\'REQUEST_URI\') is preferred', false, '');
+    }
+
+    /**
      * Returns a URL with a command to TYPO3 Core Engine (tce_db.php)
      *
-     * @param string $parameters Is a set of GET params to send to tce_db.php. Example: "&cmd[tt_content][123][move]=456" or "&data[tt_content][123][hidden]=1&data[tt_content][123][title]=Hello%20World
-     * @param string $redirectUrl Redirect URL if any other that \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('REQUEST_URI') is wished
-     *
      * @return string URL to tce_db.php + parameters
      * @see \TYPO3\CMS\Backend\Utility\BackendUtility::getLinkToDataHandlerAction()
      */
-    public function render($parameters, $redirectUrl = '')
+    public function render()
     {
-        return static::renderStatic(
-            array(
-                'parameters' => $parameters,
-                'redirectUrl' => $redirectUrl
-            ),
-            $this->buildRenderChildrenClosure(),
-            $this->renderingContext
-        );
+        return static::renderStatic($this->arguments, $this->buildRenderChildrenClosure(), $this->renderingContext);
     }
 
     /**
index a22cd35..680344c 100644 (file)
@@ -39,14 +39,22 @@ class PermissionsViewHelper extends AbstractViewHelper
     protected static $permissionLabels = array();
 
     /**
+     * Initializes the arguments
+     */
+    public function initializeArguments()
+    {
+        parent::initializeArguments();
+        $this->registerArgument('permission', 'int', 'Current permission', true);
+        $this->registerArgument('scope', 'string', '"user" / "group" / "everybody"', true);
+        $this->registerArgument('pageId', 'int', '', true);
+    }
+
+    /**
      * Return permissions.
      *
-     * @param int $permission Current permission
-     * @param string $scope "user" / "group" / "everybody"
-     * @param int $pageId
      * @return string
      */
-    public function render($permission, $scope, $pageId)
+    public function render()
     {
         return static::renderStatic($this->arguments, $this->buildRenderChildrenClosure(), $this->renderingContext);
     }
index a71bb40..91d4722 100644 (file)
@@ -39,20 +39,22 @@ class RemoveUserViewHelper extends AbstractViewHelper
     protected $escapeOutput = false;
 
     /**
+     * Initializes the arguments
+     */
+    public function initializeArguments()
+    {
+        parent::initializeArguments();
+        $this->registerArgument('backendUser', BackendUser::class, 'Target backendUser to switch active session to', true);
+    }
+
+    /**
      * Render link with sprite icon to remove user
      *
-     * @param \TYPO3\CMS\Beuser\Domain\Model\BackendUser $backendUser Target backendUser to switch active session to
      * @return string
      */
-    public function render(BackendUser $backendUser)
+    public function render()
     {
-        return static::renderStatic(
-            array(
-                'backendUser' => $backendUser
-            ),
-            $this->buildRenderChildrenClosure(),
-            $this->renderingContext
-        );
+        return static::renderStatic($this->arguments, $this->buildRenderChildrenClosure(), $this->renderingContext);
     }
 
     /**
index ff3d5a3..e860003 100644 (file)
@@ -35,23 +35,24 @@ class SpriteIconForRecordViewHelper extends AbstractBackendViewHelper
     protected $escapeOutput = false;
 
     /**
+     * Initializes the arguments
+     */
+    public function initializeArguments()
+    {
+        parent::initializeArguments();
+        $this->registerArgument('table', 'string', '', true);
+        $this->registerArgument('object', 'object', '', true);
+    }
+
+    /**
      * Displays spriteIcon for database table and object
      *
-     * @param string $table
-     * @param object $object
      * @return string
      * @see IconFactory::getIconForRecord()
      */
-    public function render($table, $object)
+    public function render()
     {
-        return static::renderStatic(
-            array(
-                'table' => $table,
-                'object' => $object
-            ),
-            $this->buildRenderChildrenClosure(),
-            $this->renderingContext
-        );
+        return static::renderStatic($this->arguments, $this->buildRenderChildrenClosure(), $this->renderingContext);
     }
 
     /**
index 80e1982..afd4d9a 100644 (file)
@@ -36,21 +36,24 @@ class SwitchUserViewHelper extends AbstractViewHelper
     protected $escapeOutput = false;
 
     /**
+     * Initializes the arguments
+     */
+    public function initializeArguments()
+    {
+        parent::initializeArguments();
+        $this->registerArgument('backendUser', BackendUser::class, 'Target backendUser to switch active session to', true);
+    }
+
+    /**
      * Render link with sprite icon to change current backend user to target
      *
-     * @param BackendUser $backendUser Target backendUser to switch active session to
      * @return string
      */
-    public function render(BackendUser $backendUser)
+    public function render()
     {
-        return static::renderStatic(
-            array(
-                'backendUser' => $backendUser
-            ),
-            $this->buildRenderChildrenClosure(),
-            $this->renderingContext
-        );
+        return static::renderStatic($this->arguments, $this->buildRenderChildrenClosure(), $this->renderingContext);
     }
+
     /**
      * @param array $arguments
      * @param \Closure $renderChildrenClosure