Commit 5d4032a4 authored by Christian Kuhn's avatar Christian Kuhn
Browse files

[!!!][TASK] Remove deprecated fluid view related classes

Needs a styleguide raise

composer u typo3/cms-styleguide

Resolves: #96174
Related: #94991
Related: #95005
Related: #95164
Related: #95222
Related: #95003
Change-Id: Iba811bf554a5ad575080950c221cc5185281435d
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/72436


Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
Tested-by: Stefan Bürk's avatarStefan Bürk <stefan@buerk.tech>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Stefan Bürk's avatarStefan Bürk <stefan@buerk.tech>
Reviewed-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
parent 68b9560e
......@@ -8144,12 +8144,12 @@
"source": {
"type": "git",
"url": "https://github.com/TYPO3/styleguide.git",
"reference": "c50050700146892f746b81e63946e076144d03bb"
"reference": "d3b947caaf099f8bd7b6dce7c0fb75352bb7e6d9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/TYPO3/styleguide/zipball/c50050700146892f746b81e63946e076144d03bb",
"reference": "c50050700146892f746b81e63946e076144d03bb",
"url": "https://api.github.com/repos/TYPO3/styleguide/zipball/d3b947caaf099f8bd7b6dce7c0fb75352bb7e6d9",
"reference": "d3b947caaf099f8bd7b6dce7c0fb75352bb7e6d9",
"shasum": ""
},
"require-dev": {
......@@ -8157,7 +8157,7 @@
"codeception/module-asserts": "^1.2",
"codeception/module-cli": "^1.1",
"codeception/module-webdriver": "^1.1",
"phpstan/phpstan": "^0.12.37",
"phpstan/phpstan": "^1.2.0",
"typo3/cms-core": "~12.0@dev",
"typo3/cms-frontend": "~12.0@dev",
"typo3/cms-install": "~12.0@dev",
......@@ -8209,7 +8209,7 @@
"issues": "https://github.com/TYPO3/styleguide/issues",
"source": "https://github.com/TYPO3/styleguide/tree/main"
},
"time": "2021-11-30T13:42:17+00:00"
"time": "2021-12-01T12:02:28+00:00"
},
{
"name": "typo3/testing-framework",
......
<?php
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
namespace TYPO3\CMS\Backend\View;
use TYPO3\CMS\Backend\Template\ModuleTemplate;
use TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext;
use TYPO3\CMS\Extbase\Mvc\View\ViewInterface;
use TYPO3\CMS\Fluid\View\TemplateView;
/**
* Decorates the main template view. Should be used as view if you want to use
* Fluid templates in a backend module in order to have a consistent backend.
*
* @deprecated since v11, will be removed with v12.
*/
class BackendTemplateView implements ViewInterface
{
/**
* @var ModuleTemplate
*/
protected $moduleTemplate;
/**
* @var TemplateView
*/
protected $templateView;
/**
* @param ModuleTemplate $moduleTemplate
*/
public function injectModuleTemplate(ModuleTemplate $moduleTemplate)
{
$this->moduleTemplate = $moduleTemplate;
}
/**
* @param TemplateView $templateView
*/
public function injectTemplateView(TemplateView $templateView)
{
$this->templateView = $templateView;
}
/**
* @return ModuleTemplate
*/
public function getModuleTemplate()
{
return $this->moduleTemplate;
}
/**
* Loads the template source and render the template.
* If "layoutName" is set in a PostParseFacet callback, it will render the file with the given layout.
*
* Additionally amends the rendered template with a module template "frame"
*
* @param string $actionName If set, the view of the specified action will be rendered instead. Default is the action specified in the Request object
* @return string Rendered Template
*/
public function render($actionName = null)
{
$actionViewContent = $this->templateView->render($actionName);
$this->moduleTemplate->setContent($actionViewContent);
return $this->moduleTemplate->renderContent();
}
/**
* Sets the current controller context
*
* @param \TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext $controllerContext Controller context which is available inside the view
* @deprecated since v11, will be removed with v12.
*/
public function setControllerContext(ControllerContext $controllerContext)
{
$this->templateView->setControllerContext($controllerContext);
}
/**
* Assign a value to the variable container.
*
* @param string $key The key of a view variable to set
* @param mixed $value The value of the view variable
* @return \TYPO3\CMS\Fluid\View\AbstractTemplateView the instance of this view to allow chaining
*/
public function assign($key, $value)
{
$this->templateView->assign($key, $value);
return $this;
}
/**
* Assigns multiple values to the JSON output.
* However, only the key "value" is accepted.
*
* @param array $values Keys and values - only a value with key "value" is considered
* @return \TYPO3\CMS\Fluid\View\AbstractTemplateView the instance of this view to allow chaining
*/
public function assignMultiple(array $values)
{
$this->templateView->assignMultiple($values);
return $this;
}
/**
* Checks whether a template can be resolved for the current request context.
*
* @return bool
* @deprecated since TYPO3 v11, will be removed in v12. Legacy method, not part of ViewInterface anymore.
*/
public function canRender()
{
// Deprecation logged by AbstractTemplateView
return $this->templateView->canRender();
}
/**
* Init view
*/
public function initializeView()
{
if (method_exists($this->templateView, 'initializeView')) {
$this->templateView->initializeView();
}
}
/**
* Set the root path(s) to the templates.
*
* @param array $templateRootPaths Root path(s) to the templates.
*/
public function setTemplateRootPaths(array $templateRootPaths)
{
$this->templateView->setTemplateRootPaths($templateRootPaths);
}
/**
* Set the root path(s) to the partials.
*
* @param array $partialRootPaths Root paths to the partials.
*/
public function setPartialRootPaths(array $partialRootPaths)
{
$this->templateView->setPartialRootPaths($partialRootPaths);
}
/**
* Set the root path(s) to the layouts.
*
* @param array $layoutRootPaths Root path to the layouts.
*/
public function setLayoutRootPaths(array $layoutRootPaths)
{
$this->templateView->setLayoutRootPaths($layoutRootPaths);
}
}
......@@ -41,10 +41,10 @@ use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
use TYPO3\CMS\Extbase\Mvc\Exception\StopActionException;
use TYPO3\CMS\Extbase\Mvc\Request;
use TYPO3\CMS\Extbase\Mvc\RequestInterface;
use TYPO3\CMS\Extbase\Mvc\View\ViewInterface;
use TYPO3\CMS\Extbase\Pagination\QueryResultPaginator;
use TYPO3\CMS\Extbase\Persistence\QueryResultInterface;
use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
use TYPO3Fluid\Fluid\View\ViewInterface;
/**
* Backend module user and user group administration controller
......@@ -124,7 +124,6 @@ class BackendUserController extends ActionController
/**
* Assign default variables to view
* @param ViewInterface $view
* @todo v12: Change signature to TYPO3Fluid\Fluid\View\ViewInterface when extbase ViewInterface is dropped.
*/
protected function initializeView(ViewInterface $view): void
{
......
......@@ -42,7 +42,15 @@ empty. To simplify compatibility for extensions supporting both TYPO3 v11 and TY
that empty method will be removed in TYPO3 v12, but will still be called if it exists in classes
extending :php:`ActionController`.
Extension authors should thus avoid calling :php:`parent::initializeView($view)` in their
implementation of :php:`initializeView()` to prepare towards TYPO3 v12.
implementation of :php:`initializeView()` to prepare towards TYPO3 v12. Additionally, extension
authors should adapt the method signature to avoid a PHP contravariance violation:
.. code-block:: php
// Old:
protected function initializeView(ViewInterface $view)
// New:
protected function initializeView($view)
Apart from that, usages of `TYPO3\CMS\Extbase\Mvc\View\ViewInterface` should be changed
to the more specific :php:`TYPO3\CMS\Fluid\View\StandaloneView` - usually in non-Extbase
......
......@@ -11,6 +11,7 @@ Description
The following PHP classes that have previously been marked as deprecated for v11 and were now removed:
- :php:`\TYPO3\CMS\Backend\View\BackendTemplateView`
- :php:`\TYPO3\CMS\Core\Cache\Backend\PdoBackend`
- :php:`\TYPO3\CMS\Core\Cache\Backend\WincacheBackend`
- :php:`\TYPO3\CMS\Core\Category\CategoryRegistry`
......@@ -27,12 +28,15 @@ The following PHP classes that have previously been marked as deprecated for v11
- :php:`\TYPO3\CMS\Extbase\Domain\Repository\CategoryRepository`
- :php:`\TYPO3\CMS\Extbase\Domain\Repository\FrontendUserGroupRepository`
- :php:`\TYPO3\CMS\Extbase\Domain\Repository\FrontendUserRepository`
- :php:`\TYPO3\CMS\Extbase\Mvc\View\AbstractView`
- :php:`\TYPO3\CMS\Extbase\Mvc\View\EmptyView`
- :php:`\TYPO3\CMS\Extbase\Service\EnvironmentService`
- :php:`\TYPO3\CMS\Frontend\ContentObject\EditPanelContentObject`
The following PHP interfaces that have previously been marked as deprecated for v11 and were now removed:
- :php:`\TYPO3\CMS\Core\Resource\Hook\FileDumpEIDHookInterface`
- :php:`\TYPO3\CMS\Extbase\Mvc\View\ViewInterface`
- :php:`\TYPO3\CMS\Recordlist\RecordList\RecordListHookInterface`
The following PHP class aliases that have previously been marked as deprecated for v11 and were now removed:
......
......@@ -42,7 +42,6 @@ use TYPO3\CMS\Extbase\Mvc\Request;
use TYPO3\CMS\Extbase\Mvc\RequestInterface;
use TYPO3\CMS\Extbase\Mvc\View\GenericViewResolver;
use TYPO3\CMS\Extbase\Mvc\View\JsonView;
use TYPO3\CMS\Extbase\Mvc\View\ViewInterface;
use TYPO3\CMS\Extbase\Mvc\View\ViewResolverInterface;
use TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder;
use TYPO3\CMS\Extbase\Object\ObjectManagerInterface;
......@@ -57,6 +56,7 @@ use TYPO3\CMS\Extbase\Validation\Validator\ValidatorInterface;
use TYPO3\CMS\Extbase\Validation\ValidatorResolver;
use TYPO3\CMS\Fluid\View\TemplateView;
use TYPO3Fluid\Fluid\View\AbstractTemplateView;
use TYPO3Fluid\Fluid\View\ViewInterface;
/**
* A multi action controller. This is by far the most common base class for Controllers.
......@@ -95,7 +95,6 @@ abstract class ActionController implements ControllerInterface
* The current view, as resolved by resolveView()
*
* @var ViewInterface
* @todo v12: Change signature to TYPO3Fluid\Fluid\View\ViewInterface when extbase ViewInterface is dropped.
*/
protected $view;
......@@ -323,19 +322,6 @@ abstract class ActionController implements ControllerInterface
$this->internalExtensionService = $extensionService;
}
/**
* Initializes the view before invoking an action method.
*
* Override this method to solve assign variables common for all actions
* or prepare the view in another way before the action is called.
*
* @param ViewInterface $view The view to be initialized
* @deprecated since v11, will be removed in v12: Drop method along with extbase ViewInterface.
*/
protected function initializeView(ViewInterface $view)
{
}
/**
* Initializes the controller before invoking an action method.
*
......@@ -611,12 +597,9 @@ abstract class ActionController implements ControllerInterface
* Prepares a view for the current action.
* By default, this method tries to locate a view with a name matching the current action.
*
* @return ViewInterface
* @todo v12: Change signature to TYPO3Fluid\Fluid\View\ViewInterface when extbase ViewInterface is dropped.
*
* @internal only to be used within Extbase, not part of TYPO3 Core API.
*/
protected function resolveView()
protected function resolveView(): ViewInterface
{
if ($this->viewResolver instanceof GenericViewResolver) {
/*
......@@ -639,21 +622,12 @@ abstract class ActionController implements ControllerInterface
if (method_exists($view, 'injectSettings')) {
$view->injectSettings($this->settings);
}
if (method_exists($view, 'initializeView')) {
// @deprecated since v11, will be removed with v12. Drop together with removal of extbase ViewInterface.
$view->initializeView();
}
// In TYPO3.Flow, solved through Object Lifecycle methods, we need to call it explicitly
$view->assign('settings', $this->settings);
// same with settings injection.
return $view;
}
/**
* @param ViewInterface $view
*
* @internal only to be used within Extbase, not part of TYPO3 Core API.
* @todo v12: Change signature to TYPO3Fluid\Fluid\View\ViewInterface when extbase ViewInterface is dropped.
*/
protected function setViewConfiguration(ViewInterface $view)
{
......
<?php
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
namespace TYPO3\CMS\Extbase\Mvc\View;
use TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext;
/**
* An abstract View
* @deprecated since TYPO3 v11, will be removed in TYPO3 v12.0. It is highly recommended to implement all needed logic of ViewInterface yourself
*/
abstract class AbstractView implements ViewInterface
{
/**
* @var \TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext
*/
protected $controllerContext;
/**
* View variables and their values
*
* @var array
* @see assign()
*/
protected $variables = [];
/**
* Sets the current controller context
*
* @param \TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext $controllerContext
*/
public function setControllerContext(ControllerContext $controllerContext)
{
$this->controllerContext = $controllerContext;
}
/**
* Add a variable to $this->viewData.
* Can be chained, so $this->view->assign(..., ...)->assign(..., ...); is possible
*
* @param string $key Key of variable
* @param mixed $value Value of object
* @return \TYPO3\CMS\Extbase\Mvc\View\AbstractView an instance of $this, to enable chaining
*/
public function assign($key, $value)
{
$this->variables[$key] = $value;
return $this;
}
/**
* Add multiple variables to $this->viewData.
*
* @param array $values array in the format array(key1 => value1, key2 => value2).
* @return \TYPO3\CMS\Extbase\Mvc\View\AbstractView an instance of $this, to enable chaining
*/
public function assignMultiple(array $values)
{
foreach ($values as $key => $value) {
$this->assign($key, $value);
}
return $this;
}
/**
* Tells if the view implementation can render the view for the given context.
*
* By default we assume that the view implementation can handle all kinds of
* contexts. Override this method if that is not the case.
*
* @return bool TRUE if the view has something useful to display, otherwise FALSE
* @deprecated since TYPO3 v11, will be removed in v12. Legacy method, not part of ViewInterface anymore.
*/
public function canRender()
{
trigger_error('Method ' . __METHOD__ . ' has been deprecated in v11 and will be removed with v12.', E_USER_DEPRECATED);
return true;
}
/**
* Initializes this view.
*
* Override this method for initializing your concrete view implementation.
*/
public function initializeView()
{
}
}
<?php
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
namespace TYPO3\CMS\Extbase\Mvc\View;
use TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext;
/**
* An empty view - a special case.
*
* @deprecated since v11, will be removed with 12.
*/
class EmptyView implements ViewInterface
{
public function __construct()
{
trigger_error('Class ' . __CLASS__ . ' has been deprecated in v11 and will be removed with v12.');
}
/**
* Dummy method to satisfy the ViewInterface
*
* @param \TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext $controllerContext
* @internal
*/
public function setControllerContext(ControllerContext $controllerContext)
{
}
/**
* Dummy method to satisfy the ViewInterface
*
* @param string $key
* @param mixed $value
* @return \TYPO3\CMS\Extbase\Mvc\View\EmptyView instance of $this to allow chaining
*/
public function assign($key, $value)
{
return $this;
}
/**
* Dummy method to satisfy the ViewInterface
*
* @param array $values
* @return \TYPO3\CMS\Extbase\Mvc\View\EmptyView instance of $this to allow chaining
*/
public function assignMultiple(array $values)
{
return $this;
}
/**
* This view can be used in any case.
*
* @return bool TRUE
* @deprecated since TYPO3 v11, will be removed in v12. Legacy method, not part of ViewInterface anymore.
*/
public function canRender()
{
trigger_error('Method ' . __METHOD__ . ' has been deprecated in v11 and will be removed with v12.', E_USER_DEPRECATED);
return true;
}
/**
* Renders the empty view
*
* @return string An empty string
*/
public function render()
{
return '<!-- This is the output of the Empty View. An appropriate View was not found. -->';
}
/**
* A magic call method.
*
* Because this empty view is used as a Special Case in situations when no matching
* view is available, it must be able to handle method calls which originally were
* directed to another type of view. This magic method should prevent PHP from issuing
* a fatal error.
*
* @param string $methodName
* @param array $arguments
*/
public function __call($methodName, array $arguments)
{
}
/**
* Initializes this view.
*
* Override this method for initializing your concrete view implementation.
*/
public function initializeView()
{
}
}
......@@ -20,6 +20,7 @@ namespace TYPO3\CMS\Extbase\Mvc\View;
use Psr\Container\ContainerInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Object\ObjectManager;
use TYPO3Fluid\Fluid\View\ViewInterface;
/**
* @internal only to be used within Extbase, not part of TYPO3 Core API.
......@@ -47,9 +48,6 @@ class GenericViewResolver implements ViewResolverInterface
$this->defaultViewClass = $defaultViewClass;
}
/**
* @todo v12: Change signature to TYPO3Fluid\Fluid\View\ViewInterface when extbase ViewInterface is dropped.
*/
public function resolve(string $controllerObjectName, string $actionName, string $format): ViewInterface
{
if ($this->container->has($this->defaultViewClass)) {
......
......@@ -24,10 +24,8 @@ use TYPO3Fluid\Fluid\View\AbstractView;
/**
* A JSON view
*
* @todo v12: Drop 'implements ViewInterface' together with removal of extbase ViewInterface
*/
class JsonView extends AbstractView implements ViewInterface
class JsonView extends AbstractView
{
/**
* Definition for the class name exposure configuration,
......@@ -224,31 +222,6 @@ class JsonView extends AbstractView implements ViewInterface
return $this;
}
/**
* Tells if the view implementation can render the view for the given context.
*
* By default we assume that the view implementation can handle all kinds of
* contexts. Override this method if that is not the case.
*
* @return bool TRUE if the view has something useful to display, otherwise FALSE
* @deprecated since TYPO3 v11, will be removed in v12. Legacy method, not part of ViewInterface anymore.
*/
public function canRender()
{
trigger_error('Method ' . __METHOD__ . ' has been deprecated in v11 and will be removed with v12.', E_USER_DEPRECATED);
return true;
}
/**
* Initializes this view.
*
* Override this method for initializing your concrete view implementation.
* @deprecated since v11, will be removed with v12. Drop together with removal of extbase ViewInterface.
*/
public function initializeView()