Commit c24cef6e authored by Alexander Schnitzler's avatar Alexander Schnitzler Committed by Benni Mack
Browse files

[TASK] Deprecate ControllerContext::getUriBuilder()

With this patch method geturiBuilder() of ControllerContext
is deprecated and the core avoids using it.

A trigger_error call will be implemented in another patch set
which deprecates the whole ControllerContext object.

Releases: master
Resolves: #93019
Change-Id: Ie36bac79a6da3400a2b3594d5519af13f23a22c6
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/67047


Tested-by: default avatarTYPO3com <noreply@typo3.com>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
parent 05f83aae
......@@ -123,9 +123,12 @@ class ControllerContext
/**
* @return \TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder
* @deprecated since v11, will be removed in v12
*/
public function getUriBuilder()
{
// todo: trigger an error as soon as this whole object can be deprecated
if (!$this->uriBuilder) {
$this->uriBuilder = GeneralUtility::makeInstance(ObjectManager::class)->get(UriBuilder::class);
if ($this->request) {
......
......@@ -81,9 +81,7 @@ class DistributionController extends AbstractModuleController
/** @var ButtonBar $buttonBar */
$buttonBar = $this->view->getModuleTemplate()->getDocHeaderComponent()->getButtonBar();
$uriBuilder = $this->controllerContext->getUriBuilder();
$uri = $uriBuilder->reset()->uriFor('distributions', [], 'List');
$uri = $this->uriBuilder->reset()->uriFor('distributions', [], 'List');
$title = $this->translate('extConfTemplate.backToList');
$icon = $this->view->getModuleTemplate()->getIconFactory()->getIcon('actions-view-go-back', Icon::SIZE_SMALL);
$button = $buttonBar->makeLinkButton()
......
......@@ -295,15 +295,14 @@ class ListController extends AbstractModuleController
/** @var ButtonBar $buttonBar */
$buttonBar = $this->view->getModuleTemplate()->getDocHeaderComponent()->getButtonBar();
$uriBuilder = $this->controllerContext->getUriBuilder();
if ($this->actionMethodName === 'showAllVersionsAction') {
$uri = $uriBuilder->reset()->uriFor('ter', [], 'List');
$uri = $this->uriBuilder->reset()->uriFor('ter', [], 'List');
$title = $this->translate('extConfTemplate.backToList');
$icon = $this->view->getModuleTemplate()->getIconFactory()->getIcon('actions-view-go-back', Icon::SIZE_SMALL);
$classes = '';
} else {
$uri = $uriBuilder->reset()->uriFor('form', [], 'UploadExtensionFile');
$uri = $this->uriBuilder->reset()->uriFor('form', [], 'UploadExtensionFile');
$title = $this->translate('extensionList.uploadExtension');
$icon = $this->view->getModuleTemplate()->getIconFactory()->getIcon('actions-edit-upload', Icon::SIZE_SMALL);
$classes = 't3js-upload';
......
......@@ -68,9 +68,7 @@ class UpdateScriptController extends AbstractModuleController
/** @var ButtonBar $buttonBar */
$buttonBar = $this->view->getModuleTemplate()->getDocHeaderComponent()->getButtonBar();
$uriBuilder = $this->controllerContext->getUriBuilder();
$uri = $uriBuilder->reset()->uriFor('index', [], 'List');
$uri = $this->uriBuilder->reset()->uriFor('index', [], 'List');
$title = $this->translate('extConfTemplate.backToList');
$icon = $this->view->getModuleTemplate()->getIconFactory()->getIcon('actions-view-go-back', Icon::SIZE_SMALL);
$button = $buttonBar->makeLinkButton()
......
......@@ -108,8 +108,8 @@ class FormEditorController extends AbstractBackendController
'formPersistenceIdentifier' => $formPersistenceIdentifier,
'prototypeName' => $prototypeName,
'endpoints' => [
'formPageRenderer' => $this->controllerContext->getUriBuilder()->uriFor('renderFormPage'),
'saveForm' => $this->controllerContext->getUriBuilder()->uriFor('saveForm')
'formPageRenderer' => $this->uriBuilder->uriFor('renderFormPage'),
'saveForm' => $this->uriBuilder->uriFor('saveForm')
],
'additionalViewModelModules' => $this->prototypeConfiguration['formEditor']['dynamicRequireJsModules']['additionalViewModelModules'],
'maximumUndoSteps' => $this->prototypeConfiguration['formEditor']['maximumUndoSteps'],
......
......@@ -137,7 +137,7 @@ class FormManagerController extends AbstractBackendController
$response = [
'status' => 'success',
'url' => $this->controllerContext->getUriBuilder()->uriFor('index', ['formPersistenceIdentifier' => $formPersistenceIdentifier], 'FormEditor')
'url' => $this->uriBuilder->uriFor('index', ['formPersistenceIdentifier' => $formPersistenceIdentifier], 'FormEditor')
];
try {
......@@ -197,7 +197,7 @@ class FormManagerController extends AbstractBackendController
$response = [
'status' => 'success',
'url' => $this->controllerContext->getUriBuilder()->uriFor('index', ['formPersistenceIdentifier' => $formPersistenceIdentifier], 'FormEditor')
'url' => $this->uriBuilder->uriFor('index', ['formPersistenceIdentifier' => $formPersistenceIdentifier], 'FormEditor')
];
try {
......@@ -326,10 +326,10 @@ class FormManagerController extends AbstractBackendController
'selectablePrototypesConfiguration' => $this->formSettings['formManager']['selectablePrototypesConfiguration'],
'accessibleFormStorageFolders' => $this->getAccessibleFormStorageFolders(),
'endpoints' => [
'create' => $this->controllerContext->getUriBuilder()->uriFor('create'),
'duplicate' => $this->controllerContext->getUriBuilder()->uriFor('duplicate'),
'delete' => $this->controllerContext->getUriBuilder()->uriFor('delete'),
'references' => $this->controllerContext->getUriBuilder()->uriFor('references')
'create' => $this->uriBuilder->uriFor('create'),
'duplicate' => $this->uriBuilder->uriFor('duplicate'),
'delete' => $this->uriBuilder->uriFor('delete'),
'references' => $this->uriBuilder->uriFor('references')
],
];
......
......@@ -23,7 +23,6 @@ use TYPO3\CMS\Core\Imaging\IconFactory;
use TYPO3\CMS\Core\Resource\Folder;
use TYPO3\CMS\Core\Resource\ResourceStorage;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext;
use TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder;
use TYPO3\CMS\Extbase\Object\ObjectManager;
use TYPO3\CMS\Form\Controller\FormManagerController;
......@@ -125,13 +124,8 @@ class FormManagerControllerTest extends UnitTestCase
], [], '', false);
$mockUriBuilder = $this->createMock(UriBuilder::class);
$mockControllerContext = $this->createMock(ControllerContext::class);
$mockControllerContext
->expects(self::any())
->method('getUriBuilder')
->willReturn($mockUriBuilder);
$mockController->_set('controllerContext', $mockControllerContext);
$mockController->_set('uriBuilder', $mockUriBuilder);
$mockController->_set('formSettings', [
'formManager' => [
......
......@@ -1591,7 +1591,7 @@ class SearchController extends ActionController
protected function preparePageLink(int $pageUid, array $row, array $urlParameters): array
{
$target = '';
$uri = $this->controllerContext->getUriBuilder()
$uri = $this->uriBuilder
->setTargetPageUid($pageUid)
->setTargetPageType($row['data_page_type'])
->setArguments($urlParameters)
......
Supports Markdown
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