Commit eaee4a06 authored by Christian Kuhn's avatar Christian Kuhn
Browse files

[!!!][TASK] Remove extbase ControllerContext

Change-Id: Idf41a7708c1d9ffee635ece1b7c060b3f751c15d
Resolves: #96183
Related: #95139
Releases: main
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/72445

Tested-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Stefan Bürk's avatarStefan Bürk <stefan@buerk.tech>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Reviewed-by: Stefan Bürk's avatarStefan Bürk <stefan@buerk.tech>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
parent db92cbd1
......@@ -28,6 +28,7 @@ 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\Controller\ControllerContext`
- :php:`\TYPO3\CMS\Extbase\Mvc\View\AbstractView`
- :php:`\TYPO3\CMS\Extbase\Mvc\View\EmptyView`
- :php:`\TYPO3\CMS\Extbase\Service\EnvironmentService`
......@@ -58,6 +59,15 @@ The following PHP class methods that have previously been marked as deprecated f
- :php:`\TYPO3\CMS\Backend\Domain\Module\BackendModule->setOnClick()`
- :php:`\TYPO3\CMS\Backend\Domain\Module\BackendModule->getOnClick()`
- :php:`\TYPO3\CMS\Core\Domain\Repository\PageRepository->fixVersioningPid()`
- :php:`\TYPO3\CMS\Extbase\Mvc\Controller\ActionController->buildControllerContext()`
- :php:`\TYPO3\CMS\Extbase\Mvc\Controller\ActionController->getControllerContext()`
- :php:`\TYPO3\CMS\Extbase\Mvc\View\JsonView->setControllerContext()`
- :php:`\TYPO3\CMS\Fluid\Core\Rendering\RenderingContext->getControllerContext()`
- :php:`\TYPO3\CMS\Fluid\Core\Rendering\RenderingContext->setControllerContext()`
- :php:`\TYPO3\CMS\Fluid\View\AbstractTemplateView->setControllerContext()`
- :php:`\TYPO3\CMS\Form\Domain\Renderer\AbstractElementRenderer->setControllerContext()`
- :php:`\TYPO3\CMS\Form\Domain\Renderer\RendererInterface->setControllerContext()`
- :php:`\TYPO3\CMS\Form\Domain\Runtime\FormRuntime->getControllerContext()`
- :php:`\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer->editIcons()`
- :php:`\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer->editPanel()`
- :php:`\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer->isDisabled()`
......@@ -97,8 +107,8 @@ The following PHP static class methods that have previously been marked as depre
The following PHP class methods changed signature according to previous deprecations in v11 at the end of the argument list:
- :php:`\TYPO3\CMS\Core\Core\ApplicationInterface->run` (argument 1 is removed)
- :php:`\TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController->ATagParams` (argument 2 is removed)
- :php:`\TYPO3\CMS\Core\Core\ApplicationInterface->run()` (argument 1 is removed)
- :php:`\TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController->ATagParams()` (argument 2 is removed)
The following PHP static class methods changed signature according to previous deprecations in v11 at the end of the argument list:
......@@ -108,10 +118,15 @@ The following PHP class methods changed signature according to previous deprecat
- :php:`\TYPO3\CMS\Backend\Tree\View\AbstractTreeView->getIcon()` (first argument is now type hinted `array`)
The following public class properties have been removed:
The following class properties have been removed:
- :php:`\TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController.php->displayEditIcons`
- :php:`\TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController.php->displayFieldEditIcons`
- :php:`\TYPO3\CMS\Extbase\Mvc\Controller\ActionController->controllerContext`
- :php:`\TYPO3\CMS\Extbase\Mvc\View\JsonView->controllerContext`
- :php:`\TYPO3\CMS\Fluid\Core\Rendering\RenderingContext->controllerContext`
- :php:`\TYPO3\CMS\Fluid\View\AbstractTemplateView->controllerContext`
- :php:`\TYPO3\CMS\Form\Domain\Renderer\AbstractElementRenderer->controllerContext`
- :php:`\TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController->displayEditIcons`
- :php:`\TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController->displayFieldEditIcons`
- :php:`\TYPO3\CMS\Frontend\Plugin\AbstractPlugin->pi_EPtemp_cObj`
The following class methods visibility have been changed to protected:
......
......@@ -54,6 +54,7 @@ use TYPO3\CMS\Extbase\SignalSlot\Dispatcher;
use TYPO3\CMS\Extbase\Validation\Validator\ConjunctionValidator;
use TYPO3\CMS\Extbase\Validation\Validator\ValidatorInterface;
use TYPO3\CMS\Extbase\Validation\ValidatorResolver;
use TYPO3\CMS\Fluid\Core\Rendering\RenderingContext;
use TYPO3\CMS\Fluid\View\TemplateView;
use TYPO3Fluid\Fluid\View\AbstractTemplateView;
use TYPO3Fluid\Fluid\View\ViewInterface;
......@@ -175,13 +176,6 @@ abstract class ActionController implements ControllerInterface
*/
protected $arguments;
/**
* @var ControllerContext
* @internal only to be used within Extbase, not part of TYPO3 Core API.
* @deprecated since v11, will be removed with v12.
*/
protected $controllerContext;
/**
* @var ConfigurationManagerInterface
* @internal only to be used within Extbase, not part of TYPO3 Core API.
......@@ -466,8 +460,6 @@ abstract class ActionController implements ControllerInterface
$callable();
}
$this->mapRequestArgumentsToControllerArguments();
// @deprecated since v11, will be removed with v12.
$this->controllerContext = $this->buildControllerContext();
$this->view = $this->resolveView();
if ($this->view !== null && method_exists($this, 'initializeView')) {
$this->initializeView($this->view);
......@@ -615,10 +607,17 @@ abstract class ActionController implements ControllerInterface
$this->request->getControllerActionName(),
$this->request->getFormat()
);
if ($view instanceof AbstractTemplateView) {
$renderingContext = $view->getRenderingContext();
if ($renderingContext instanceof RenderingContext) {
$renderingContext->setRequest($this->request);
}
$templatePaths = $view->getRenderingContext()->getTemplatePaths();
$templatePaths->fillDefaultsByPackageName($this->request->getControllerExtensionKey());
$templatePaths->setFormat($this->request->getFormat());
}
$this->setViewConfiguration($view);
// @deprecated since v11, will be removed with v12.
$view->setControllerContext($this->controllerContext);
if (method_exists($view, 'injectSettings')) {
$view->injectSettings($this->settings);
}
......@@ -802,15 +801,6 @@ abstract class ActionController implements ControllerInterface
return $outputMessage;
}
/**
* @return ControllerContext
* @deprecated since v11, will be removed with v12.
*/
public function getControllerContext()
{
return $this->controllerContext;
}
/**
* Creates a Message object and adds it to the FlashMessageQueue.
*
......@@ -858,27 +848,6 @@ abstract class ActionController implements ControllerInterface
return $this->internalFlashMessageService->getMessageQueueByIdentifier($identifier);
}
/**
* Initialize the controller context
*
* @return ControllerContext ControllerContext to be passed to the view
*
* @internal only to be used within Extbase, not part of TYPO3 Core API.
* @deprecated since v11, will be removed with v12.
*/
protected function buildControllerContext()
{
/** @var ControllerContext $controllerContext */
$controllerContext = GeneralUtility::makeInstance(ControllerContext::class);
$controllerContext->setRequest($this->request);
if ($this->arguments !== null) {
$controllerContext->setArguments($this->arguments);
}
$controllerContext->setUriBuilder($this->uriBuilder);
return $controllerContext;
}
/**
* Forwards the request to another action and / or controller.
*
......
<?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\Controller;
use TYPO3\CMS\Core\Messaging\FlashMessageService;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Mvc\Request;
use TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder;
use TYPO3\CMS\Extbase\Service\ExtensionService;
/**
* The controller context contains information from the controller
*
* @deprecated since v11, will be removed with v12
*/
class ControllerContext
{
/**
* @var \TYPO3\CMS\Extbase\Mvc\Request
*/
protected $request;
/**
* @var \TYPO3\CMS\Extbase\Mvc\Controller\Arguments
*/
protected $arguments;
/**
* @var UriBuilder
*/
protected $uriBuilder;
/**
* @var string
*/
protected $flashMessageQueueDefaultIdentifier;
/**
* @var \TYPO3\CMS\Core\Messaging\FlashMessageService
*/
protected $flashMessageService;
/**
* @var \TYPO3\CMS\Extbase\Service\ExtensionService
*/
protected $extensionService;
/**
* @param \TYPO3\CMS\Core\Messaging\FlashMessageService $flashMessageService
*/
public function injectFlashMessageService(FlashMessageService $flashMessageService)
{
$this->flashMessageService = $flashMessageService;
}
/**
* @param \TYPO3\CMS\Extbase\Service\ExtensionService $extensionService
*/
public function injectExtensionService(ExtensionService $extensionService)
{
$this->extensionService = $extensionService;
}
/**
* Set the request of the controller
*
* @param \TYPO3\CMS\Extbase\Mvc\Request $request
*/
public function setRequest(Request $request)
{
$this->request = $request;
}
/**
* Get the request of the controller
*
* @return \TYPO3\CMS\Extbase\Mvc\Request
*/
public function getRequest()
{
return $this->request;
}
/**
* Set the arguments of the controller
*
* @param \TYPO3\CMS\Extbase\Mvc\Controller\Arguments $arguments
*/
public function setArguments(Arguments $arguments)
{
$this->arguments = $arguments;
}
/**
* Get the arguments of the controller
*
* @return \TYPO3\CMS\Extbase\Mvc\Controller\Arguments
*/
public function getArguments()
{
return $this->arguments;
}
/**
* @param UriBuilder $uriBuilder
*/
public function setUriBuilder(UriBuilder $uriBuilder)
{
$this->uriBuilder = $uriBuilder;
}
/**
* @return UriBuilder
* @deprecated since v11, will be removed in v12
*/
public function getUriBuilder()
{
if (!$this->uriBuilder) {
$this->uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
if ($this->request) {
$this->uriBuilder->setRequest($this->request);
}
}
return $this->uriBuilder;
}
/**
* @param string $identifier Queue-identifier
* @return \TYPO3\CMS\Core\Messaging\FlashMessageQueue
* @deprecated since v11, will be removed in v12
*/
public function getFlashMessageQueue($identifier = null)
{
if ($identifier === null) {
if ($this->flashMessageQueueDefaultIdentifier === null) {
// cache the default-identifier for performance-reasons
$this->flashMessageQueueDefaultIdentifier = 'extbase.flashmessages.' . $this->extensionService->getPluginNamespace($this->request->getControllerExtensionName(), $this->request->getPluginName());
}
$identifier = $this->flashMessageQueueDefaultIdentifier;
}
return $this->flashMessageService->getMessageQueueByIdentifier($identifier);
}
}
......@@ -212,7 +212,7 @@ class ExtbaseRequestParameters
*/
public function getControllerExtensionKey()
{
return GeneralUtility::camelCaseToLowerCaseUnderscored($this->controllerExtensionName);
return GeneralUtility::camelCaseToLowerCaseUnderscored((string)$this->controllerExtensionName);
}
/**
......
......@@ -17,7 +17,6 @@ declare(strict_types=1);
namespace TYPO3\CMS\Extbase\Mvc\View;
use TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext;
use TYPO3\CMS\Extbase\Persistence\PersistenceManagerInterface;
use TYPO3\CMS\Extbase\Reflection\ObjectAccess;
use TYPO3Fluid\Fluid\View\AbstractView;
......@@ -160,12 +159,6 @@ class JsonView extends AbstractView
*/
protected $persistenceManager;
/**
* @var ControllerContext
* @deprecated since v11, will be removed with v12.
*/
protected $controllerContext;
/**
* View variables and their values
*
......@@ -183,17 +176,6 @@ class JsonView extends AbstractView
$this->persistenceManager = $persistenceManager;
}
/**
* Sets the current controller context
*
* @param ControllerContext $controllerContext
* @deprecated since v11, will be removed with v12.
*/
public function setControllerContext(ControllerContext $controllerContext)
{
$this->controllerContext = $controllerContext;
}
/**
* Add a variable to $this->viewData.
* Can be chained, so $this->view->assign(..., ...)->assign(..., ...); is possible
......
......@@ -59,11 +59,6 @@ services:
factory: ['@TYPO3\CMS\Core\Cache\CacheManager', 'getCache']
arguments: ['extbase']
# @deprecated since v11, will be removed in v12
TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext:
public: true
shared: false
TYPO3\CMS\Extbase\Mvc\View\GenericViewResolver: ~
TYPO3\CMS\Extbase\Mvc\View\ViewResolverInterface: '@TYPO3\CMS\Extbase\Mvc\View\GenericViewResolver'
......
......@@ -16,7 +16,6 @@
namespace TYPO3\CMS\Fluid\Core\Rendering;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext;
use TYPO3\CMS\Extbase\Mvc\Request;
use TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder;
use TYPO3\CMS\Fluid\Core\ViewHelper\ViewHelperResolver;
......@@ -35,14 +34,6 @@ use TYPO3Fluid\Fluid\Core\ViewHelper\ViewHelperVariableContainer;
*/
class RenderingContext extends \TYPO3Fluid\Fluid\Core\Rendering\RenderingContext
{
/**
* Controller context being passed to the ViewHelper
*
* @var ControllerContext
* @deprecated since v11, will be removed with v12.
*/
protected $controllerContext;
/**
* @var Request
*/
......@@ -129,24 +120,6 @@ class RenderingContext extends \TYPO3Fluid\Fluid\Core\Rendering\RenderingContext
}
}
/**
* Get the controller context which will be passed to the ViewHelper
*
* @return ControllerContext The controller context to set
* @deprecated since v11, will be removed in v12
*/
public function getControllerContext()
{
if ($this->controllerContext) {
return $this->controllerContext;
}
$controllerContext = GeneralUtility::makeInstance(ControllerContext::class);
if ($this->request) {
$controllerContext->setRequest($this->request);
}
return $controllerContext;
}
/**
* @param string $action
*/
......@@ -190,25 +163,6 @@ class RenderingContext extends \TYPO3Fluid\Fluid\Core\Rendering\RenderingContext
return $this->request instanceof Request ? $this->request->getControllerActionName() : $this->controllerAction;
}
/**
* Set the controller context which will be passed to the ViewHelper
*
* @param ControllerContext $controllerContext The controller context to set
* @deprecated since v11, will be removed with v12.
*/
public function setControllerContext(ControllerContext $controllerContext)
{
$this->controllerContext = $controllerContext;
if ($this->request === null) {
trigger_error(
'Setting request from controllerContext in class ' . __CLASS__ . ' is deprecated. Use setRequest() directly.',
E_USER_DEPRECATED
);
$request = $controllerContext->getRequest();
$this->setRequest($request);
}
}
/**
* @param Request $request
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\InvalidControllerNameException
......@@ -220,12 +174,6 @@ class RenderingContext extends \TYPO3Fluid\Fluid\Core\Rendering\RenderingContext
$this->request = $request;
$this->setControllerAction($request->getControllerActionName());
$this->setControllerName($request->getControllerName());
// Also ensure that controller context is filled, if not set yet.
if ($this->controllerContext === null) {
// @deprecated since v11, will be removed with v12.
$this->controllerContext = GeneralUtility::makeInstance(ControllerContext::class);
$this->controllerContext->setRequest($request);
}
}
/**
......
......@@ -16,8 +16,6 @@
namespace TYPO3\CMS\Fluid\View;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext;
use TYPO3\CMS\Fluid\Core\Rendering\RenderingContext;
use TYPO3\CMS\Fluid\Core\Rendering\RenderingContextFactory;
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
use TYPO3Fluid\Fluid\View\AbstractTemplateView as Typo3FluidAbstractTemplateView;
......@@ -30,12 +28,6 @@ use TYPO3Fluid\Fluid\View\Exception\InvalidTemplateResourceException;
*/
abstract class AbstractTemplateView extends Typo3FluidAbstractTemplateView
{
/**
* @var \TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext
* @deprecated since v11, will be removed with v12.
*/
protected $controllerContext;
/**
* @param RenderingContextInterface $context
* @internal
......@@ -48,28 +40,6 @@ abstract class AbstractTemplateView extends Typo3FluidAbstractTemplateView
parent::__construct($context);
}
/**
* Sets the current controller context
*
* @param \TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext $controllerContext
* @internal
* @deprecated since v11, will be removed with v12.
*/
public function setControllerContext(ControllerContext $controllerContext)
{
$request = $controllerContext->getRequest();
$this->controllerContext = $controllerContext;
// @todo: Move these two lines elsewhere when dropping the method
$this->baseRenderingContext->getTemplatePaths()->fillDefaultsByPackageName($request->getControllerExtensionKey());
$this->baseRenderingContext->getTemplatePaths()->setFormat($request->getFormat());
if ($this->baseRenderingContext instanceof RenderingContext) {
$this->baseRenderingContext->setRequest($request);
$this->baseRenderingContext->setControllerContext($controllerContext);
}
}
/**
* @param string $templateName
* @internal
......
<?php
declare(strict_types=1);
/*
* 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\Fluid\Tests\UnitDeprecated\Core\Rendering;
use TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext;
use TYPO3\CMS\Extbase\Mvc\Request;
use TYPO3\CMS\Fluid\Core\Rendering\RenderingContext;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
/**
* Test case
*/
class RenderingContextTest extends UnitTestCase
{
/**
* Parsing state
*
* @var RenderingContext
*/
protected $renderingContext;
protected function setUp(): void
{
parent::setUp();
$this->renderingContext = $this->getMockBuilder(RenderingContext::class)
->addMethods(['dummy'])
->disableOriginalConstructor()
->getMock();
}
/**
* @test
* @deprecated since v11, will be removed with v12.
*/
public function controllerContextCanBeReadCorrectly(): void
{
$controllerContext = $this->getMockBuilder(ControllerContext::class)
->disableOriginalConstructor()
->getMock();
$controllerContext->expects(self::atLeastOnce())->method('getRequest')->willReturn($this->createMock(Request::class));
$this->renderingContext->setControllerContext($controllerContext);
self::assertSame($this->renderingContext->getControllerContext(), $controllerContext);
}
}
......@@ -507,8 +507,7 @@ class FormEditorController extends AbstractBackendController
$insertRenderablesPanelConfiguration = $this->getInsertRenderablesPanelConfiguration($formEditorDefinitions['formElements']);
$view = GeneralUtility::makeInstance(TemplateView::class);
// @deprecated since v11, will be removed with v12.
$view->setControllerContext(clone $this->controllerContext);
$view->getRenderingContext()->setRequest($this->request);
$view->getRenderingContext()->getTemplatePaths()->fillFromConfigurationArray($fluidConfiguration);
$view->setTemplatePathAndFilename($fluidConfiguration['templatePathAndFilename']);
$view->assignMultiple([
......
......@@ -22,7 +22,6 @@ declare(strict_types=1);
namespace TYPO3\CMS\Form\Domain\Finishers;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext;
use TYPO3\CMS\Extbase\Mvc\Request;
use TYPO3\CMS\Form\Domain\Runtime\FormRuntime;
......@@ -49,12 +48,6 @@ class FinisherContext
*/
protected FormRuntime $formRuntime;
/**
* The assigned controller context which might be needed by the finisher.
* @deprecated since v11, will be removed with v12.
*/
protected ControllerContext $controllerContext;
/**
* The assigned controller context which might be needed by the finisher.
*/
......@@ -64,15 +57,12 @@ class FinisherContext
/**
* @param FormRuntime $formRuntime
* @param ControllerContext $controllerContext @deprecated since v11, will be removed with v12.
* @param Request $request
* @internal