‪TYPO3CMS  10.4
FileEditHook.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
26 
32 {
42  public function ‪preOutputProcessingHook(array $parameters, ‪EditFileController $pObj)
43  {
44  // Compile and register t3editor configuration
45  GeneralUtility::makeInstance(T3editor::class)->registerConfiguration();
46 
47  $target = '';
48  if (isset($parameters['target']) && is_string($parameters['target'])) {
49  $target = $parameters['target'];
50  }
51 
52  $fileExtension = GeneralUtility::makeInstance(ResourceFactory::class)->retrieveFileOrFolderObject($target)->getExtension();
53  $modeRegistry = GeneralUtility::makeInstance(ModeRegistry::class);
54  try {
55  $mode = $modeRegistry->getByFileExtension($fileExtension);
56  } catch (‪InvalidModeException $e) {
57  $mode = $modeRegistry->getDefaultMode();
58  }
59 
60  $parameters['dataColumnDefinition']['config']['renderType'] = 't3editor';
61  $parameters['dataColumnDefinition']['config']['format'] = $mode->getFormatCode();
62  }
63 }
‪TYPO3\CMS\T3editor\Hook\FileEditHook\preOutputProcessingHook
‪preOutputProcessingHook(array $parameters, EditFileController $pObj)
Definition: FileEditHook.php:42
‪TYPO3\CMS\T3editor\Hook\FileEditHook
Definition: FileEditHook.php:32
‪TYPO3\CMS\T3editor\Hook
Definition: FileEditHook.php:18
‪TYPO3\CMS\Core\Resource\ResourceFactory
Definition: ResourceFactory.php:41
‪TYPO3\CMS\T3editor\T3editor
Definition: T3editor.php:35
‪TYPO3\CMS\T3editor\Exception\InvalidModeException
Definition: InvalidModeException.php:27
‪TYPO3\CMS\T3editor\Registry\ModeRegistry
Definition: ModeRegistry.php:30
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46
‪TYPO3\CMS\Filelist\Controller\File\EditFileController
Definition: EditFileController.php:45