‪TYPO3CMS  10.4
RenameFileViewHelper.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
21 use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
22 use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
23 use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
24 
28 class ‪RenameFileViewHelper extends AbstractViewHelper
29 {
30  use CompileWithRenderStatic;
31 
35  public function ‪initializeArguments()
36  {
37  $this->registerArgument('file', AbstractFile::class, '', true);
38  $this->registerArgument('returnUrl', 'string', '', false, '');
39  }
40 
50  public static function ‪renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
51  {
52  if (empty($arguments['returnUrl'])) {
53  $arguments['returnUrl'] = GeneralUtility::getIndpEnv('REQUEST_URI');
54  }
55 
57  $file = $arguments['file'];
58 
59  $params = [
60  'target' => $file->getCombinedIdentifier(),
61  'returnUrl' => $arguments['returnUrl']
62  ];
63  $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
64  return (string)$uriBuilder->buildUriFromRoute('file_rename', $params);
65  }
66 }
‪TYPO3\CMS\Filelist\ViewHelpers\Uri\RenameFileViewHelper
Definition: RenameFileViewHelper.php:29
‪TYPO3\CMS\Filelist\ViewHelpers\Uri
Definition: CopyCutFileViewHelper.php:16
‪TYPO3\CMS\Core\Resource\AbstractFile
Definition: AbstractFile.php:26
‪TYPO3\CMS\Backend\Routing\UriBuilder
Definition: UriBuilder.php:38
‪TYPO3\CMS\Filelist\ViewHelpers\Uri\RenameFileViewHelper\renderStatic
‪static string renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
Definition: RenameFileViewHelper.php:49
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46
‪TYPO3\CMS\Filelist\ViewHelpers\Uri\RenameFileViewHelper\initializeArguments
‪initializeArguments()
Definition: RenameFileViewHelper.php:34