Skip to content

Commit

Permalink
[!!!][TASK] Remove CMS base ViewHelper classes
Browse files Browse the repository at this point in the history
This patch sacrifices two features:

* Having $this->controllerContext on ViewHelpers
* Support for render method arguments

And by doing so, allows the removal of every CMS
base ViewHelper class and several overrides they
implement. The base classes are still available as
class aliases to limit the breaking change to the two
features mentioned above.

Change-Id: I425b01234618f83d701ec6dd99ce3bf7ce514589
Resolves: #82414
Releases: master
Reviewed-on: https://review.typo3.org/54068
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
  • Loading branch information
NamelessCoder authored and georgringer committed Dec 5, 2017
1 parent ea436df commit 533a1a3
Show file tree
Hide file tree
Showing 31 changed files with 179 additions and 995 deletions.
@@ -0,0 +1,52 @@
.. include:: ../../Includes.txt

======================================================
Breaking: #82414 - CMS ViewHelper base classes removed
======================================================

See :issue:`82414`

Description
===========

The following ViewHelper base classes have been removed:

- :php:`TYPO3\CMS\Fluid\Core\ViewHelper\AbstractConditionViewHelper`
- :php:`TYPO3\CMS\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper`
- :php:`TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper`
- :php:`TYPO3\CMS\Fluid\Core\ViewHelper\ArgumentDefinition`

Aliases are in place, but the following key differences may break your code:

- Render method arguments are no longer possible at all
- The property :php:`$this->controllerContext` is no longer defined


Impact
======

Render method arguments have been deprecated for a long time and should already have been migrated
in your code. If you still have ViewHelpers using render method arguments, these will break
after this change.


Affected Installations
======================

All instances which use a ViewHelper that either contains render method arguments, extends from one
of the base classes above, or or accesses :php:`$this->controllerContext`.


Migration
=========

Migrate to use `renderStatic` methods (see examples in TYPO3 Core, EXT:fluid) to not use
render method arguments.


ViewHelpers which access :php:`$this->controllerContext` can instead access
:php:`$this->renderingContext->getControllerContext()`.

Migrating this can be done with search-and-replace for all common use cases.

.. index:: Fluid, NotScanned
Expand Up @@ -49,7 +49,7 @@ public function render()

$content = (string)$this->renderChildren();
if ($extension['installed'] && file_exists(PATH_site . $extension['siteRelPath'] . 'ext_conf_template.txt')) {
$uriBuilder = $this->controllerContext->getUriBuilder();
$uriBuilder = $this->renderingContext->getControllerContext()->getUriBuilder();
$action = 'showConfigurationForm';
$uri = $uriBuilder->reset()->uriFor(
$action,
Expand Down
Expand Up @@ -90,7 +90,7 @@ public function render()
</li>';
}
$pathSelector .= '</ul>';
$uriBuilder = $this->controllerContext->getUriBuilder();
$uriBuilder = $this->renderingContext->getControllerContext()->getUriBuilder();
$action = 'checkDependencies';
$uriBuilder->reset();
$uriBuilder->setFormat('json');
Expand Down Expand Up @@ -138,7 +138,7 @@ protected function getFieldNamePrefix()
*/
protected function getDefaultFieldNamePrefix()
{
$request = $this->controllerContext->getRequest();
$request = $this->renderingContext->getControllerContext()->getRequest();
if ($this->hasArgument('extensionName')) {
$extensionName = $this->arguments['extensionName'];
} else {
Expand Down
Expand Up @@ -26,6 +26,19 @@ class ActionViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractTagBased
*/
protected $tagName = 'a';

/**
* @var \TYPO3\CMS\Extbase\Object\ObjectManagerInterface
*/
protected $objectManager;

/**
* @param \TYPO3\CMS\Extbase\Object\ObjectManagerInterface $objectManager
*/
public function injectObjectManager(\TYPO3\CMS\Extbase\Object\ObjectManagerInterface $objectManager)
{
$this->objectManager = $objectManager;
}

/**
* Arguments initialization
*/
Expand Down
Expand Up @@ -70,7 +70,7 @@ public function render()
$languageKey = 'extensionList.databaseImport';
}

$uriBuilder = $this->controllerContext->getUriBuilder();
$uriBuilder = $this->renderingContext->getControllerContext()->getUriBuilder();
$uriBuilder->reset();
$uri = $uriBuilder->uriFor('reloadExtensionData', ['extension' => $extension['key']], 'Action');
$this->tag->addAttribute('href', $uri);
Expand Down
Expand Up @@ -53,7 +53,7 @@ public function render()
) {
return '<span class="btn btn-default disabled">' . $iconFactory->getIcon('empty-empty', Icon::SIZE_SMALL)->render() . '</span>';
}
$uriBuilder = $this->controllerContext->getUriBuilder();
$uriBuilder = $this->renderingContext->getControllerContext()->getUriBuilder();
$action = 'removeExtension';
$uriBuilder->reset();
$uriBuilder->setFormat('json');
Expand Down
Expand Up @@ -46,7 +46,7 @@ public function render()
/** @var Extension $extension */
$extension = $this->arguments['extension'];

$uriBuilder = $this->controllerContext->getUriBuilder();
$uriBuilder = $this->renderingContext->getControllerContext()->getUriBuilder();
$action = 'showAllVersions';
$uri = $uriBuilder->reset()->uriFor($action, [
'extensionKey' => $extension->getExtensionKey(),
Expand Down
Expand Up @@ -56,7 +56,7 @@ public function render()
return '';
}

$uriBuilder = $this->controllerContext->getUriBuilder();
$uriBuilder = $this->renderingContext->getControllerContext()->getUriBuilder();
$action = 'toggleExtensionInstallationState';
$uri = $uriBuilder->reset()->uriFor($action, [
'extensionKey' => $extension['key']
Expand Down
Expand Up @@ -24,19 +24,6 @@
*/
class UpdateScriptViewHelper extends Link\ActionViewHelper
{
/**
* @var \TYPO3\CMS\Extbase\Object\ObjectManagerInterface
*/
protected $objectManager;

/**
* @param \TYPO3\CMS\Extbase\Object\ObjectManagerInterface $objectManager
*/
public function injectObjectManager(\TYPO3\CMS\Extbase\Object\ObjectManagerInterface $objectManager)
{
$this->objectManager = $objectManager;
}

/**
* initialize arguments
*/
Expand All @@ -62,7 +49,7 @@ public function render()
/** @var IconFactory $iconFactory */
$iconFactory = GeneralUtility::makeInstance(IconFactory::class);
if ($updateScriptUtility->checkUpdateScriptExists($extensionKey)) {
$uriBuilder = $this->controllerContext->getUriBuilder();
$uriBuilder = $this->renderingContext->getControllerContext()->getUriBuilder();
$action = 'show';
$uri = $uriBuilder->reset()->uriFor(
$action,
Expand Down

This file was deleted.

This file was deleted.

0 comments on commit 533a1a3

Please sign in to comment.