|
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 Fab\Vidi\Domain\Model\Selection; |
|
18
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
|
19
|
|
|
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* Controller which handles actions related to Selection in Vidi Backend. |
|
23
|
|
|
*/ |
|
24
|
|
|
class SelectionController extends ActionController |
|
25
|
|
|
{ |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* @var \Fab\Vidi\Domain\Repository\SelectionRepository |
|
29
|
|
|
* @inject |
|
30
|
|
|
*/ |
|
31
|
|
|
protected $selectionRepository; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* @param Selection $selection |
|
35
|
|
|
*/ |
|
36
|
|
|
public function createAction(Selection $selection = NULL) |
|
37
|
|
|
{ |
|
38
|
|
|
$selection->setDataType($this->getModuleLoader()->getDataType()); |
|
|
|
|
|
|
39
|
|
|
|
|
40
|
|
|
$selection->setOwner($this->getBackendUser()->user['uid']); |
|
41
|
|
|
$this->selectionRepository->add($selection); |
|
42
|
|
|
$this->redirect('edit', 'Selection', 'vidi', array('dataType' => $selection->getDataType())); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* @param Selection $selection |
|
47
|
|
|
* @return string |
|
48
|
|
|
*/ |
|
49
|
|
|
public function deleteAction(Selection $selection) |
|
50
|
|
|
{ |
|
51
|
|
|
$this->selectionRepository->remove($selection); |
|
52
|
|
|
return 'ok'; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* @param Selection $selection |
|
57
|
|
|
*/ |
|
58
|
|
|
public function updateAction(Selection $selection) |
|
59
|
|
|
{ |
|
60
|
|
|
$this->selectionRepository->update($selection); |
|
61
|
|
|
$this->redirect('show', 'Selection', 'vidi', array('selection' => $selection->getUid())); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* @param Selection $selection |
|
66
|
|
|
*/ |
|
67
|
|
|
public function showAction(Selection $selection) |
|
68
|
|
|
{ |
|
69
|
|
|
$this->view->assign('selection', $selection); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* Returns an editing form for a given data type. |
|
74
|
|
|
* |
|
75
|
|
|
* @param string $dataType |
|
76
|
|
|
*/ |
|
77
|
|
|
public function editAction($dataType) |
|
78
|
|
|
{ |
|
79
|
|
|
$selections = $this->selectionRepository->findByDataTypeForCurrentBackendUser($dataType); |
|
80
|
|
|
$this->view->assign('selections', $selections); |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* @param string $dataType |
|
85
|
|
|
*/ |
|
86
|
|
|
public function listAction($dataType) |
|
87
|
|
|
{ |
|
88
|
|
|
$selections = $this->selectionRepository->findByDataTypeForCurrentBackendUser($dataType); |
|
89
|
|
|
$this->view->assign('selections', $selections); |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* Get the Vidi Module Loader. |
|
94
|
|
|
* |
|
95
|
|
|
* @return \Fab\Vidi\Module\ModuleLoader |
|
96
|
|
|
*/ |
|
97
|
|
|
protected function getModuleLoader() |
|
98
|
|
|
{ |
|
99
|
|
|
return GeneralUtility::makeInstance('Fab\Vidi\Module\ModuleLoader'); |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
/** |
|
103
|
|
|
* Returns an instance of the current Backend User. |
|
104
|
|
|
* |
|
105
|
|
|
* @return \TYPO3\CMS\Core\Authentication\BackendUserAuthentication |
|
106
|
|
|
*/ |
|
107
|
|
|
protected function getBackendUser() |
|
|
|
|
|
|
108
|
|
|
{ |
|
109
|
|
|
return $GLOBALS['BE_USER']; |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
|
|
} |
If a variable is not always an object, we recommend to add an additional type check to ensure your method call is safe: