Skip to content

Commit

Permalink
[!!!][TASK] Remove deprecated code from backend Controller/File
Browse files Browse the repository at this point in the history
Resolves: #87431
Releases: master
Change-Id: Idb7a87bce6d7edee409bc24348b185ea51c17de2
Reviewed-on: https://review.typo3.org/59428
Tested-by: TYPO3com <noreply@typo3.com>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
  • Loading branch information
lolli42 authored and bmack committed Jan 14, 2019
1 parent fee2a4b commit 46b5493
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 264 deletions.
Expand Up @@ -20,8 +20,6 @@
use TYPO3\CMS\Backend\Routing\UriBuilder;
use TYPO3\CMS\Backend\Template\ModuleTemplate;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Compatibility\PublicMethodDeprecationTrait;
use TYPO3\CMS\Core\Compatibility\PublicPropertyDeprecationTrait;
use TYPO3\CMS\Core\Http\HtmlResponse;
use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Localization\LanguageService;
Expand All @@ -40,41 +38,11 @@
*/
class CreateFolderController
{
use PublicMethodDeprecationTrait;
use PublicPropertyDeprecationTrait;

/**
* @var array
*/
private $deprecatedPublicMethods = [
'main' => 'Using CreateFolderController::main() is deprecated and will not be possible anymore in TYPO3 v10.0.',
];

/**
* @var array
*/
private $deprecatedPublicProperties = [
'number' => 'Using $number of class CreateFolderController from outside is discouraged, as this variable is only used for internal storage.',
'folderNumber' => 'Using $folderNumber of class CreateFolderController from outside is discouraged, as this variable is only used for internal storage.',
'target' => 'Using $target of class CreateFolderController from outside is discouraged, as this variable is only used for internal storage.',
'content' => 'Using $content of class CreateFolderController from outside is discouraged, as this variable is only used for internal storage.',
'returnUrl' => 'Using $content of class CreateFolderController from outside is discouraged, as this variable is only used for internal storage.',
'title' => 'Using $content of class CreateFolderController from outside is discouraged, as this variable is only used for internal storage.',
];

/**
* @var int
*/
protected $folderNumber = 10;

/**
* Name of the filemount
*
* @var string
* @deprecated since TYPO3 v9, will be removed in TYPO3 v10.0, unused
*/
protected $title;

/**
* @var int
*/
Expand Down Expand Up @@ -106,31 +74,13 @@ class CreateFolderController
*/
protected $pathInfo;

/**
* Accumulating content
*
* @var string
* @deprecated since TYPO3 v9, will be removed in TYPO3 v10.0, unused
*/
protected $content;

/**
* ModuleTemplate object
*
* @var ModuleTemplate
*/
protected $moduleTemplate;

/**
* Constructor
*/
public function __construct()
{
$this->moduleTemplate = GeneralUtility::makeInstance(ModuleTemplate::class);
// @deprecated since TYPO3 v9, will be moved out of __construct() in TYPO3 v10.0
$this->init($GLOBALS['TYPO3_REQUEST']);
}

/**
* Processes the request, currently everything is handled and put together via "main()"
*
Expand All @@ -139,6 +89,8 @@ public function __construct()
*/
public function mainAction(ServerRequestInterface $request): ResponseInterface
{
$this->moduleTemplate = GeneralUtility::makeInstance(ModuleTemplate::class);
$this->init($request);
$this->main();
return new HtmlResponse($this->moduleTemplate->renderContent());
}
Expand Down
43 changes: 4 additions & 39 deletions typo3/sysext/backend/Classes/Controller/File/FileController.php
Expand Up @@ -21,7 +21,6 @@
use TYPO3\CMS\Backend\Routing\UriBuilder;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Core\Compatibility\PublicMethodDeprecationTrait;
use TYPO3\CMS\Core\Http\HtmlResponse;
use TYPO3\CMS\Core\Http\JsonResponse;
use TYPO3\CMS\Core\Http\RedirectResponse;
Expand All @@ -34,7 +33,6 @@
use TYPO3\CMS\Core\Resource\ResourceFactory;
use TYPO3\CMS\Core\Utility\File\ExtendedFileUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\HttpUtility;

/**
* Gateway for TCE (TYPO3 Core Engine) file-handling through POST forms.
Expand All @@ -44,16 +42,6 @@
*/
class FileController
{
use PublicMethodDeprecationTrait;

/**
* @var array
*/
private $deprecatedPublicMethods = [
'initClipboard' => 'Using FileController::initClipboard() is deprecated and will not be possible anymore in TYPO3 v10.0.',
'main' => 'Using FileController::main() is deprecated and will not be possible anymore in TYPO3 v10.0.',
];

/**
* Array of file-operations.
*
Expand Down Expand Up @@ -98,15 +86,6 @@ class FileController
*/
protected $fileData;

/**
* Constructor
*/
public function __construct()
{
// @deprecated since TYPO3 v9, will be moved out of __construct() in TYPO3 v10.0
$this->init($GLOBALS['TYPO3_REQUEST']);
}

/**
* Injects the request object for the current request or subrequest
* As this controller goes only through the main() method, it just redirects to the given URL afterwards.
Expand All @@ -116,6 +95,7 @@ public function __construct()
*/
public function mainAction(ServerRequestInterface $request): ResponseInterface
{
$this->init($request);
$this->main();

BackendUtility::setUpdateSignal('updateFolderTree');
Expand All @@ -138,15 +118,14 @@ public function mainAction(ServerRequestInterface $request): ResponseInterface

/**
* Handles the actual process from within the ajaxExec function
* therefore, it does exactly the same as the real typo3/tce_file.php
* but without calling the "finish" method, thus makes it simpler to deal with the
* actual return value
* therefore, it does exactly the same as the real typo3/tce_file.php.
*
* @param ServerRequestInterface $request
* @return ResponseInterface
*/
public function processAjaxRequest(ServerRequestInterface $request): ResponseInterface
{
$this->init($request);
$this->main();
$errors = $this->fileProcessor->getErrorMessages();
if (!empty($errors)) {
Expand Down Expand Up @@ -175,6 +154,7 @@ public function processAjaxRequest(ServerRequestInterface $request): ResponseInt
*/
public function fileExistsInFolderAction(ServerRequestInterface $request): ResponseInterface
{
$this->init($request);
$fileName = $request->getParsedBody()['fileName'] ?? $request->getQueryParams()['fileName'] ?? null;
$fileTarget = $request->getParsedBody()['fileTarget'] ?? $request->getQueryParams()['fileTarget'] ?? null;

Expand Down Expand Up @@ -277,21 +257,6 @@ protected function getFileEditRedirect(File $file): ?string
return (string)$uriBuilder->buildUriFromRoute('file_edit', $urlParameters);
}

/**
* Redirecting the user after the processing has been done.
* Might also display error messages directly, if any.
*
* @deprecated since TYPO3 v9. Will be removed in TYPO3 v10.0.
*/
public function finish()
{
trigger_error('FileController->finish() will be removed in TYPO3 v10.0. Do not call from other extension.', E_USER_DEPRECATED);
BackendUtility::setUpdateSignal('updateFolderTree');
if ($this->redirect) {
HttpUtility::redirect($this->redirect);
}
}

/**
* Flatten result value from FileProcessor
*
Expand Down
Expand Up @@ -18,7 +18,6 @@
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Backend\Template\ModuleTemplate;
use TYPO3\CMS\Core\Compatibility\PublicPropertyDeprecationTrait;
use TYPO3\CMS\Core\Http\HtmlResponse;
use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Localization\LanguageService;
Expand All @@ -32,25 +31,6 @@
*/
class FileUploadController
{
use PublicPropertyDeprecationTrait;

/**
* @var array
*/
protected $deprecatedPublicProperties = [
'title' => 'Using $title of class FileUploadController from outside is discouraged as this variable is only used for internal storage.',
'target' => 'Using $target of class FileUploadController from outside is discouraged as this variable is only used for internal storage.',
'returnUrl' => 'Using $returnUrl of class FileUploadController from outside is discouraged as this variable is only used for internal storage.',
'content' => 'Using $content of class FileUploadController from outside is discouraged as this variable is only used for internal storage.',
];

/**
* Name of the filemount
*
* @var string
*/
protected $title;

/**
* Set with the target path inputted in &target
*
Expand Down Expand Up @@ -86,18 +66,6 @@ class FileUploadController
*/
protected $moduleTemplate;

/**
* Constructor
*/
public function __construct()
{
$this->moduleTemplate = GeneralUtility::makeInstance(ModuleTemplate::class);
$this->getLanguageService()->includeLLFile('EXT:core/Resources/Private/Language/locallang_misc.xlf');

// @deprecated since TYPO3 v9, will be moved out of __construct() in TYPO3 v10.0
$this->init($GLOBALS['TYPO3_REQUEST']);
}

/**
* Processes the request, currently everything is handled and put together via "renderContent()"
*
Expand All @@ -106,33 +74,13 @@ public function __construct()
*/
public function mainAction(ServerRequestInterface $request): ResponseInterface
{
$this->moduleTemplate = GeneralUtility::makeInstance(ModuleTemplate::class);
$this->getLanguageService()->includeLLFile('EXT:core/Resources/Private/Language/locallang_misc.xlf');
$this->init($request);
$this->renderContent();
return new HtmlResponse($this->moduleTemplate->renderContent());
}

/**
* Main function, rendering the upload file form fields
*
* @deprecated since TYPO3 v9, will be removed in TYPO3 v10.0
*/
public function main()
{
trigger_error('FileUploadController->main() will be replaced by protected method renderContent() in TYPO3 v10.0. Do not call from other extension.', E_USER_DEPRECATED);
$this->renderContent();
}

/**
* This function renders the upload form
*
* @return string The HTML form as a string, ready for outputting
* @deprecated since TYPO3 v9, will be removed in TYPO3 v10.0
*/
public function renderUploadForm()
{
trigger_error('FileUploadController->renderUploadForm() will be replaced by protected method renderUploadFormInternal() in TYPO3 v10.0. Do not call from other extension.', E_USER_DEPRECATED);
return $this->renderUploadFormInternal();
}

/**
* Initialize
*
Expand Down

0 comments on commit 46b5493

Please sign in to comment.