|
1
|
|
|
<?php |
|
2
|
|
|
namespace Fab\Vidi\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 TYPO3\CMS\Core\Utility\GeneralUtility; |
|
18
|
|
|
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController; |
|
19
|
|
|
use Fab\Vidi\Tool\ToolInterface; |
|
20
|
|
|
use Fab\Vidi\Tool\ToolRegistry; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* Controller which handles tools related to a Vidi module. |
|
24
|
|
|
*/ |
|
25
|
|
|
class ToolController extends ActionController |
|
26
|
|
|
{ |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* @return void |
|
30
|
|
|
*/ |
|
31
|
|
|
public function welcomeAction() |
|
32
|
|
|
{ |
|
33
|
|
|
$items = array(); |
|
34
|
|
|
$tools = ToolRegistry::getInstance()->getTools($this->getModuleLoader()->getDataType()); |
|
35
|
|
|
|
|
36
|
|
|
foreach ($tools as $index => $tool) { |
|
37
|
|
|
$item = array(); |
|
38
|
|
|
$item['title'] = $tool->getTitle(); |
|
39
|
|
|
$item['description'] = $tool->getDescription(); |
|
40
|
|
|
|
|
41
|
|
|
$items[] = $item; |
|
42
|
|
|
} |
|
43
|
|
|
$this->view->assign('items', $items); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* @param string $tool |
|
48
|
|
|
* @param array $arguments |
|
49
|
|
|
* @return void |
|
50
|
|
|
* @validate $tool Fab\Vidi\Domain\Validator\ToolValidator |
|
51
|
|
|
*/ |
|
52
|
|
|
public function workAction($tool, array $arguments = array()) |
|
53
|
|
|
{ |
|
54
|
|
|
/** @var ToolInterface $tool */ |
|
55
|
|
|
$tool = GeneralUtility::makeInstance($tool); |
|
56
|
|
|
$workResult = $tool->work($arguments); |
|
57
|
|
|
$this->view->assign('result', $workResult); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* Get the Vidi Module Loader. |
|
62
|
|
|
* |
|
63
|
|
|
* @return \Fab\Vidi\Module\ModuleLoader |
|
64
|
|
|
*/ |
|
65
|
|
|
protected function getModuleLoader() |
|
66
|
|
|
{ |
|
67
|
|
|
return GeneralUtility::makeInstance('Fab\Vidi\Module\ModuleLoader'); |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
} |
|
71
|
|
|
|