Commit 6285f05c authored by Markus Klein's avatar Markus Klein Committed by Christian Kuhn
Browse files

[BUGFIX] Use late static binding for compilable viewhelpers

Using self::renderStatic() in the render method of the viewhelpers
forces extending viewhelpers to copy the render method, which is
useless overhead.

Adjust all viewhelpers to use static::renderStatic() instead to
allow for late static binding.

Resolves: #67420
Releases: master
Change-Id: I12ca42a16365ee2baceeca6a17193e5f6877ed27
Reviewed-on: http://review.typo3.org/40184

Reviewed-by: default avatarHelmut Hummel <helmut.hummel@typo3.org>
Reviewed-by: Stephan Großberndt's avatarStephan Großberndt <stephan@grossberndt.de>
Reviewed-by: Mathias Brodala's avatarMathias Brodala <mbrodala@pagemachine.de>
Reviewed-by: Andreas Fernandez's avatarAndreas Fernandez <typo3@scripting-base.de>
Tested-by: Andreas Fernandez's avatarAndreas Fernandez <typo3@scripting-base.de>
Reviewed-by: default avatarManuel Selbach <m.selbach@reply.de>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
parent a2dbe0cf
......@@ -35,7 +35,14 @@ class SpriteManagerIconViewHelper extends AbstractViewHelper implements Compilab
* @return string
*/
public function render($iconName, $options = array()) {
return self::renderStatic(array('iconName' => $iconName, 'options' => $options), $this->buildRenderChildrenClosure(), $this->renderingContext);
return static::renderStatic(
array(
'iconName' => $iconName,
'options' => $options
),
$this->buildRenderChildrenClosure(),
$this->renderingContext
);
}
/**
......
......@@ -13,6 +13,7 @@ namespace TYPO3\CMS\Belog\ViewHelpers\Be;
*
* The TYPO3 project - inspiring people to share!
*/
use TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface;
use TYPO3\CMS\Fluid\Core\ViewHelper\Facets\CompilableInterface;
use TYPO3\CMS\Fluid\ViewHelpers\Be\AbstractBackendViewHelper;
......@@ -33,7 +34,7 @@ class PagePathViewHelper extends AbstractBackendViewHelper implements Compilable
* @return string Page path string
*/
public function render($pid, $titleLimit = 20) {
return self::renderStatic(
return static::renderStatic(
array(
'pid' => $pid,
'titleLimit' => $titleLimit
......
......@@ -13,6 +13,7 @@ namespace TYPO3\CMS\Belog\ViewHelpers;
*
* The TYPO3 project - inspiring people to share!
*/
use TYPO3\CMS\Backend\Template\DocumentTemplate;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface;
......@@ -35,8 +36,7 @@ class ErrorIconViewHelper extends AbstractBackendViewHelper implements Compilabl
* @return string the rendered error icon link
*/
public function render($errorNumber = 0) {
return self::renderStatic(
return static::renderStatic(
array(
'errorNumber' => $errorNumber
),
......
......@@ -13,6 +13,7 @@ namespace TYPO3\CMS\Belog\ViewHelpers;
*
* The TYPO3 project - inspiring people to share!
*/
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
use TYPO3\CMS\Belog\Domain\Model\LogEntry;
use TYPO3\CMS\Fluid\Core\ViewHelper\Facets\CompilableInterface;
......@@ -39,7 +40,7 @@ class FormatDetailsViewHelper extends AbstractViewHelper implements CompilableIn
* @return string Formatted details
*/
public function render(LogEntry $logEntry) {
return self::renderStatic(
return static::renderStatic(
array(
'logEntry' => $logEntry
),
......
......@@ -13,6 +13,7 @@ namespace TYPO3\CMS\Belog\ViewHelpers;
*
* The TYPO3 project - inspiring people to share!
*/
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Backend\Utility\IconUtility;
use TYPO3\CMS\Belog\Domain\Model\HistoryEntry;
......@@ -39,7 +40,7 @@ class HistoryEntryViewHelper extends AbstractViewHelper implements CompilableInt
* @return string Formatted history entry if one exists, else empty string
*/
public function render($uid) {
return self::renderStatic(
return static::renderStatic(
array(
'uid' => $uid
),
......@@ -86,5 +87,5 @@ class HistoryEntryViewHelper extends AbstractViewHelper implements CompilableInt
$historyLink = '<a href="' . htmlspecialchars($historyHref) . '">' . $historyIcon . '</a>';
return $historyLabel . '&nbsp;' . $historyLink;
}
}
}
......@@ -13,6 +13,7 @@ namespace TYPO3\CMS\Belog\ViewHelpers;
*
* The TYPO3 project - inspiring people to share!
*/
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface;
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
......@@ -33,7 +34,7 @@ class IsExtensionLoadedViewHelper extends AbstractViewHelper implements Compilab
* @return bool TRUE if extension is loaded, FALSE otherwise
*/
public function render($extensionKey) {
return self::renderStatic(
return static::renderStatic(
array(
'extensionKey' => $extensionKey
),
......@@ -52,4 +53,5 @@ class IsExtensionLoadedViewHelper extends AbstractViewHelper implements Compilab
static public function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) {
return ExtensionManagementUtility::isLoaded($arguments['extensionKey']);
}
}
......@@ -40,7 +40,7 @@ class UsernameViewHelper extends AbstractViewHelper implements CompilableInterfa
* @return string Username or an empty string if there is no user with that UID
*/
public function render($uid) {
return self::renderStatic(
return static::renderStatic(
array(
'uid' => $uid
),
......
......@@ -40,7 +40,7 @@ class WorkspaceTitleViewHelper extends AbstractViewHelper implements CompilableI
* @return string workspace title or UID
*/
public function render($uid) {
return self::renderStatic(
return static::renderStatic(
array(
'uid' => $uid
),
......
......@@ -32,7 +32,15 @@ class ArrayElementViewHelper extends AbstractViewHelper implements CompilableInt
* @return string
*/
public function render(array $array, $key, $subKey = '') {
return self::renderStatic(array('array' => $array, 'key' => $key, 'subKey' => $subKey), $this->buildRenderChildrenClosure(), $this->renderingContext);
return static::renderStatic(
array(
'array' => $array,
'key' => $key,
'subKey' => $subKey
),
$this->buildRenderChildrenClosure(),
$this->renderingContext
);
}
/**
......
......@@ -33,7 +33,7 @@ class PagesViewHelper extends AbstractViewHelper implements CompilableInterface
* @return string
*/
public function render($uids = '') {
return self::renderStatic(
return static::renderStatic(
array(
'uids' => $uids,
),
......
......@@ -33,7 +33,7 @@ class SysFileMountsViewHelper extends AbstractViewHelper implements CompilableIn
* @return string
*/
public function render($uids = '') {
return self::renderStatic(
return static::renderStatic(
array(
'uids' => $uids,
),
......
......@@ -33,7 +33,7 @@ class SysLanguageViewHelper extends AbstractViewHelper implements CompilableInte
* @return string
*/
public function render($uids = '') {
return self::renderStatic(
return static::renderStatic(
array(
'uids' => $uids,
),
......
......@@ -35,7 +35,7 @@ class EditRecordViewHelper extends AbstractViewHelper implements CompilableInter
* @see \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl()
*/
public function render($parameters) {
return self::renderStatic(
return static::renderStatic(
array(
'parameters' => $parameters
),
......@@ -55,4 +55,5 @@ class EditRecordViewHelper extends AbstractViewHelper implements CompilableInter
$parameters = GeneralUtility::explodeUrl2Array($arguments['parameters']);
return BackendUtility::getModuleUrl('record_edit', $parameters);
}
}
......@@ -40,7 +40,7 @@ class IssueCommandViewHelper extends AbstractViewHelper implements CompilableInt
* @see \TYPO3\CMS\Backend\Template\DocumentTemplate::issueCommand()
*/
public function render($parameters, $redirectUrl = '') {
return self::renderStatic(
return static::renderStatic(
array(
'parameters' => $parameters,
'redirectUrl' => $redirectUrl
......@@ -68,4 +68,5 @@ class IssueCommandViewHelper extends AbstractViewHelper implements CompilableInt
];
return htmlspecialchars(BackendUtility::getModuleUrl('tce_db', $urlParameters) . $arguments['parameters'] . BackendUtility::getUrlToken('tceAction'));
}
}
......@@ -38,7 +38,7 @@ class RemoveUserViewHelper extends AbstractViewHelper implements CompilableInter
* @return string
*/
public function render(BackendUser $backendUser) {
return self::renderStatic(
return static::renderStatic(
array(
'backendUser' => $backendUser
),
......
......@@ -13,6 +13,7 @@ namespace TYPO3\CMS\Beuser\ViewHelpers;
*
* The TYPO3 project - inspiring people to share!
*/
use TYPO3\CMS\Backend\Utility\IconUtility;
use TYPO3\CMS\Extbase\Domain\Model\BackendUser;
use TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface;
......@@ -36,7 +37,7 @@ class SpriteIconForRecordViewHelper extends AbstractBackendViewHelper implements
* @see \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord($table, $row)
*/
public function render($table, $object) {
return self::renderStatic(
return static::renderStatic(
array(
'table' => $table,
'object' => $object
......
......@@ -37,7 +37,7 @@ class SwitchUserViewHelper extends AbstractViewHelper implements CompilableInter
* @return string
*/
public function render(BackendUser $backendUser) {
return self::renderStatic(
return static::renderStatic(
array(
'backendUser' => $backendUser
),
......@@ -64,4 +64,5 @@ class SwitchUserViewHelper extends AbstractViewHelper implements CompilableInter
'" target="_top" title="' . htmlspecialchars($title) . '">' .
IconUtility::getSpriteIcon(('actions-system-backend-user-switch')) . '</a>';
}
}
......@@ -35,7 +35,7 @@ class FormatsViewHelper extends AbstractViewHelper implements CompilableInterfac
* @return string
*/
public function render(\TYPO3\CMS\Documentation\Domain\Model\DocumentTranslation $documentTranslation) {
return self::renderStatic(
return static::renderStatic(
array(
'documentTranslation' => $documentTranslation,
),
......
......@@ -35,7 +35,7 @@ class ImplodeViewHelper extends AbstractViewHelper implements CompilableInterfac
* @api
*/
public function render(array $implode, $delimiter = ', ') {
return self::renderStatic(
return static::renderStatic(
array(
'implode' => $implode,
'delimiter' => $delimiter,
......
......@@ -42,7 +42,7 @@ class JsonEncodeViewHelper extends AbstractViewHelper implements CompilableInter
* @api
*/
public function render() {
return self::renderStatic(
return static::renderStatic(
$this->arguments,
$this->buildRenderChildrenClosure(),
$this->renderingContext
......
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