Commit dbda2e0b authored by Wouter Wolters's avatar Wouter Wolters Committed by Susanne Moog
Browse files

[TASK] Move ViewHelper arguments to initializeArguments() in ext:beuser

Resolves: #76909
Releases: master
Change-Id: Iadc46b0281bce3671be2c84aa5cf5ba276ecee47
Reviewed-on: https://review.typo3.org/48770

Tested-by: default avatarBamboo TYPO3com <info@typo3.com>
Reviewed-by: default avatarJoerg Boesche <typo3@joergboesche.de>
Tested-by: default avatarJoerg Boesche <typo3@joergboesche.de>
Reviewed-by: default avatarSusanne Moog <typo3@susannemoog.de>
Tested-by: default avatarSusanne Moog <typo3@susannemoog.de>
parent 1c09482e
......@@ -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;
......@@ -22,25 +23,25 @@ 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;
}
......
......@@ -32,21 +32,23 @@ 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);
}
/**
......
......@@ -32,21 +32,23 @@ 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);
}
/**
......
......@@ -32,21 +32,23 @@ 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);
}
/**
......
......@@ -26,22 +26,24 @@ 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);
}
/**
......
......@@ -26,25 +26,25 @@ 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);
}
/**
......
......@@ -38,15 +38,23 @@ 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);
}
......
......@@ -38,21 +38,23 @@ 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);
}
/**
......
......@@ -34,24 +34,25 @@ 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);
}
/**
......
......@@ -35,22 +35,25 @@ 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
......
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