|
1
|
|
|
<?php |
|
2
|
|
|
namespace Fab\Media\Controller; |
|
3
|
|
|
|
|
4
|
|
|
/** |
|
5
|
|
|
* This file is part of the TYPO3 CMS project. |
|
6
|
|
|
* |
|
7
|
|
|
* It is free software; you can redistribute it and/or modify it under |
|
8
|
|
|
* the terms of the GNU General Public License, either version 2 |
|
9
|
|
|
* of the License, or any later version. |
|
10
|
|
|
* |
|
11
|
|
|
* For the full copyright and license information, please read the |
|
12
|
|
|
* LICENSE.txt file that was distributed with this source code. |
|
13
|
|
|
* |
|
14
|
|
|
* The TYPO3 project - inspiring people to share! |
|
15
|
|
|
*/ |
|
16
|
|
|
|
|
17
|
|
|
use Fab\Media\Module\MediaModule; |
|
18
|
|
|
use TYPO3\CMS\Backend\Utility\BackendUtility; |
|
19
|
|
|
use TYPO3\CMS\Core\Resource\File; |
|
20
|
|
|
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* Controller which handles actions related to Image Editor. |
|
24
|
|
|
*/ |
|
25
|
|
|
class ImageEditorController extends ActionController |
|
26
|
|
|
{ |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* @var \TYPO3\CMS\Core\Page\PageRenderer |
|
30
|
|
|
* @inject |
|
31
|
|
|
*/ |
|
32
|
|
|
protected $pageRenderer; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* Initializes the controller before invoking an action method. |
|
36
|
|
|
*/ |
|
37
|
|
View Code Duplication |
public function initializeAction() |
|
|
|
|
|
|
38
|
|
|
{ |
|
39
|
|
|
$this->pageRenderer->addInlineLanguageLabelFile('EXT:media/Resources/Private/Language/locallang.xlf'); |
|
40
|
|
|
|
|
41
|
|
|
// Configure property mapping to retrieve the file object. |
|
42
|
|
|
if ($this->arguments->hasArgument('file')) { |
|
43
|
|
|
|
|
44
|
|
|
/** @var \Fab\Media\TypeConverter\FileConverter $typeConverter */ |
|
45
|
|
|
$typeConverter = $this->objectManager->get('Fab\Media\TypeConverter\FileConverter'); |
|
46
|
|
|
|
|
47
|
|
|
$propertyMappingConfiguration = $this->arguments->getArgument('file')->getPropertyMappingConfiguration(); |
|
48
|
|
|
$propertyMappingConfiguration->setTypeConverter($typeConverter); |
|
49
|
|
|
} |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* Handle GUI for inserting an image in the RTE. |
|
54
|
|
|
* |
|
55
|
|
|
* @param File $file |
|
56
|
|
|
* @return void |
|
57
|
|
|
*/ |
|
58
|
|
|
public function showAction(File $file) |
|
59
|
|
|
{ |
|
60
|
|
|
$this->view->assign('file', $file); |
|
61
|
|
|
$moduleSignature = MediaModule::getSignature(); |
|
62
|
|
|
$this->view->assign('moduleUrl', BackendUtility::getModuleUrl($moduleSignature)); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
} |
|
66
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.