Completed
Push — master ( 080764...892a3f )
by Fabien
52:24
created
Classes/Processor/ContentObjectProcessor.php 1 patch
Indentation   +117 added lines, -117 removed lines patch added patch discarded remove patch
@@ -23,121 +23,121 @@
 block discarded – undo
23 23
 class ContentObjectProcessor implements SingletonInterface
24 24
 {
25 25
 
26
-    /**
27
-     * @param ProcessContentDataSignalArguments $signalArguments
28
-     * @return array
29
-     */
30
-    public function processRelations(ProcessContentDataSignalArguments $signalArguments)
31
-    {
32
-
33
-        $contentObject = $signalArguments->getContentObject();
34
-        $fieldNameAndPath = $signalArguments->getFieldNameAndPath();
35
-        $contentData = $signalArguments->getContentData();
36
-        $savingBehavior = $signalArguments->getSavingBehavior();
37
-
38
-        if ($savingBehavior !== SavingBehavior::REPLACE) {
39
-            $contentData = $this->appendOrRemoveRelations($contentObject, $fieldNameAndPath, $contentData, $savingBehavior);
40
-            $signalArguments->setContentData($contentData);
41
-        }
42
-
43
-        return array($signalArguments);
44
-    }
45
-
46
-    /**
47
-     * @param Content $object
48
-     * @param $fieldNameAndPath
49
-     * @param array $contentData
50
-     * @param string $savingBehavior
51
-     * @return array
52
-     */
53
-    protected function appendOrRemoveRelations(Content $object, $fieldNameAndPath, array $contentData, $savingBehavior)
54
-    {
55
-
56
-        foreach ($contentData as $fieldName => $values) {
57
-
58
-            $resolvedObject = $this->getContentObjectResolver()->getObject($object, $fieldNameAndPath);
59
-
60
-            if (Tca::table($resolvedObject)->field($fieldName)->hasMany()) {
61
-
62
-                // true means CSV values must be converted to array.
63
-                if (!is_array($values)) {
64
-                    $values = GeneralUtility::trimExplode(',', $values);
65
-                }
66
-                $relatedValues = $this->getRelatedValues($object, $fieldNameAndPath, $fieldName);
67
-
68
-                foreach ($values as $value) {
69
-                    $appendOrRemove = $savingBehavior . 'Relations';
70
-                    $relatedValues = $this->$appendOrRemove($value, $relatedValues);
71
-                }
72
-
73
-                $contentData[$fieldName] = $relatedValues;
74
-            }
75
-        }
76
-        return $contentData;
77
-    }
78
-
79
-    /**
80
-     * @param $value
81
-     * @param array $relatedValues
82
-     * @return array
83
-     */
84
-    protected function appendRelations($value, array $relatedValues)
85
-    {
86
-        if (!in_array($value, $relatedValues)) {
87
-            $relatedValues[] = $value;
88
-        }
89
-        return $relatedValues;
90
-    }
91
-
92
-    /**
93
-     * @param $value
94
-     * @param array $relatedValues
95
-     * @return array
96
-     */
97
-    protected function removeRelations($value, array $relatedValues)
98
-    {
99
-        if (in_array($value, $relatedValues)) {
100
-            $key = array_search($value, $relatedValues);
101
-            unset($relatedValues[$key]);
102
-        }
103
-        return $relatedValues;
104
-    }
105
-
106
-    /**
107
-     * @param Content $object
108
-     * @param string $fieldNameAndPath
109
-     * @param string $fieldName
110
-     * @return array
111
-     */
112
-    protected function getRelatedValues(Content $object, $fieldNameAndPath, $fieldName)
113
-    {
114
-
115
-        $values = [];
116
-        $relatedContentObjects = $this->getContentObjectResolver()->getValue($object, $fieldNameAndPath, $fieldName);
117
-
118
-        if (is_array($relatedContentObjects)) {
119
-            /** @var Content $relatedContentObject */
120
-            foreach ($relatedContentObjects as $relatedContentObject) {
121
-                $values[] = $relatedContentObject->getUid();
122
-            }
123
-        }
124
-
125
-        return $values;
126
-    }
127
-
128
-    /**
129
-     * @return ContentObjectResolver|object
130
-     */
131
-    protected function getContentObjectResolver()
132
-    {
133
-        return GeneralUtility::makeInstance(ContentObjectResolver::class);
134
-    }
135
-
136
-    /**
137
-     * @return FieldPathResolver|object
138
-     */
139
-    protected function getFieldPathResolver()
140
-    {
141
-        return GeneralUtility::makeInstance(FieldPathResolver::class);
142
-    }
26
+	/**
27
+	 * @param ProcessContentDataSignalArguments $signalArguments
28
+	 * @return array
29
+	 */
30
+	public function processRelations(ProcessContentDataSignalArguments $signalArguments)
31
+	{
32
+
33
+		$contentObject = $signalArguments->getContentObject();
34
+		$fieldNameAndPath = $signalArguments->getFieldNameAndPath();
35
+		$contentData = $signalArguments->getContentData();
36
+		$savingBehavior = $signalArguments->getSavingBehavior();
37
+
38
+		if ($savingBehavior !== SavingBehavior::REPLACE) {
39
+			$contentData = $this->appendOrRemoveRelations($contentObject, $fieldNameAndPath, $contentData, $savingBehavior);
40
+			$signalArguments->setContentData($contentData);
41
+		}
42
+
43
+		return array($signalArguments);
44
+	}
45
+
46
+	/**
47
+	 * @param Content $object
48
+	 * @param $fieldNameAndPath
49
+	 * @param array $contentData
50
+	 * @param string $savingBehavior
51
+	 * @return array
52
+	 */
53
+	protected function appendOrRemoveRelations(Content $object, $fieldNameAndPath, array $contentData, $savingBehavior)
54
+	{
55
+
56
+		foreach ($contentData as $fieldName => $values) {
57
+
58
+			$resolvedObject = $this->getContentObjectResolver()->getObject($object, $fieldNameAndPath);
59
+
60
+			if (Tca::table($resolvedObject)->field($fieldName)->hasMany()) {
61
+
62
+				// true means CSV values must be converted to array.
63
+				if (!is_array($values)) {
64
+					$values = GeneralUtility::trimExplode(',', $values);
65
+				}
66
+				$relatedValues = $this->getRelatedValues($object, $fieldNameAndPath, $fieldName);
67
+
68
+				foreach ($values as $value) {
69
+					$appendOrRemove = $savingBehavior . 'Relations';
70
+					$relatedValues = $this->$appendOrRemove($value, $relatedValues);
71
+				}
72
+
73
+				$contentData[$fieldName] = $relatedValues;
74
+			}
75
+		}
76
+		return $contentData;
77
+	}
78
+
79
+	/**
80
+	 * @param $value
81
+	 * @param array $relatedValues
82
+	 * @return array
83
+	 */
84
+	protected function appendRelations($value, array $relatedValues)
85
+	{
86
+		if (!in_array($value, $relatedValues)) {
87
+			$relatedValues[] = $value;
88
+		}
89
+		return $relatedValues;
90
+	}
91
+
92
+	/**
93
+	 * @param $value
94
+	 * @param array $relatedValues
95
+	 * @return array
96
+	 */
97
+	protected function removeRelations($value, array $relatedValues)
98
+	{
99
+		if (in_array($value, $relatedValues)) {
100
+			$key = array_search($value, $relatedValues);
101
+			unset($relatedValues[$key]);
102
+		}
103
+		return $relatedValues;
104
+	}
105
+
106
+	/**
107
+	 * @param Content $object
108
+	 * @param string $fieldNameAndPath
109
+	 * @param string $fieldName
110
+	 * @return array
111
+	 */
112
+	protected function getRelatedValues(Content $object, $fieldNameAndPath, $fieldName)
113
+	{
114
+
115
+		$values = [];
116
+		$relatedContentObjects = $this->getContentObjectResolver()->getValue($object, $fieldNameAndPath, $fieldName);
117
+
118
+		if (is_array($relatedContentObjects)) {
119
+			/** @var Content $relatedContentObject */
120
+			foreach ($relatedContentObjects as $relatedContentObject) {
121
+				$values[] = $relatedContentObject->getUid();
122
+			}
123
+		}
124
+
125
+		return $values;
126
+	}
127
+
128
+	/**
129
+	 * @return ContentObjectResolver|object
130
+	 */
131
+	protected function getContentObjectResolver()
132
+	{
133
+		return GeneralUtility::makeInstance(ContentObjectResolver::class);
134
+	}
135
+
136
+	/**
137
+	 * @return FieldPathResolver|object
138
+	 */
139
+	protected function getFieldPathResolver()
140
+	{
141
+		return GeneralUtility::makeInstance(FieldPathResolver::class);
142
+	}
143 143
 }
Please login to merge, or discard this patch.
Classes/Command/VidiCommandController.php 1 patch
Indentation   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -23,59 +23,59 @@
 block discarded – undo
23 23
 class VidiCommandController extends Command
24 24
 {
25 25
 
26
-    /**
27
-     * Configure the command by defining the name, options and arguments
28
-     */
29
-    protected function configure()
30
-    {
31
-        $this->setDescription('Check TCA configuration for relations used in grid.')
32
-        ->addOption(
33
-        'table',
34
-        'c',
35
-        InputOption::VALUE_NONE,
36
-        'The table name. If not defined check for every table.'
37
-    );
38
-    }
26
+	/**
27
+	 * Configure the command by defining the name, options and arguments
28
+	 */
29
+	protected function configure()
30
+	{
31
+		$this->setDescription('Check TCA configuration for relations used in grid.')
32
+		->addOption(
33
+		'table',
34
+		'c',
35
+		InputOption::VALUE_NONE,
36
+		'The table name. If not defined check for every table.'
37
+	);
38
+	}
39 39
 
40
-    /**
41
-     * Executes the command for removing the lock file
42
-     *
43
-     * @param InputInterface $input
44
-     * @param OutputInterface $output
45
-     */
46
-    protected function execute(InputInterface $input, OutputInterface $output)
47
-    {
48
-        $io = new SymfonyStyle($input, $output);
49
-        foreach ($GLOBALS['TCA'] as $tableName => $TCA) {
50
-            $table = $input->getOption('table');
51
-            if ($table !== '' && $table !== $tableName) {
52
-                continue;
53
-            }
40
+	/**
41
+	 * Executes the command for removing the lock file
42
+	 *
43
+	 * @param InputInterface $input
44
+	 * @param OutputInterface $output
45
+	 */
46
+	protected function execute(InputInterface $input, OutputInterface $output)
47
+	{
48
+		$io = new SymfonyStyle($input, $output);
49
+		foreach ($GLOBALS['TCA'] as $tableName => $TCA) {
50
+			$table = $input->getOption('table');
51
+			if ($table !== '' && $table !== $tableName) {
52
+				continue;
53
+			}
54 54
 
55
-            $fields = Tca::grid($tableName)->getFields();
56
-            if (!empty($fields)) {
55
+			$fields = Tca::grid($tableName)->getFields();
56
+			if (!empty($fields)) {
57 57
 
58
-                $relations = $this->getGridAnalyserService()->checkRelationForTable($tableName);
59
-                if (!empty($relations)) {
58
+				$relations = $this->getGridAnalyserService()->checkRelationForTable($tableName);
59
+				if (!empty($relations)) {
60 60
 
61
-                    $io->text('');
62
-                    $io->text('--------------------------------------------------------------------');
63
-                    $io->text('');
64
-                    $io->text(sprintf('Relations for "%s"', $tableName));
65
-                    $io->text('');
66
-                    $io->text(implode("\n", $relations));
67
-                }
68
-            }
69
-        }
70
-    }
61
+					$io->text('');
62
+					$io->text('--------------------------------------------------------------------');
63
+					$io->text('');
64
+					$io->text(sprintf('Relations for "%s"', $tableName));
65
+					$io->text('');
66
+					$io->text(implode("\n", $relations));
67
+				}
68
+			}
69
+		}
70
+	}
71 71
 
72
-    /**
73
-     * Get the Vidi Module Loader.
74
-     *
75
-     * @return GridAnalyserService|object
76
-     */
77
-    protected function getGridAnalyserService()
78
-    {
79
-        return GeneralUtility::makeInstance(GridAnalyserService::class);
80
-    }
72
+	/**
73
+	 * Get the Vidi Module Loader.
74
+	 *
75
+	 * @return GridAnalyserService|object
76
+	 */
77
+	protected function getGridAnalyserService()
78
+	{
79
+		return GeneralUtility::makeInstance(GridAnalyserService::class);
80
+	}
81 81
 }
Please login to merge, or discard this patch.
Classes/Grid/ColumnRendererInterface.php 1 patch
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -14,46 +14,46 @@
 block discarded – undo
14 14
 interface ColumnRendererInterface
15 15
 {
16 16
 
17
-    /**
18
-     * Render a column in the Grid.
19
-     *
20
-     * @return string
21
-     */
22
-    public function render();
23
-
24
-    /**
25
-     * @param Content $object
26
-     * @return $this
27
-     */
28
-    public function setObject($object);
29
-
30
-    /**
31
-     * @param string $fieldName
32
-     * @return $this
33
-     */
34
-    public function setFieldName($fieldName);
35
-
36
-    /**
37
-     * @param int $index
38
-     * @return $this
39
-     */
40
-    public function setRowIndex($index);
41
-
42
-    /**
43
-     * @param array $configuration
44
-     * @return $this
45
-     */
46
-    public function setFieldConfiguration($configuration);
47
-
48
-    /**
49
-     * @param array $configuration
50
-     * @return $this
51
-     */
52
-    public function setGridRendererConfiguration($configuration);
53
-
54
-    /**
55
-     * @return array
56
-     */
57
-    public function getConfiguration();
17
+	/**
18
+	 * Render a column in the Grid.
19
+	 *
20
+	 * @return string
21
+	 */
22
+	public function render();
23
+
24
+	/**
25
+	 * @param Content $object
26
+	 * @return $this
27
+	 */
28
+	public function setObject($object);
29
+
30
+	/**
31
+	 * @param string $fieldName
32
+	 * @return $this
33
+	 */
34
+	public function setFieldName($fieldName);
35
+
36
+	/**
37
+	 * @param int $index
38
+	 * @return $this
39
+	 */
40
+	public function setRowIndex($index);
41
+
42
+	/**
43
+	 * @param array $configuration
44
+	 * @return $this
45
+	 */
46
+	public function setFieldConfiguration($configuration);
47
+
48
+	/**
49
+	 * @param array $configuration
50
+	 * @return $this
51
+	 */
52
+	public function setGridRendererConfiguration($configuration);
53
+
54
+	/**
55
+	 * @return array
56
+	 */
57
+	public function getConfiguration();
58 58
 
59 59
 }
Please login to merge, or discard this patch.
Classes/Grid/ColumnRendererAbstract.php 1 patch
Indentation   +186 added lines, -186 removed lines patch added patch discarded remove patch
@@ -19,191 +19,191 @@
 block discarded – undo
19 19
 abstract class ColumnRendererAbstract implements ColumnRendererInterface
20 20
 {
21 21
 
22
-    /**
23
-     * The content object.
24
-     *
25
-     * @var Content
26
-     */
27
-    protected $object;
28
-
29
-    /**
30
-     * @var string
31
-     */
32
-    protected $fieldName;
33
-
34
-    /**
35
-     * @var int
36
-     */
37
-    protected $rowIndex;
38
-
39
-    /**
40
-     * @var array
41
-     */
42
-    protected $fieldConfiguration = [];
43
-
44
-    /**
45
-     * @var array
46
-     */
47
-    protected $gridRendererConfiguration = [];
48
-
49
-    /**
50
-     * @var array
51
-     */
52
-    protected $configuration = [];
53
-
54
-    /**
55
-     * Constructor of a Generic component in Vidi.
56
-     *
57
-     * @param array $configuration
58
-     * @param array $legacyParameterConfiguration
59
-     */
60
-    public function __construct($configuration = [], $legacyParameterConfiguration = array())
61
-    {
62
-        if (is_string($configuration)) {
63
-            $configuration = $legacyParameterConfiguration;
64
-            GeneralUtility::deprecationLog('ColumnRendererAbstract: first parameter must now be an array. Please edit me in ' . get_class($this));
65
-        }
66
-        $this->configuration = $configuration;
67
-    }
68
-
69
-    /**
70
-     * @return array
71
-     */
72
-    public function getConfiguration()
73
-    {
74
-        return $this->configuration;
75
-    }
76
-
77
-    /**
78
-     * @return Content
79
-     */
80
-    public function getObject()
81
-    {
82
-        return $this->object;
83
-    }
84
-
85
-    /**
86
-     * @param Content $object
87
-     * @return $this
88
-     */
89
-    public function setObject($object)
90
-    {
91
-        $this->object = $object;
92
-        return $this;
93
-    }
94
-
95
-    /**
96
-     * @return string
97
-     */
98
-    public function getFieldName()
99
-    {
100
-        return $this->fieldName;
101
-    }
102
-
103
-    /**
104
-     * @param string $fieldName
105
-     * @return $this
106
-     */
107
-    public function setFieldName($fieldName)
108
-    {
109
-        $this->fieldName = $fieldName;
110
-        return $this;
111
-    }
112
-
113
-    /**
114
-     * @return int
115
-     */
116
-    public function getRowIndex()
117
-    {
118
-        return $this->rowIndex;
119
-    }
120
-
121
-    /**
122
-     * @param int $rowIndex
123
-     * @return $this
124
-     */
125
-    public function setRowIndex($rowIndex)
126
-    {
127
-        $this->rowIndex = $rowIndex;
128
-        return $this;
129
-    }
130
-
131
-    /**
132
-     * @return array
133
-     */
134
-    public function getFieldConfiguration()
135
-    {
136
-        return $this->fieldConfiguration;
137
-    }
138
-
139
-    /**
140
-     * @param array $fieldConfiguration
141
-     * @return $this
142
-     */
143
-    public function setFieldConfiguration($fieldConfiguration)
144
-    {
145
-        $this->fieldConfiguration = $fieldConfiguration;
146
-        return $this;
147
-    }
148
-
149
-    /**
150
-     * @return array
151
-     */
152
-    public function getGridRendererConfiguration()
153
-    {
154
-        return $this->gridRendererConfiguration;
155
-    }
156
-
157
-    /**
158
-     * @param array $gridRendererConfiguration
159
-     * @return $this
160
-     */
161
-    public function setGridRendererConfiguration($gridRendererConfiguration)
162
-    {
163
-        $this->gridRendererConfiguration = $gridRendererConfiguration;
164
-        return $this;
165
-    }
166
-
167
-    /**
168
-     * Escapes special characters with their escaped counterparts as needed using PHPs htmlentities() function.
169
-     *
170
-     * @param string $value string to format
171
-     * @param bool $keepQuotes if TRUE, single and double quotes won't be replaced (sets ENT_NOQUOTES flag)
172
-     * @param string $encoding
173
-     * @return string
174
-     * @see http://www.php.net/manual/function.htmlentities.php
175
-     * @api
176
-     */
177
-    protected function secure($value , $keepQuotes = false, $encoding = 'UTF-8')
178
-    {
179
-        $flags = $keepQuotes ? ENT_NOQUOTES : ENT_COMPAT;
180
-        return htmlspecialchars($value, $flags, $encoding);
181
-    }
182
-
183
-    /**
184
-     * Get the Vidi Module Loader.
185
-     *
186
-     * @return object|ModuleLoader
187
-     */
188
-    protected function getModuleLoader()
189
-    {
190
-        return GeneralUtility::makeInstance(ModuleLoader::class);
191
-    }
192
-
193
-    /**
194
-     * @return object|IconFactory
195
-     */
196
-    protected function getIconFactory()
197
-    {
198
-        return GeneralUtility::makeInstance(IconFactory::class);
199
-    }
200
-
201
-    /**
202
-     * @return object|LanguageService
203
-     */
204
-    protected function getLanguageService()
205
-    {
206
-        return GeneralUtility::makeInstance(LanguageService::class);
207
-    }
22
+	/**
23
+	 * The content object.
24
+	 *
25
+	 * @var Content
26
+	 */
27
+	protected $object;
28
+
29
+	/**
30
+	 * @var string
31
+	 */
32
+	protected $fieldName;
33
+
34
+	/**
35
+	 * @var int
36
+	 */
37
+	protected $rowIndex;
38
+
39
+	/**
40
+	 * @var array
41
+	 */
42
+	protected $fieldConfiguration = [];
43
+
44
+	/**
45
+	 * @var array
46
+	 */
47
+	protected $gridRendererConfiguration = [];
48
+
49
+	/**
50
+	 * @var array
51
+	 */
52
+	protected $configuration = [];
53
+
54
+	/**
55
+	 * Constructor of a Generic component in Vidi.
56
+	 *
57
+	 * @param array $configuration
58
+	 * @param array $legacyParameterConfiguration
59
+	 */
60
+	public function __construct($configuration = [], $legacyParameterConfiguration = array())
61
+	{
62
+		if (is_string($configuration)) {
63
+			$configuration = $legacyParameterConfiguration;
64
+			GeneralUtility::deprecationLog('ColumnRendererAbstract: first parameter must now be an array. Please edit me in ' . get_class($this));
65
+		}
66
+		$this->configuration = $configuration;
67
+	}
68
+
69
+	/**
70
+	 * @return array
71
+	 */
72
+	public function getConfiguration()
73
+	{
74
+		return $this->configuration;
75
+	}
76
+
77
+	/**
78
+	 * @return Content
79
+	 */
80
+	public function getObject()
81
+	{
82
+		return $this->object;
83
+	}
84
+
85
+	/**
86
+	 * @param Content $object
87
+	 * @return $this
88
+	 */
89
+	public function setObject($object)
90
+	{
91
+		$this->object = $object;
92
+		return $this;
93
+	}
94
+
95
+	/**
96
+	 * @return string
97
+	 */
98
+	public function getFieldName()
99
+	{
100
+		return $this->fieldName;
101
+	}
102
+
103
+	/**
104
+	 * @param string $fieldName
105
+	 * @return $this
106
+	 */
107
+	public function setFieldName($fieldName)
108
+	{
109
+		$this->fieldName = $fieldName;
110
+		return $this;
111
+	}
112
+
113
+	/**
114
+	 * @return int
115
+	 */
116
+	public function getRowIndex()
117
+	{
118
+		return $this->rowIndex;
119
+	}
120
+
121
+	/**
122
+	 * @param int $rowIndex
123
+	 * @return $this
124
+	 */
125
+	public function setRowIndex($rowIndex)
126
+	{
127
+		$this->rowIndex = $rowIndex;
128
+		return $this;
129
+	}
130
+
131
+	/**
132
+	 * @return array
133
+	 */
134
+	public function getFieldConfiguration()
135
+	{
136
+		return $this->fieldConfiguration;
137
+	}
138
+
139
+	/**
140
+	 * @param array $fieldConfiguration
141
+	 * @return $this
142
+	 */
143
+	public function setFieldConfiguration($fieldConfiguration)
144
+	{
145
+		$this->fieldConfiguration = $fieldConfiguration;
146
+		return $this;
147
+	}
148
+
149
+	/**
150
+	 * @return array
151
+	 */
152
+	public function getGridRendererConfiguration()
153
+	{
154
+		return $this->gridRendererConfiguration;
155
+	}
156
+
157
+	/**
158
+	 * @param array $gridRendererConfiguration
159
+	 * @return $this
160
+	 */
161
+	public function setGridRendererConfiguration($gridRendererConfiguration)
162
+	{
163
+		$this->gridRendererConfiguration = $gridRendererConfiguration;
164
+		return $this;
165
+	}
166
+
167
+	/**
168
+	 * Escapes special characters with their escaped counterparts as needed using PHPs htmlentities() function.
169
+	 *
170
+	 * @param string $value string to format
171
+	 * @param bool $keepQuotes if TRUE, single and double quotes won't be replaced (sets ENT_NOQUOTES flag)
172
+	 * @param string $encoding
173
+	 * @return string
174
+	 * @see http://www.php.net/manual/function.htmlentities.php
175
+	 * @api
176
+	 */
177
+	protected function secure($value , $keepQuotes = false, $encoding = 'UTF-8')
178
+	{
179
+		$flags = $keepQuotes ? ENT_NOQUOTES : ENT_COMPAT;
180
+		return htmlspecialchars($value, $flags, $encoding);
181
+	}
182
+
183
+	/**
184
+	 * Get the Vidi Module Loader.
185
+	 *
186
+	 * @return object|ModuleLoader
187
+	 */
188
+	protected function getModuleLoader()
189
+	{
190
+		return GeneralUtility::makeInstance(ModuleLoader::class);
191
+	}
192
+
193
+	/**
194
+	 * @return object|IconFactory
195
+	 */
196
+	protected function getIconFactory()
197
+	{
198
+		return GeneralUtility::makeInstance(IconFactory::class);
199
+	}
200
+
201
+	/**
202
+	 * @return object|LanguageService
203
+	 */
204
+	protected function getLanguageService()
205
+	{
206
+		return GeneralUtility::makeInstance(LanguageService::class);
207
+	}
208 208
 
209 209
 }
Please login to merge, or discard this patch.
Classes/Grid/VisibilityRenderer.php 2 patches
Indentation   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -21,83 +21,83 @@
 block discarded – undo
21 21
 class VisibilityRenderer extends ColumnRendererAbstract
22 22
 {
23 23
 
24
-    /**
25
-     * Render visibility for the Grid.
26
-     *
27
-     * @return string
28
-     */
29
-    public function render()
30
-    {
31
-
32
-        $output = '';
33
-        $hiddenField = Tca::table()->getHiddenField();
34
-
35
-        if ($hiddenField) {
36
-
37
-            $spriteName = $this->object[$hiddenField] ? 'actions-edit-unhide' : 'actions-edit-hide';
38
-
39
-            $label = $this->object[$hiddenField] ? 'unHide' : 'hide';
40
-
41
-            $output = $this->makeLinkButton()
42
-                ->setHref($this->getEditUri($this->object))
43
-                ->setClasses('btn-visibility-toggle')
44
-                ->setDataAttributes([
45
-                    'toggle' => 'tooltip',
46
-                ])
47
-                ->setTitle($this->getLabelService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_mod_web_list.xlf:' . $label))
48
-                ->setIcon($this->getIconFactory()->getIcon($spriteName, Icon::SIZE_SMALL))
49
-                ->render();
50
-        }
51
-        return $output;
52
-    }
53
-
54
-    /**
55
-     * @param Content $object
56
-     * @return string
57
-     */
58
-    protected function getEditUri(Content $object)
59
-    {
60
-        $hiddenField = Tca::table()->getHiddenField();
61
-
62
-        $additionalParameters = array(
63
-            $this->getModuleLoader()->getParameterPrefix() => [
64
-                'controller' => 'Content',
65
-                'action' => 'update',
66
-                'format' => 'json',
67
-                'fieldNameAndPath' => Tca::table()->getHiddenField(),
68
-                'matches' => [
69
-                    'uid' => $object->getUid(),
70
-                ],
71
-                'content' => [$hiddenField => (int)!$this->object[$hiddenField]],
72
-            ],
73
-        );
74
-
75
-        return $this->getModuleLoader()->getModuleUrl($additionalParameters);
76
-    }
77
-
78
-    /**
79
-     * @return LinkButton
80
-     */
81
-    protected function makeLinkButton()
82
-    {
83
-        return GeneralUtility::makeInstance(LinkButton::class);
84
-    }
85
-
86
-
87
-    /**
88
-     * @return IconFactory
89
-     */
90
-    protected function getIconFactory()
91
-    {
92
-        return GeneralUtility::makeInstance(IconFactory::class);
93
-    }
94
-
95
-    /**
96
-     * @return LanguageService
97
-     */
98
-    protected function getLabelService()
99
-    {
100
-        return $GLOBALS['LANG'];
101
-    }
24
+	/**
25
+	 * Render visibility for the Grid.
26
+	 *
27
+	 * @return string
28
+	 */
29
+	public function render()
30
+	{
31
+
32
+		$output = '';
33
+		$hiddenField = Tca::table()->getHiddenField();
34
+
35
+		if ($hiddenField) {
36
+
37
+			$spriteName = $this->object[$hiddenField] ? 'actions-edit-unhide' : 'actions-edit-hide';
38
+
39
+			$label = $this->object[$hiddenField] ? 'unHide' : 'hide';
40
+
41
+			$output = $this->makeLinkButton()
42
+				->setHref($this->getEditUri($this->object))
43
+				->setClasses('btn-visibility-toggle')
44
+				->setDataAttributes([
45
+					'toggle' => 'tooltip',
46
+				])
47
+				->setTitle($this->getLabelService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_mod_web_list.xlf:' . $label))
48
+				->setIcon($this->getIconFactory()->getIcon($spriteName, Icon::SIZE_SMALL))
49
+				->render();
50
+		}
51
+		return $output;
52
+	}
53
+
54
+	/**
55
+	 * @param Content $object
56
+	 * @return string
57
+	 */
58
+	protected function getEditUri(Content $object)
59
+	{
60
+		$hiddenField = Tca::table()->getHiddenField();
61
+
62
+		$additionalParameters = array(
63
+			$this->getModuleLoader()->getParameterPrefix() => [
64
+				'controller' => 'Content',
65
+				'action' => 'update',
66
+				'format' => 'json',
67
+				'fieldNameAndPath' => Tca::table()->getHiddenField(),
68
+				'matches' => [
69
+					'uid' => $object->getUid(),
70
+				],
71
+				'content' => [$hiddenField => (int)!$this->object[$hiddenField]],
72
+			],
73
+		);
74
+
75
+		return $this->getModuleLoader()->getModuleUrl($additionalParameters);
76
+	}
77
+
78
+	/**
79
+	 * @return LinkButton
80
+	 */
81
+	protected function makeLinkButton()
82
+	{
83
+		return GeneralUtility::makeInstance(LinkButton::class);
84
+	}
85
+
86
+
87
+	/**
88
+	 * @return IconFactory
89
+	 */
90
+	protected function getIconFactory()
91
+	{
92
+		return GeneralUtility::makeInstance(IconFactory::class);
93
+	}
94
+
95
+	/**
96
+	 * @return LanguageService
97
+	 */
98
+	protected function getLabelService()
99
+	{
100
+		return $GLOBALS['LANG'];
101
+	}
102 102
 
103 103
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@
 block discarded – undo
44 44
                 ->setDataAttributes([
45 45
                     'toggle' => 'tooltip',
46 46
                 ])
47
-                ->setTitle($this->getLabelService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_mod_web_list.xlf:' . $label))
47
+                ->setTitle($this->getLabelService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_mod_web_list.xlf:'.$label))
48 48
                 ->setIcon($this->getIconFactory()->getIcon($spriteName, Icon::SIZE_SMALL))
49 49
                 ->render();
50 50
         }
Please login to merge, or discard this patch.
Classes/Module/ModuleService.php 1 patch
Indentation   +93 added lines, -93 removed lines patch added patch discarded remove patch
@@ -21,106 +21,106 @@
 block discarded – undo
21 21
 class ModuleService implements SingletonInterface
22 22
 {
23 23
 
24
-    /**
25
-     * @var array
26
-     */
27
-    protected $storage = [];
24
+	/**
25
+	 * @var array
26
+	 */
27
+	protected $storage = [];
28 28
 
29
-    /**
30
-     * Returns a class instance
31
-     *
32
-     * @return \Fab\Vidi\Module\ModuleService|object
33
-     */
34
-    static public function getInstance()
35
-    {
36
-        return GeneralUtility::makeInstance(\Fab\Vidi\Module\ModuleService::class);
37
-    }
29
+	/**
30
+	 * Returns a class instance
31
+	 *
32
+	 * @return \Fab\Vidi\Module\ModuleService|object
33
+	 */
34
+	static public function getInstance()
35
+	{
36
+		return GeneralUtility::makeInstance(\Fab\Vidi\Module\ModuleService::class);
37
+	}
38 38
 
39
-    /**
40
-     * Fetch all modules to be displayed on the current pid.
41
-     *
42
-     * @return array
43
-     */
44
-    public function getModulesForCurrentPid(): array
45
-    {
46
-        $pid = $this->getModuleLoader()->getCurrentPid();
47
-        return $this->getModulesForPid($pid);
48
-    }
39
+	/**
40
+	 * Fetch all modules to be displayed on the current pid.
41
+	 *
42
+	 * @return array
43
+	 */
44
+	public function getModulesForCurrentPid(): array
45
+	{
46
+		$pid = $this->getModuleLoader()->getCurrentPid();
47
+		return $this->getModulesForPid($pid);
48
+	}
49 49
 
50
-    /**
51
-     * Fetch all modules displayed given a pid.
52
-     *
53
-     * @param int $pid
54
-     * @return array
55
-     */
56
-    public function getModulesForPid($pid = null): array
57
-    {
58
-        if (!isset($this->storage[$pid])) {
50
+	/**
51
+	 * Fetch all modules displayed given a pid.
52
+	 *
53
+	 * @param int $pid
54
+	 * @return array
55
+	 */
56
+	public function getModulesForPid($pid = null): array
57
+	{
58
+		if (!isset($this->storage[$pid])) {
59 59
 
60
-            $modules = [];
61
-            foreach ($GLOBALS['TCA'] as $dataType => $configuration) {
62
-                if (Tca::table($dataType)->isNotHidden()) {
63
-                    $record = $this->getDataService()->getRecord(
64
-                        $dataType,
65
-                        [
66
-                            'pid' => $pid
67
-                        ]
68
-                    );
69
-                    if (!empty($record)) {
70
-                        $moduleName = 'Vidi' . GeneralUtility::underscoredToUpperCamelCase($dataType) . 'M1';
71
-                        $title = Tca::table($dataType)->getTitle();
72
-                        $modules[$moduleName] = $title;
73
-                    }
74
-                }
75
-            }
76
-            $this->storage[$pid] = $modules;
77
-        }
78
-        return $this->storage[$pid];
79
-    }
60
+			$modules = [];
61
+			foreach ($GLOBALS['TCA'] as $dataType => $configuration) {
62
+				if (Tca::table($dataType)->isNotHidden()) {
63
+					$record = $this->getDataService()->getRecord(
64
+						$dataType,
65
+						[
66
+							'pid' => $pid
67
+						]
68
+					);
69
+					if (!empty($record)) {
70
+						$moduleName = 'Vidi' . GeneralUtility::underscoredToUpperCamelCase($dataType) . 'M1';
71
+						$title = Tca::table($dataType)->getTitle();
72
+						$modules[$moduleName] = $title;
73
+					}
74
+				}
75
+			}
76
+			$this->storage[$pid] = $modules;
77
+		}
78
+		return $this->storage[$pid];
79
+	}
80 80
 
81
-    /**
82
-     * Fetch the first module for the current pid.
83
-     *
84
-     * @return string
85
-     */
86
-    public function getFirstModuleForCurrentPid(): string
87
-    {
88
-        $pid = $this->getModuleLoader()->getCurrentPid();
89
-        return $this->getFirstModuleForPid($pid);
90
-    }
81
+	/**
82
+	 * Fetch the first module for the current pid.
83
+	 *
84
+	 * @return string
85
+	 */
86
+	public function getFirstModuleForCurrentPid(): string
87
+	{
88
+		$pid = $this->getModuleLoader()->getCurrentPid();
89
+		return $this->getFirstModuleForPid($pid);
90
+	}
91 91
 
92
-    /**
93
-     * Fetch the module given a pid.
94
-     *
95
-     * @param int $pid
96
-     * @return string
97
-     */
98
-    public function getFirstModuleForPid($pid): string
99
-    {
100
-        $firstModule = '';
101
-        $modules = $this->getModulesForPid($pid);
102
-        if (!empty($modules)) {
103
-            $firstModule = key($modules);
104
-        }
92
+	/**
93
+	 * Fetch the module given a pid.
94
+	 *
95
+	 * @param int $pid
96
+	 * @return string
97
+	 */
98
+	public function getFirstModuleForPid($pid): string
99
+	{
100
+		$firstModule = '';
101
+		$modules = $this->getModulesForPid($pid);
102
+		if (!empty($modules)) {
103
+			$firstModule = key($modules);
104
+		}
105 105
 
106
-        return $firstModule;
107
-    }
106
+		return $firstModule;
107
+	}
108 108
 
109
-    /**
110
-     * @return object|DataService
111
-     */
112
-    protected function getDataService(): DataService
113
-    {
114
-        return GeneralUtility::makeInstance(DataService::class);
115
-    }
109
+	/**
110
+	 * @return object|DataService
111
+	 */
112
+	protected function getDataService(): DataService
113
+	{
114
+		return GeneralUtility::makeInstance(DataService::class);
115
+	}
116 116
 
117
-    /**
118
-     * Get the Vidi Module Loader.
119
-     *
120
-     * @return ModuleLoader|object
121
-     */
122
-    protected function getModuleLoader()
123
-    {
124
-        return GeneralUtility::makeInstance(ModuleLoader::class);
125
-    }
117
+	/**
118
+	 * Get the Vidi Module Loader.
119
+	 *
120
+	 * @return ModuleLoader|object
121
+	 */
122
+	protected function getModuleLoader()
123
+	{
124
+		return GeneralUtility::makeInstance(ModuleLoader::class);
125
+	}
126 126
 }
Please login to merge, or discard this patch.
Classes/Module/ModulePidService.php 1 patch
Indentation   +207 added lines, -207 removed lines patch added patch discarded remove patch
@@ -20,212 +20,212 @@
 block discarded – undo
20 20
  */
21 21
 class ModulePidService
22 22
 {
23
-    /**
24
-     * The data type (table)
25
-     *
26
-     * @var string
27
-     */
28
-    protected $dataType = '';
29
-
30
-    /**
31
-     * A collection of speaking error messages why the pid is invalid.
32
-     *
33
-     * @var array
34
-     */
35
-    protected $errors = [];
36
-
37
-    /**
38
-     * ModulePidService constructor.
39
-     */
40
-    public function __construct()
41
-    {
42
-        $this->dataType = $this->getModuleLoader()->getDataType();
43
-    }
44
-
45
-    /**
46
-     * Returns a class instance
47
-     *
48
-     * @return \Fab\Vidi\Module\ModulePidService|object
49
-     */
50
-    static public function getInstance()
51
-    {
52
-        return GeneralUtility::makeInstance(self::class);
53
-    }
54
-
55
-    /**
56
-     * @return bool
57
-     */
58
-    public function isConfiguredPidValid(): bool
59
-    {
60
-        $errors = $this->validateConfiguredPid();
61
-        return empty($errors);
62
-    }
63
-
64
-    /**
65
-     * @return array
66
-     */
67
-    public function validateConfiguredPid(): array
68
-    {
69
-        $configuredPid = $this->getConfiguredNewRecordPid();
70
-        $this->validateRootLevel($configuredPid);
71
-        $this->validatePageExist($configuredPid);
72
-        $this->validateDoktype($configuredPid);
73
-        return $this->errors;
74
-    }
75
-
76
-    /**
77
-     * Return the default configured pid.
78
-     *
79
-     * @return int
80
-     */
81
-    public function getConfiguredNewRecordPid(): int
82
-    {
83
-        if (GeneralUtility::_GP(Parameter::PID)) {
84
-            $configuredPid = (int)GeneralUtility::_GP(Parameter::PID);
85
-        } else {
86
-
87
-            // Get pid from User TSConfig if any.
88
-            $tsConfigPath = sprintf('tx_vidi.dataType.%s.storagePid', $this->dataType);
89
-            $result = $this->getBackendUser()->getTSConfig($tsConfigPath);
90
-            $configuredPid = isset($result['value'])
91
-                ? $configuredPid = (int)$result['value']
92
-                : $this->getModuleLoader()->getDefaultPid();
93
-        }
94
-
95
-        return $configuredPid;
96
-    }
97
-
98
-    /**
99
-     * Check if pid is 0 and given table is allowed on root level.
100
-     *
101
-     * @param int $configuredPid
102
-     * @return void
103
-     */
104
-    protected function validateRootLevel(int $configuredPid): void
105
-    {
106
-        if ($configuredPid > 0) {
107
-            return;
108
-        }
109
-
110
-        $isRootLevel = (bool)Tca::table()->get('rootLevel');
111
-        if (!$isRootLevel) {
112
-            $this->errors[] = sprintf(
113
-                'You are not allowed to use page id "0" unless you set $GLOBALS[\'TCA\'][\'%1$s\'][\'ctrl\'][\'rootLevel\'] = 1;',
114
-                $this->dataType
115
-            );
116
-        }
117
-    }
118
-
119
-    /**
120
-     * Check if a page exists for the configured pid
121
-     *
122
-     * @param int $configuredPid
123
-     * @return void
124
-     */
125
-    protected function validatePageExist(int $configuredPid): void
126
-    {
127
-        if ($configuredPid === 0) {
128
-            return;
129
-        }
130
-
131
-        $page = $this->getPage($configuredPid);
132
-        if (empty($page)) {
133
-            $this->errors[] = sprintf(
134
-                'No page found for the configured page id "%s".',
135
-                $configuredPid
136
-            );
137
-        }
138
-    }
139
-
140
-    /**
141
-     * Check if configured page is a sysfolder and if it is allowed.
142
-     *
143
-     * @param int $configuredPid
144
-     * @return void
145
-     */
146
-    protected function validateDoktype(int $configuredPid): void
147
-    {
148
-        if ($configuredPid === 0) {
149
-            return;
150
-        }
151
-
152
-        $page = $this->getPage($configuredPid);
153
-        if (!empty($page)
154
-            && (int)$page['doktype'] !== PageRepository::DOKTYPE_SYSFOLDER
155
-            && !$this->isTableAllowedOnStandardPages()
156
-            && $this->getModuleLoader()->hasComponentInDocHeader(NewButton::class)) {
157
-            $this->errors[] = sprintf(
158
-                'The page with the id "%s" either has to be of the type "folder" (doktype=254) or the table "%s" has to be allowed on standard pages.',
159
-                $configuredPid,
160
-                $this->dataType
161
-            );
162
-        }
163
-    }
164
-
165
-    /**
166
-     * Check if given table is allowed on standard pages
167
-     *
168
-     * @return bool
169
-     * @see \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::allowTableOnStandardPages()
170
-     */
171
-    protected function isTableAllowedOnStandardPages(): bool
172
-    {
173
-        $allowedTables = explode(',', $GLOBALS['PAGES_TYPES']['default']['allowedTables']);
174
-        return in_array($this->dataType, $allowedTables, true);
175
-    }
176
-
177
-    /**
178
-     * Returns the page record of the configured pid
179
-     *
180
-     * @param int $configuredPid
181
-     * @return array
182
-     */
183
-    protected function getPage(int $configuredPid): ?array
184
-    {
185
-        $query = $this->getQueryBuilder('pages');
186
-        $query->getRestrictions()->removeAll(); // we are in BE context.
187
-
188
-        $page = $query->select('doktype')
189
-            ->from('pages')
190
-            ->where('deleted = 0',
191
-                'uid = ' . $configuredPid)
192
-            ->execute()
193
-            ->fetch();
194
-
195
-        return is_array($page)
196
-            ? $page
197
-            : [];
198
-    }
199
-
200
-    /**
201
-     * @param string $tableName
202
-     * @return object|QueryBuilder
203
-     */
204
-    protected function getQueryBuilder($tableName): QueryBuilder
205
-    {
206
-        /** @var ConnectionPool $connectionPool */
207
-        $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
208
-        return $connectionPool->getQueryBuilderForTable($tableName);
209
-    }
210
-
211
-    /**
212
-     * Returns an instance of the current Backend User.
213
-     *
214
-     * @return BackendUserAuthentication
215
-     */
216
-    protected function getBackendUser()
217
-    {
218
-        return $GLOBALS['BE_USER'];
219
-    }
220
-
221
-    /**
222
-     * Get the Vidi Module Loader.
223
-     *
224
-     * @return ModuleLoader|object
225
-     */
226
-    protected function getModuleLoader()
227
-    {
228
-        return GeneralUtility::makeInstance(ModuleLoader::class);
229
-    }
23
+	/**
24
+	 * The data type (table)
25
+	 *
26
+	 * @var string
27
+	 */
28
+	protected $dataType = '';
29
+
30
+	/**
31
+	 * A collection of speaking error messages why the pid is invalid.
32
+	 *
33
+	 * @var array
34
+	 */
35
+	protected $errors = [];
36
+
37
+	/**
38
+	 * ModulePidService constructor.
39
+	 */
40
+	public function __construct()
41
+	{
42
+		$this->dataType = $this->getModuleLoader()->getDataType();
43
+	}
44
+
45
+	/**
46
+	 * Returns a class instance
47
+	 *
48
+	 * @return \Fab\Vidi\Module\ModulePidService|object
49
+	 */
50
+	static public function getInstance()
51
+	{
52
+		return GeneralUtility::makeInstance(self::class);
53
+	}
54
+
55
+	/**
56
+	 * @return bool
57
+	 */
58
+	public function isConfiguredPidValid(): bool
59
+	{
60
+		$errors = $this->validateConfiguredPid();
61
+		return empty($errors);
62
+	}
63
+
64
+	/**
65
+	 * @return array
66
+	 */
67
+	public function validateConfiguredPid(): array
68
+	{
69
+		$configuredPid = $this->getConfiguredNewRecordPid();
70
+		$this->validateRootLevel($configuredPid);
71
+		$this->validatePageExist($configuredPid);
72
+		$this->validateDoktype($configuredPid);
73
+		return $this->errors;
74
+	}
75
+
76
+	/**
77
+	 * Return the default configured pid.
78
+	 *
79
+	 * @return int
80
+	 */
81
+	public function getConfiguredNewRecordPid(): int
82
+	{
83
+		if (GeneralUtility::_GP(Parameter::PID)) {
84
+			$configuredPid = (int)GeneralUtility::_GP(Parameter::PID);
85
+		} else {
86
+
87
+			// Get pid from User TSConfig if any.
88
+			$tsConfigPath = sprintf('tx_vidi.dataType.%s.storagePid', $this->dataType);
89
+			$result = $this->getBackendUser()->getTSConfig($tsConfigPath);
90
+			$configuredPid = isset($result['value'])
91
+				? $configuredPid = (int)$result['value']
92
+				: $this->getModuleLoader()->getDefaultPid();
93
+		}
94
+
95
+		return $configuredPid;
96
+	}
97
+
98
+	/**
99
+	 * Check if pid is 0 and given table is allowed on root level.
100
+	 *
101
+	 * @param int $configuredPid
102
+	 * @return void
103
+	 */
104
+	protected function validateRootLevel(int $configuredPid): void
105
+	{
106
+		if ($configuredPid > 0) {
107
+			return;
108
+		}
109
+
110
+		$isRootLevel = (bool)Tca::table()->get('rootLevel');
111
+		if (!$isRootLevel) {
112
+			$this->errors[] = sprintf(
113
+				'You are not allowed to use page id "0" unless you set $GLOBALS[\'TCA\'][\'%1$s\'][\'ctrl\'][\'rootLevel\'] = 1;',
114
+				$this->dataType
115
+			);
116
+		}
117
+	}
118
+
119
+	/**
120
+	 * Check if a page exists for the configured pid
121
+	 *
122
+	 * @param int $configuredPid
123
+	 * @return void
124
+	 */
125
+	protected function validatePageExist(int $configuredPid): void
126
+	{
127
+		if ($configuredPid === 0) {
128
+			return;
129
+		}
130
+
131
+		$page = $this->getPage($configuredPid);
132
+		if (empty($page)) {
133
+			$this->errors[] = sprintf(
134
+				'No page found for the configured page id "%s".',
135
+				$configuredPid
136
+			);
137
+		}
138
+	}
139
+
140
+	/**
141
+	 * Check if configured page is a sysfolder and if it is allowed.
142
+	 *
143
+	 * @param int $configuredPid
144
+	 * @return void
145
+	 */
146
+	protected function validateDoktype(int $configuredPid): void
147
+	{
148
+		if ($configuredPid === 0) {
149
+			return;
150
+		}
151
+
152
+		$page = $this->getPage($configuredPid);
153
+		if (!empty($page)
154
+			&& (int)$page['doktype'] !== PageRepository::DOKTYPE_SYSFOLDER
155
+			&& !$this->isTableAllowedOnStandardPages()
156
+			&& $this->getModuleLoader()->hasComponentInDocHeader(NewButton::class)) {
157
+			$this->errors[] = sprintf(
158
+				'The page with the id "%s" either has to be of the type "folder" (doktype=254) or the table "%s" has to be allowed on standard pages.',
159
+				$configuredPid,
160
+				$this->dataType
161
+			);
162
+		}
163
+	}
164
+
165
+	/**
166
+	 * Check if given table is allowed on standard pages
167
+	 *
168
+	 * @return bool
169
+	 * @see \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::allowTableOnStandardPages()
170
+	 */
171
+	protected function isTableAllowedOnStandardPages(): bool
172
+	{
173
+		$allowedTables = explode(',', $GLOBALS['PAGES_TYPES']['default']['allowedTables']);
174
+		return in_array($this->dataType, $allowedTables, true);
175
+	}
176
+
177
+	/**
178
+	 * Returns the page record of the configured pid
179
+	 *
180
+	 * @param int $configuredPid
181
+	 * @return array
182
+	 */
183
+	protected function getPage(int $configuredPid): ?array
184
+	{
185
+		$query = $this->getQueryBuilder('pages');
186
+		$query->getRestrictions()->removeAll(); // we are in BE context.
187
+
188
+		$page = $query->select('doktype')
189
+			->from('pages')
190
+			->where('deleted = 0',
191
+				'uid = ' . $configuredPid)
192
+			->execute()
193
+			->fetch();
194
+
195
+		return is_array($page)
196
+			? $page
197
+			: [];
198
+	}
199
+
200
+	/**
201
+	 * @param string $tableName
202
+	 * @return object|QueryBuilder
203
+	 */
204
+	protected function getQueryBuilder($tableName): QueryBuilder
205
+	{
206
+		/** @var ConnectionPool $connectionPool */
207
+		$connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
208
+		return $connectionPool->getQueryBuilderForTable($tableName);
209
+	}
210
+
211
+	/**
212
+	 * Returns an instance of the current Backend User.
213
+	 *
214
+	 * @return BackendUserAuthentication
215
+	 */
216
+	protected function getBackendUser()
217
+	{
218
+		return $GLOBALS['BE_USER'];
219
+	}
220
+
221
+	/**
222
+	 * Get the Vidi Module Loader.
223
+	 *
224
+	 * @return ModuleLoader|object
225
+	 */
226
+	protected function getModuleLoader()
227
+	{
228
+		return GeneralUtility::makeInstance(ModuleLoader::class);
229
+	}
230 230
 
231 231
 }
Please login to merge, or discard this patch.
Classes/Module/ModulePreferences.php 1 patch
Indentation   +216 added lines, -216 removed lines patch added patch discarded remove patch
@@ -19,221 +19,221 @@
 block discarded – undo
19 19
 class ModulePreferences implements SingletonInterface
20 20
 {
21 21
 
22
-    /**
23
-     * @var array
24
-     */
25
-    protected $preferences;
26
-
27
-    /**
28
-     * @var string
29
-     */
30
-    protected $tableName = 'tx_vidi_preference';
31
-
32
-    /**
33
-     * @param string $key
34
-     * @param string $dataType
35
-     * @return mixed
36
-     */
37
-    public function get($key, $dataType = '')
38
-    {
39
-
40
-        if (empty($dataType)) {
41
-            $dataType = $this->getModuleLoader()->getDataType();
42
-        }
43
-
44
-        if (!$this->isLoaded($dataType)) {
45
-            $this->load($dataType);
46
-        }
47
-
48
-        $value = empty($this->preferences[$dataType][$key]) ? null : $this->preferences[$dataType][$key];
49
-        return $value;
50
-    }
51
-
52
-    /**
53
-     * Tell whether the module is loaded.
54
-     *
55
-     * @param string $dataType
56
-     * @return bool
57
-     */
58
-    public function isLoaded($dataType)
59
-    {
60
-        return !empty($this->preferences[$dataType]);
61
-    }
62
-
63
-    /**
64
-     * @param string $dataType
65
-     * @return array
66
-     */
67
-    public function getAll($dataType = '')
68
-    {
69
-
70
-        if (empty($dataType)) {
71
-            $dataType = $this->getModuleLoader()->getDataType();
72
-        }
73
-        $this->load($dataType);
74
-        return $this->preferences[$dataType];
75
-    }
76
-
77
-    /**
78
-     * Get the md5 signature of the preferences.
79
-     *
80
-     * @param string $dataType
81
-     * @return bool
82
-     */
83
-    public function getSignature($dataType = '')
84
-    {
85
-        $preferences = $this->getAll($dataType);
86
-        return md5(serialize($preferences));
87
-    }
88
-
89
-    /**
90
-     * Load preferences.
91
-     *
92
-     * @param string $dataType
93
-     * @return void
94
-     */
95
-    public function load($dataType)
96
-    {
97
-
98
-        // Fetch preferences from different sources and overlay them
99
-        $databasePreferences = $this->fetchPreferencesFromDatabase($dataType);
100
-        $generalPreferences = $this->fetchGlobalPreferencesFromTypoScript();
101
-        $specificPreferences = $this->fetchExtraPreferencesFromTypoScript($dataType);
102
-
103
-        $preferences = array_merge($generalPreferences, $specificPreferences, $databasePreferences);
104
-        $this->preferences[$dataType] = $preferences;
105
-    }
106
-
107
-    /**
108
-     * Save preferences
109
-     *
110
-     * @param array $preferences
111
-     * @return void
112
-     */
113
-    public function save($preferences)
114
-    {
115
-        $configurableParts = ConfigurablePart::getParts();
116
-
117
-        $dataType = $this->getModuleLoader()->getDataType();
118
-        $this->getDataService()->delete(
119
-            $this->tableName,
120
-            [
121
-                'data_type' => $dataType
122
-            ]
123
-        );
124
-
125
-        $sanitizedPreferences = [];
126
-        foreach ($preferences as $key => $value) {
127
-            if (in_array($key, $configurableParts)) {
128
-                $sanitizedPreferences[$key] = $value;
129
-            }
130
-        }
131
-
132
-        $this->getDataService()->insert(
133
-            $this->tableName,
134
-            [
135
-                'data_type' => $dataType,
136
-                'preferences' => serialize($sanitizedPreferences),
137
-            ]
138
-        );
139
-    }
140
-
141
-    /**
142
-     * @param $dataType
143
-     * @return array
144
-     */
145
-    public function fetchPreferencesFromDatabase($dataType)
146
-    {
147
-        $preferences = [];
148
-        $record = $this->getDataService()->getRecord(
149
-            $this->tableName,
150
-            [
151
-                'data_type' => $dataType
152
-            ]
153
-        );
154
-
155
-        if (!empty($record)) {
156
-            $preferences = unserialize($record['preferences']);
157
-        }
158
-
159
-        return $preferences;
160
-    }
161
-
162
-    /**
163
-     * Returns the module settings.
164
-     *
165
-     * @return array
166
-     */
167
-    protected function fetchGlobalPreferencesFromTypoScript()
168
-    {
169
-        $settings = $this->getSettings();
170
-
171
-        $configurableParts = ConfigurablePart::getParts();
172
-        $preferences = [];
173
-        foreach ($settings as $key => $value) {
174
-            if (in_array($key, $configurableParts)) {
175
-                $preferences[$key] = $value;
176
-            }
177
-        }
178
-
179
-        return $preferences;
180
-    }
181
-
182
-    /**
183
-     * Returns the module settings.
184
-     *
185
-     * @param string $dataType
186
-     * @return array
187
-     */
188
-    protected function fetchExtraPreferencesFromTypoScript($dataType)
189
-    {
190
-        $generalSettings = $this->getSettings();
191
-
192
-        $preferences = [];
193
-        if (isset($generalSettings[$dataType . '.'])) {
194
-            $settings = $generalSettings[$dataType . '.'];
195
-
196
-            $configurableParts = ConfigurablePart::getParts();
197
-            foreach ($settings as $key => $value) {
198
-                if (in_array($key, $configurableParts)) {
199
-                    $preferences[$key] = $value;
200
-                }
201
-            }
202
-        }
203
-
204
-        return $preferences;
205
-    }
206
-
207
-    /**
208
-     * Returns the module settings.
209
-     *
210
-     * @return array
211
-     */
212
-    protected function getSettings()
213
-    {
214
-        /** @var BackendConfigurationManager $backendConfigurationManager */
215
-        $objectManager = GeneralUtility::makeInstance(ObjectManager::class);
216
-        $backendConfigurationManager = $objectManager->get(BackendConfigurationManager::class);
217
-        $configuration = $backendConfigurationManager->getTypoScriptSetup();
218
-        return $configuration['module.']['tx_vidi.']['settings.'];
219
-    }
220
-
221
-    /**
222
-     * @return object|DataService
223
-     */
224
-    protected function getDataService(): DataService
225
-    {
226
-        return GeneralUtility::makeInstance(DataService::class);
227
-    }
228
-
229
-    /**
230
-     * Get the Vidi Module Loader.
231
-     *
232
-     * @return ModuleLoader|object
233
-     */
234
-    protected function getModuleLoader()
235
-    {
236
-        return GeneralUtility::makeInstance(ModuleLoader::class);
237
-    }
22
+	/**
23
+	 * @var array
24
+	 */
25
+	protected $preferences;
26
+
27
+	/**
28
+	 * @var string
29
+	 */
30
+	protected $tableName = 'tx_vidi_preference';
31
+
32
+	/**
33
+	 * @param string $key
34
+	 * @param string $dataType
35
+	 * @return mixed
36
+	 */
37
+	public function get($key, $dataType = '')
38
+	{
39
+
40
+		if (empty($dataType)) {
41
+			$dataType = $this->getModuleLoader()->getDataType();
42
+		}
43
+
44
+		if (!$this->isLoaded($dataType)) {
45
+			$this->load($dataType);
46
+		}
47
+
48
+		$value = empty($this->preferences[$dataType][$key]) ? null : $this->preferences[$dataType][$key];
49
+		return $value;
50
+	}
51
+
52
+	/**
53
+	 * Tell whether the module is loaded.
54
+	 *
55
+	 * @param string $dataType
56
+	 * @return bool
57
+	 */
58
+	public function isLoaded($dataType)
59
+	{
60
+		return !empty($this->preferences[$dataType]);
61
+	}
62
+
63
+	/**
64
+	 * @param string $dataType
65
+	 * @return array
66
+	 */
67
+	public function getAll($dataType = '')
68
+	{
69
+
70
+		if (empty($dataType)) {
71
+			$dataType = $this->getModuleLoader()->getDataType();
72
+		}
73
+		$this->load($dataType);
74
+		return $this->preferences[$dataType];
75
+	}
76
+
77
+	/**
78
+	 * Get the md5 signature of the preferences.
79
+	 *
80
+	 * @param string $dataType
81
+	 * @return bool
82
+	 */
83
+	public function getSignature($dataType = '')
84
+	{
85
+		$preferences = $this->getAll($dataType);
86
+		return md5(serialize($preferences));
87
+	}
88
+
89
+	/**
90
+	 * Load preferences.
91
+	 *
92
+	 * @param string $dataType
93
+	 * @return void
94
+	 */
95
+	public function load($dataType)
96
+	{
97
+
98
+		// Fetch preferences from different sources and overlay them
99
+		$databasePreferences = $this->fetchPreferencesFromDatabase($dataType);
100
+		$generalPreferences = $this->fetchGlobalPreferencesFromTypoScript();
101
+		$specificPreferences = $this->fetchExtraPreferencesFromTypoScript($dataType);
102
+
103
+		$preferences = array_merge($generalPreferences, $specificPreferences, $databasePreferences);
104
+		$this->preferences[$dataType] = $preferences;
105
+	}
106
+
107
+	/**
108
+	 * Save preferences
109
+	 *
110
+	 * @param array $preferences
111
+	 * @return void
112
+	 */
113
+	public function save($preferences)
114
+	{
115
+		$configurableParts = ConfigurablePart::getParts();
116
+
117
+		$dataType = $this->getModuleLoader()->getDataType();
118
+		$this->getDataService()->delete(
119
+			$this->tableName,
120
+			[
121
+				'data_type' => $dataType
122
+			]
123
+		);
124
+
125
+		$sanitizedPreferences = [];
126
+		foreach ($preferences as $key => $value) {
127
+			if (in_array($key, $configurableParts)) {
128
+				$sanitizedPreferences[$key] = $value;
129
+			}
130
+		}
131
+
132
+		$this->getDataService()->insert(
133
+			$this->tableName,
134
+			[
135
+				'data_type' => $dataType,
136
+				'preferences' => serialize($sanitizedPreferences),
137
+			]
138
+		);
139
+	}
140
+
141
+	/**
142
+	 * @param $dataType
143
+	 * @return array
144
+	 */
145
+	public function fetchPreferencesFromDatabase($dataType)
146
+	{
147
+		$preferences = [];
148
+		$record = $this->getDataService()->getRecord(
149
+			$this->tableName,
150
+			[
151
+				'data_type' => $dataType
152
+			]
153
+		);
154
+
155
+		if (!empty($record)) {
156
+			$preferences = unserialize($record['preferences']);
157
+		}
158
+
159
+		return $preferences;
160
+	}
161
+
162
+	/**
163
+	 * Returns the module settings.
164
+	 *
165
+	 * @return array
166
+	 */
167
+	protected function fetchGlobalPreferencesFromTypoScript()
168
+	{
169
+		$settings = $this->getSettings();
170
+
171
+		$configurableParts = ConfigurablePart::getParts();
172
+		$preferences = [];
173
+		foreach ($settings as $key => $value) {
174
+			if (in_array($key, $configurableParts)) {
175
+				$preferences[$key] = $value;
176
+			}
177
+		}
178
+
179
+		return $preferences;
180
+	}
181
+
182
+	/**
183
+	 * Returns the module settings.
184
+	 *
185
+	 * @param string $dataType
186
+	 * @return array
187
+	 */
188
+	protected function fetchExtraPreferencesFromTypoScript($dataType)
189
+	{
190
+		$generalSettings = $this->getSettings();
191
+
192
+		$preferences = [];
193
+		if (isset($generalSettings[$dataType . '.'])) {
194
+			$settings = $generalSettings[$dataType . '.'];
195
+
196
+			$configurableParts = ConfigurablePart::getParts();
197
+			foreach ($settings as $key => $value) {
198
+				if (in_array($key, $configurableParts)) {
199
+					$preferences[$key] = $value;
200
+				}
201
+			}
202
+		}
203
+
204
+		return $preferences;
205
+	}
206
+
207
+	/**
208
+	 * Returns the module settings.
209
+	 *
210
+	 * @return array
211
+	 */
212
+	protected function getSettings()
213
+	{
214
+		/** @var BackendConfigurationManager $backendConfigurationManager */
215
+		$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
216
+		$backendConfigurationManager = $objectManager->get(BackendConfigurationManager::class);
217
+		$configuration = $backendConfigurationManager->getTypoScriptSetup();
218
+		return $configuration['module.']['tx_vidi.']['settings.'];
219
+	}
220
+
221
+	/**
222
+	 * @return object|DataService
223
+	 */
224
+	protected function getDataService(): DataService
225
+	{
226
+		return GeneralUtility::makeInstance(DataService::class);
227
+	}
228
+
229
+	/**
230
+	 * Get the Vidi Module Loader.
231
+	 *
232
+	 * @return ModuleLoader|object
233
+	 */
234
+	protected function getModuleLoader()
235
+	{
236
+		return GeneralUtility::makeInstance(ModuleLoader::class);
237
+	}
238 238
 
239 239
 }
Please login to merge, or discard this patch.
Classes/Module/ModuleLoader.php 2 patches
Indentation   +999 added lines, -999 removed lines patch added patch discarded remove patch
@@ -37,1004 +37,1004 @@
 block discarded – undo
37 37
 class ModuleLoader
38 38
 {
39 39
 
40
-    /**
41
-     * Define the default main module
42
-     */
43
-    const DEFAULT_MAIN_MODULE = 'content';
44
-
45
-    /**
46
-     * Define the default pid
47
-     */
48
-    const DEFAULT_PID = 0;
49
-
50
-    /**
51
-     * The type of data being listed (which corresponds to a table name in TCA)
52
-     *
53
-     * @var string
54
-     */
55
-    protected $dataType;
56
-
57
-    /**
58
-     * @var string
59
-     */
60
-    protected $defaultPid;
61
-
62
-    /**
63
-     * @var bool
64
-     */
65
-    protected $isPidIgnored = false;
66
-
67
-    /**
68
-     * @var bool
69
-     */
70
-    protected $showPageTree = false;
71
-
72
-    /**
73
-     * @var bool
74
-     */
75
-    protected $isShown = true;
76
-
77
-    /**
78
-     * @var string
79
-     */
80
-    protected $access;
81
-
82
-    /**
83
-     * @var string
84
-     */
85
-    protected $mainModule;
86
-
87
-    /**
88
-     * @var string
89
-     */
90
-    protected $position = '';
91
-
92
-    /**
93
-     * @var string
94
-     */
95
-    protected $icon;
96
-
97
-    /**
98
-     * @var string
99
-     */
100
-    protected $moduleLanguageFile;
101
-
102
-    /**
103
-     * The module key such as m1, m2.
104
-     *
105
-     * @var string
106
-     */
107
-    protected $moduleKey = 'm1';
108
-
109
-    /**
110
-     * @var string[]
111
-     */
112
-    protected $additionalJavaScriptFiles = [];
113
-
114
-    /**
115
-     * @var string[]
116
-     */
117
-    protected $additionalStyleSheetFiles = [];
118
-
119
-    /**
120
-     * @var array
121
-     */
122
-    protected $components = [];
123
-
124
-    /**
125
-     * @param string $dataType
126
-     */
127
-    public function __construct($dataType = null)
128
-    {
129
-        $this->dataType = $dataType;
130
-
131
-        // Initialize components
132
-        $this->components = [
133
-            ModulePosition::DOC_HEADER => [
134
-                ModulePosition::TOP => [
135
-                    ModulePosition::LEFT => [],
136
-                    ModulePosition::RIGHT => [
137
-                        ToolButton::class,
138
-                    ],
139
-                ],
140
-                ModulePosition::BOTTOM => [
141
-                    ModulePosition::LEFT => [
142
-                        NewButton::class,
143
-                        BackViewHelper::class,
144
-                    ],
145
-                    ModulePosition::RIGHT => [],
146
-                ],
147
-            ],
148
-            ModulePosition::GRID => [
149
-                ModulePosition::TOP => [
150
-                    RelationsCheck::class,
151
-                    #\Fab\Vidi\View\Tab\DataTypeTab::class,
152
-                ],
153
-                ModulePosition::BUTTONS => [
154
-                    EditButton::class,
155
-                    DeleteButton::class,
156
-                ],
157
-                ModulePosition::BOTTOM => [],
158
-            ],
159
-            ModulePosition::MENU_MASS_ACTION => [
160
-                ExportXlsMenuItem::class,
161
-                ExportXmlMenuItem::class,
162
-                ExportCsvMenuItem::class,
163
-                DividerMenuItem::class,
164
-                MassDeleteMenuItem::class,
165
-                #\Fab\Vidi\View\MenuItem\MassEditMenuItem::class,
166
-            ],
167
-        ];
168
-    }
169
-
170
-    /**
171
-     * Tell whether a module is already registered.
172
-     *
173
-     * @param string $dataType
174
-     * @return bool
175
-     */
176
-    public function isRegistered($dataType): bool
177
-    {
178
-        $internalModuleSignature = $this->getInternalModuleSignature($dataType);
179
-        return !empty($GLOBALS['TBE_MODULES_EXT']['vidi'][$internalModuleSignature]);
180
-    }
181
-
182
-    /**
183
-     * @return array
184
-     */
185
-    protected function getExistingInternalConfiguration(): array
186
-    {
187
-        $internalModuleSignature = $this->getInternalModuleSignature();
188
-        return $GLOBALS['TBE_MODULES_EXT']['vidi'][$internalModuleSignature] ?? [];
189
-    }
190
-
191
-    /**
192
-     * @return array
193
-     */
194
-    protected function getExistingMainConfiguration(): array
195
-    {
196
-        $moduleSignature = $this->computeMainModule() . '_' . $this->getInternalModuleSignature();
197
-        return $GLOBALS['TBE_MODULES']['_configuration'][$moduleSignature] ?? [];
198
-    }
199
-
200
-    /**
201
-     * @return string
202
-     */
203
-    protected function computeMainModule(): string
204
-    {
205
-        $existingConfiguration = $this->getExistingInternalConfiguration();
206
-
207
-        if ($this->mainModule !== null) {
208
-            $mainModule = $this->mainModule;
209
-        } elseif (!empty($existingConfiguration['mainModule'])) { // existing configuration may override.
210
-            $mainModule = $existingConfiguration['mainModule'];
211
-        } else {
212
-            $mainModule = self::DEFAULT_MAIN_MODULE; //default value.
213
-        }
214
-        return $mainModule;
215
-    }
216
-
217
-    /**
218
-     * @return string
219
-     */
220
-    protected function computeDefaultPid(): string
221
-    {
222
-        $existingConfiguration = $this->getExistingInternalConfiguration();
223
-
224
-        if ($this->defaultPid !== null) {
225
-            $defaultPid = $this->defaultPid;
226
-        } elseif (!empty($existingConfiguration['defaultPid'])) { // existing configuration may override.
227
-            $defaultPid = $existingConfiguration['defaultPid'];
228
-        } else {
229
-            $defaultPid = self::DEFAULT_PID; //default value.
230
-        }
231
-        return $defaultPid;
232
-    }
233
-
234
-    /**
235
-     * @return array
236
-     */
237
-    protected function computeAdditionalJavaScriptFiles(): array
238
-    {
239
-        $additionalJavaScriptFiles = $this->additionalJavaScriptFiles;
240
-
241
-        // Possible merge of existing javascript files.
242
-        $existingConfiguration = $this->getExistingInternalConfiguration();
243
-        if (!empty($existingConfiguration['additionalJavaScriptFiles'])) {
244
-            $additionalJavaScriptFiles = array_merge($additionalJavaScriptFiles, $existingConfiguration['additionalJavaScriptFiles']);
245
-        }
246
-
247
-        return $additionalJavaScriptFiles;
248
-    }
249
-
250
-    /**
251
-     * @return array
252
-     */
253
-    protected function computeAdditionalStyleSheetFiles(): array
254
-    {
255
-        $additionalStyleSheetFiles = $this->additionalStyleSheetFiles;
256
-
257
-        // Possible merge of existing style sheets.
258
-        $existingConfiguration = $this->getExistingInternalConfiguration();
259
-        if (!empty($existingConfiguration['additionalStyleSheetFiles'])) {
260
-            $additionalStyleSheetFiles = array_merge($additionalStyleSheetFiles, $existingConfiguration['additionalStyleSheetFiles']);
261
-        }
262
-
263
-        return $additionalStyleSheetFiles;
264
-    }
265
-
266
-    /**
267
-     * @return array
268
-     */
269
-    protected function computeComponents(): array
270
-    {
271
-        // We override the config in any case. See if we need more than that.
272
-        return $this->components;
273
-    }
274
-
275
-    /**
276
-     * Register the module in two places: core + vidi internal.
277
-     *
278
-     * @return $this
279
-     */
280
-    public function register(): self
281
-    {
282
-        // Internal Vidi module registration.
283
-        $configuration = [];
284
-        $configuration['dataType'] = $this->dataType;
285
-        $configuration['mainModule'] = $this->computeMainModule();
286
-        $configuration['defaultPid'] = $this->computeDefaultPid();
287
-        $configuration['additionalJavaScriptFiles'] = $this->computeAdditionalJavaScriptFiles();
288
-        $configuration['additionalStyleSheetFiles'] = $this->computeAdditionalStyleSheetFiles();
289
-        $configuration['components'] = $this->computeComponents();
290
-        $configuration['isPidIgnored'] = $this->isPidIgnored;
291
-
292
-        $internalModuleSignature = $this->getInternalModuleSignature();
293
-        $GLOBALS['TBE_MODULES_EXT']['vidi'][$internalModuleSignature] = $configuration;
294
-
295
-        // Core module registration.
296
-        // Register and displays module in the BE only if told, default is "true".
297
-        if ($this->isShown) {
298
-
299
-            $moduleConfiguration = [];
300
-            #$moduleConfiguration['routeTarget'] = \Fab\Vidi\Controller\ContentController::class . '::mainAction', // what to do here?
301
-            $moduleConfiguration['access'] = $this->getAccess();
302
-            $moduleConfiguration['labels'] = $this->getModuleLanguageFile();
303
-            $icon = $this->getIcon();
304
-            if ($icon) {
305
-                $moduleConfiguration['icon'] = $icon;
306
-            }
307
-
308
-            if ($this->showPageTree) {
309
-                $moduleConfiguration['navigationComponentId'] = 'TYPO3/CMS/Backend/PageTree/PageTreeElement';
310
-                $moduleConfiguration['inheritNavigationComponentFromMainModule'] = true;
311
-            } else {
312
-                $moduleConfiguration['inheritNavigationComponentFromMainModule'] = true;
313
-            }
314
-
315
-            ExtensionUtility::registerModule(
316
-                'Fab.vidi',
317
-                $this->computeMainModule(),
318
-                $this->dataType . '_' . $this->moduleKey,
319
-                $this->position,
320
-                [
321
-                    ContentController::class => 'index, list, delete, update, edit, copy, move, localize, sort, copyClipboard, moveClipboard',
322
-                    ToolController::class => 'welcome, work',
323
-                    FacetController::class => 'autoSuggest, autoSuggests',
324
-                    SelectionController::class => 'edit, update, create, delete, list, show',
325
-                    UserPreferencesController::class => 'save',
326
-                    ClipboardController::class => 'save, flush, show',
327
-                ],
328
-                $moduleConfiguration
329
-            );
330
-        }
331
-        return $this;
332
-    }
333
-
334
-    /**
335
-     * Return the module code for a BE module.
336
-     *
337
-     * @return string
338
-     */
339
-    public function getSignature(): string
340
-    {
341
-        $signature = GeneralUtility::_GP(Parameter::MODULE);
342
-        $trimmedSignature = trim($signature, '/');
343
-        return str_replace(['/', 'module_'], ['_', ''], $trimmedSignature);
344
-    }
345
-
346
-    /**
347
-     * Returns the current pid.
348
-     *
349
-     * @return int
350
-     */
351
-    public function getCurrentPid(): int
352
-    {
353
-        return GeneralUtility::_GET(Parameter::PID) > 0 ? (int)GeneralUtility::_GET(Parameter::PID) : 0;
354
-    }
355
-
356
-    /**
357
-     * Return the module URL.
358
-     *
359
-     * @param array $additionalParameters
360
-     * @return string
361
-     */
362
-    public function getModuleUrl(array $additionalParameters = []): string
363
-    {
364
-        $moduleCode = $this->getSignature();
365
-
366
-        // And don't forget the pid!
367
-        if (GeneralUtility::_GET(Parameter::PID)) {
368
-            $additionalParameters[Parameter::PID] = GeneralUtility::_GET(Parameter::PID);
369
-        }
370
-
371
-        return BackendUtility::getModuleUrl($moduleCode, $additionalParameters);
372
-    }
373
-
374
-    /**
375
-     * Return the parameter prefix for a BE module.
376
-     *
377
-     * @return string
378
-     */
379
-    public function getParameterPrefix(): string
380
-    {
381
-        return 'tx_vidi_' . strtolower($this->getSignature());
382
-    }
383
-
384
-    /**
385
-     * Return a configuration key or the entire module configuration array if not key is given.
386
-     *
387
-     * @param string $key
388
-     * @return mixed
389
-     */
390
-    public function getModuleConfiguration($key = '')
391
-    {
392
-
393
-        $vidiModuleCode = $this->getSignature();
394
-
395
-        // Module code must exist
396
-        if (empty($GLOBALS['TBE_MODULES_EXT']['vidi'][$vidiModuleCode])) {
397
-            $message = sprintf('Invalid or not existing module code "%s"', $vidiModuleCode);
398
-            throw new InvalidKeyInArrayException($message, 1375092053);
399
-        }
400
-
401
-        $result = $GLOBALS['TBE_MODULES_EXT']['vidi'][$vidiModuleCode];
402
-
403
-        if (!empty($key)) {
404
-            if (isset($result[$key])) {
405
-                $result = $result[$key];
406
-            } else {
407
-                // key must exist
408
-                $message = sprintf('Invalid key configuration "%s"', $key);
409
-                throw new InvalidKeyInArrayException($message, 1375092054);
410
-            }
411
-        }
412
-        return $result;
413
-    }
414
-
415
-    /**
416
-     * @param string $icon
417
-     * @return $this
418
-     */
419
-    public function setIcon($icon): self
420
-    {
421
-        $this->icon = $icon;
422
-        return $this;
423
-    }
424
-
425
-    /**
426
-     * @return string
427
-     */
428
-    protected function getIcon(): string
429
-    {
430
-        $moduleConfiguration = $this->getExistingMainConfiguration();
431
-
432
-
433
-        if ($this->icon) {
434
-            $icon = $this->icon;
435
-        } elseif ($moduleConfiguration['icon']) { // existing configuration may override.
436
-            $icon = $moduleConfiguration['icon'];
437
-        } else {
438
-            $icon = ''; //default value.
439
-        }
440
-
441
-        return $icon;
442
-    }
443
-
444
-    /**
445
-     * @param string $mainModule
446
-     * @return $this
447
-     */
448
-    public function setMainModule($mainModule): self
449
-    {
450
-        $this->mainModule = $mainModule;
451
-        return $this;
452
-    }
453
-
454
-    /**
455
-     * @return string
456
-     */
457
-    public function getMainModule(): string
458
-    {
459
-        if ($this->mainModule === null) {
460
-            $this->mainModule = $this->getModuleConfiguration('mainModule');
461
-        }
462
-        return $this->mainModule;
463
-    }
464
-
465
-    /**
466
-     * @param string $moduleLanguageFile
467
-     * @return $this
468
-     */
469
-    public function setModuleLanguageFile($moduleLanguageFile): self
470
-    {
471
-        $this->moduleLanguageFile = $moduleLanguageFile;
472
-        return $this;
473
-    }
474
-
475
-    /**
476
-     * @param string $component
477
-     * @return $this
478
-     */
479
-    public function removeComponentFromDocHeader(string $component): self
480
-    {
481
-        foreach ($this->components[ModulePosition::DOC_HEADER] as $verticalPosition => $docHeaders) {
482
-            foreach ($docHeaders as $horizontalPosition => $docHeader) {
483
-
484
-                $index = array_search($component, $docHeader, true);
485
-                if ($index !== false) {
486
-                    // $verticalPosition: top or bottom
487
-                    // $horizontalPosition: left or right
488
-                    unset($this->components[ModulePosition::DOC_HEADER][$verticalPosition][$horizontalPosition][$index]);
489
-                }
490
-            }
491
-        }
492
-        return $this;
493
-    }
494
-
495
-    /**
496
-     * @param bool $isPidIgnored
497
-     * @return $this
498
-     */
499
-    public function ignorePid(bool $isPidIgnored): self
500
-    {
501
-        $this->isPidIgnored = $isPidIgnored;
502
-        return $this;
503
-    }
504
-
505
-    /**
506
-     * @return bool
507
-     */
508
-    public function isPidIgnored(): bool
509
-    {
510
-        return $this->getModuleConfiguration('isPidIgnored');
511
-    }
512
-
513
-    /**
514
-     * @param string $component
515
-     * @return bool
516
-     */
517
-    public function hasComponentInDocHeader(string $component): bool
518
-    {
519
-        foreach ($this->getModuleConfiguration('components')[ModulePosition::DOC_HEADER] as $verticalPosition => $docHeaders) {
520
-            foreach ($docHeaders as $horizontalPosition => $docHeader) {
521
-
522
-                $index = array_search($component, $docHeader, true);
523
-                if ($index !== false) {
524
-                    return true;
525
-                }
526
-            }
527
-        }
528
-        return false;
529
-    }
530
-
531
-    /**
532
-     * @return string
533
-     */
534
-    protected function getModuleLanguageFile(): string
535
-    {
536
-        $moduleConfiguration = $this->getExistingMainConfiguration();
537
-
538
-        if ($this->moduleLanguageFile) {
539
-            $moduleLanguageFile = $this->moduleLanguageFile;
540
-        } elseif ($moduleConfiguration['labels']) { // existing configuration may override.
541
-            $moduleLanguageFile = $moduleConfiguration['labels'];
542
-        } else {
543
-            $moduleLanguageFile = ''; //default value.
544
-        }
545
-
546
-        return $moduleLanguageFile;
547
-    }
548
-
549
-    /**
550
-     * @param string $position
551
-     * @return $this
552
-     */
553
-    public function setPosition($position): self
554
-    {
555
-        $this->position = $position;
556
-        return $this;
557
-    }
558
-
559
-    /**
560
-     * @return string
561
-     */
562
-    public function getPosition(): string
563
-    {
564
-        return $this->position;
565
-    }
566
-
567
-    /**
568
-     * @param array $files
569
-     * @return $this
570
-     */
571
-    public function addJavaScriptFiles(array $files): self
572
-    {
573
-        foreach ($files as $file) {
574
-            $this->additionalJavaScriptFiles[] = $file;
575
-        }
576
-        return $this;
577
-    }
578
-
579
-    /**
580
-     * @param string $fileNameAndPath
581
-     * @return $this
582
-     */
583
-    public function addJavaScriptFile($fileNameAndPath): self
584
-    {
585
-        $this->additionalJavaScriptFiles[] = $fileNameAndPath;
586
-        return $this;
587
-    }
588
-
589
-    /**
590
-     * @param array $files
591
-     * @return $this
592
-     */
593
-    public function addStyleSheetFiles(array $files): self
594
-    {
595
-        foreach ($files as $file) {
596
-            $this->additionalStyleSheetFiles[] = $file;
597
-        }
598
-        return $this;
599
-    }
600
-
601
-    /**
602
-     * @param string $fileNameAndPath
603
-     * @return $this
604
-     */
605
-    public function addStyleSheetFile($fileNameAndPath): self
606
-    {
607
-        $this->additionalStyleSheetFiles[] = $fileNameAndPath;
608
-        return $this;
609
-    }
610
-
611
-    /**
612
-     * @return string
613
-     */
614
-    public function getDataType(): string
615
-    {
616
-        if ($this->dataType === null) {
617
-            $this->dataType = $this->getModuleConfiguration('dataType');
618
-        }
619
-        return $this->dataType;
620
-    }
621
-
622
-    /**
623
-     * @return array
624
-     */
625
-    public function getDataTypes(): array
626
-    {
627
-        $dataTypes = [];
628
-        foreach ($GLOBALS['TBE_MODULES_EXT']['vidi'] as $module) {
629
-            $dataTypes[] = $module['dataType'];
630
-        }
631
-        return $dataTypes;
632
-    }
633
-
634
-    /**
635
-     * @param string $dataType
636
-     * @return $this
637
-     */
638
-    public function setDataType($dataType): self
639
-    {
640
-        $this->dataType = $dataType;
641
-        return $this;
642
-    }
643
-
644
-    /**
645
-     * @return int
646
-     */
647
-    public function getDefaultPid(): int
648
-    {
649
-        if (empty($this->defaultPid)) {
650
-            $this->defaultPid = $this->getModuleConfiguration('defaultPid');
651
-        }
652
-        return (int)$this->defaultPid;
653
-    }
654
-
655
-    /**
656
-     * @param string $defaultPid
657
-     * @return $this
658
-     */
659
-    public function setDefaultPid($defaultPid): self
660
-    {
661
-        $this->defaultPid = $defaultPid;
662
-        return $this;
663
-    }
664
-
665
-    /**
666
-     * @param bool $isPageTreeShown
667
-     * @return $this
668
-     */
669
-    public function showPageTree($isPageTreeShown): self
670
-    {
671
-        $this->showPageTree = $isPageTreeShown;
672
-        return $this;
673
-    }
674
-
675
-    /**
676
-     * @param string $isShown
677
-     * @return $this
678
-     */
679
-    public function isShown($isShown): self
680
-    {
681
-        $this->isShown = $isShown;
682
-        return $this;
683
-    }
684
-
685
-    /**
686
-     * @return $array
687
-     */
688
-    public function getDocHeaderTopLeftComponents()
689
-    {
690
-        $configuration = $this->getModuleConfiguration();
691
-        return $configuration['components'][ModulePosition::DOC_HEADER][ModulePosition::TOP][ModulePosition::LEFT];
692
-    }
693
-
694
-    /**
695
-     * @param array $components
696
-     * @return $this
697
-     */
698
-    public function setDocHeaderTopLeftComponents(array $components): self
699
-    {
700
-        $this->components[ModulePosition::DOC_HEADER][ModulePosition::TOP][ModulePosition::LEFT] = $components;
701
-        return $this;
702
-    }
703
-
704
-    /**
705
-     * @param string|array $components
706
-     * @return $this
707
-     */
708
-    public function addDocHeaderTopLeftComponents($components): self
709
-    {
710
-        if (is_string($components)) {
711
-            $components = [$components];
712
-        }
713
-        $currentComponents = $this->components[ModulePosition::DOC_HEADER][ModulePosition::TOP][ModulePosition::LEFT];
714
-        $this->components[ModulePosition::DOC_HEADER][ModulePosition::TOP][ModulePosition::LEFT] = array_merge($currentComponents, $components);
715
-        return $this;
716
-    }
717
-
718
-    /**
719
-     * @return $array
720
-     */
721
-    public function getDocHeaderTopRightComponents()
722
-    {
723
-        $configuration = $this->getModuleConfiguration();
724
-        return $configuration['components'][ModulePosition::DOC_HEADER][ModulePosition::TOP][ModulePosition::RIGHT];
725
-    }
726
-
727
-    /**
728
-     * @param array $components
729
-     * @return $this
730
-     */
731
-    public function setDocHeaderTopRightComponents(array $components): self
732
-    {
733
-        $this->components[ModulePosition::DOC_HEADER][ModulePosition::TOP][ModulePosition::RIGHT] = $components;
734
-        return $this;
735
-    }
736
-
737
-    /**
738
-     * @param string|array $components
739
-     * @return $this
740
-     */
741
-    public function addDocHeaderTopRightComponents($components): self
742
-    {
743
-        if (is_string($components)) {
744
-            $components = [$components];
745
-        }
746
-        $currentComponents = $this->components[ModulePosition::DOC_HEADER][ModulePosition::TOP][ModulePosition::RIGHT];
747
-        $this->components[ModulePosition::DOC_HEADER][ModulePosition::TOP][ModulePosition::RIGHT] = array_merge($currentComponents, $components);
748
-        return $this;
749
-    }
750
-
751
-    /**
752
-     * @return $array
753
-     */
754
-    public function getDocHeaderBottomLeftComponents()
755
-    {
756
-        $configuration = $this->getModuleConfiguration();
757
-        return $configuration['components'][ModulePosition::DOC_HEADER][ModulePosition::BOTTOM][ModulePosition::LEFT];
758
-    }
759
-
760
-    /**
761
-     * @param array $components
762
-     * @return $this
763
-     */
764
-    public function setDocHeaderBottomLeftComponents(array $components): self
765
-    {
766
-        $this->components[ModulePosition::DOC_HEADER][ModulePosition::BOTTOM][ModulePosition::LEFT] = $components;
767
-        return $this;
768
-    }
769
-
770
-    /**
771
-     * @param string|array $components
772
-     * @return $this
773
-     */
774
-    public function addDocHeaderBottomLeftComponents($components): self
775
-    {
776
-        if (is_string($components)) {
777
-            $components = [$components];
778
-        }
779
-        $currentComponents = $this->components[ModulePosition::DOC_HEADER][ModulePosition::BOTTOM][ModulePosition::LEFT];
780
-        $this->components[ModulePosition::DOC_HEADER][ModulePosition::BOTTOM][ModulePosition::LEFT] = array_merge($currentComponents, $components);
781
-        return $this;
782
-    }
783
-
784
-    /**
785
-     * @return $array
786
-     */
787
-    public function getDocHeaderBottomRightComponents()
788
-    {
789
-        $configuration = $this->getModuleConfiguration();
790
-        return $configuration['components'][ModulePosition::DOC_HEADER][ModulePosition::BOTTOM][ModulePosition::RIGHT];
791
-    }
792
-
793
-    /**
794
-     * @param array $components
795
-     * @return $this
796
-     */
797
-    public function setDocHeaderBottomRightComponents(array $components): self
798
-    {
799
-        $this->components[ModulePosition::DOC_HEADER][ModulePosition::BOTTOM][ModulePosition::RIGHT] = $components;
800
-        return $this;
801
-    }
802
-
803
-    /**
804
-     * @param string|array $components
805
-     * @return $this
806
-     */
807
-    public function addDocHeaderBottomRightComponents($components): self
808
-    {
809
-        if (is_string($components)) {
810
-            $components = [$components];
811
-        }
812
-        $currentComponents = $this->components[ModulePosition::DOC_HEADER][ModulePosition::BOTTOM][ModulePosition::RIGHT];
813
-        $this->components[ModulePosition::DOC_HEADER][ModulePosition::BOTTOM][ModulePosition::RIGHT] = array_merge($currentComponents, $components);
814
-        return $this;
815
-    }
816
-
817
-    /**
818
-     * @return $array
819
-     */
820
-    public function getGridTopComponents()
821
-    {
822
-        $configuration = $this->getModuleConfiguration();
823
-        return $configuration['components'][ModulePosition::GRID][ModulePosition::TOP];
824
-    }
825
-
826
-    /**
827
-     * @param array $components
828
-     * @return $this
829
-     */
830
-    public function setGridTopComponents(array $components): self
831
-    {
832
-        $this->components[ModulePosition::GRID][ModulePosition::TOP] = $components;
833
-        return $this;
834
-    }
835
-
836
-    /**
837
-     * @param string|array $components
838
-     * @return $this
839
-     */
840
-    public function addGridTopComponents($components): self
841
-    {
842
-        if (is_string($components)) {
843
-            $components = [$components];
844
-        }
845
-        $currentComponents = $this->components[ModulePosition::GRID][ModulePosition::TOP];
846
-        $this->components[ModulePosition::GRID][ModulePosition::TOP] = array_merge($currentComponents, $components);
847
-        return $this;
848
-    }
849
-
850
-    /**
851
-     * @return mixed $array
852
-     */
853
-    public function getGridBottomComponents()
854
-    {
855
-        $configuration = $this->getModuleConfiguration();
856
-        return $configuration['components'][ModulePosition::GRID][ModulePosition::BOTTOM];
857
-    }
858
-
859
-    /**
860
-     * @param array $components
861
-     * @return $this
862
-     */
863
-    public function setGridBottomComponents(array $components): self
864
-    {
865
-        $this->components[ModulePosition::GRID][ModulePosition::BOTTOM] = $components;
866
-        return $this;
867
-    }
868
-
869
-    /**
870
-     * @param string|array $components
871
-     * @return $this
872
-     */
873
-    public function addGridBottomComponents($components): self
874
-    {
875
-        if (is_string($components)) {
876
-            $components = [$components];
877
-        }
878
-        $currentComponents = $this->components[ModulePosition::GRID][ModulePosition::BOTTOM];
879
-        $this->components[ModulePosition::GRID][ModulePosition::BOTTOM] = array_merge($currentComponents, $components);
880
-        return $this;
881
-    }
882
-
883
-    /**
884
-     * @return $array
885
-     */
886
-    public function getGridButtonsComponents()
887
-    {
888
-        $configuration = $this->getModuleConfiguration();
889
-        return $configuration['components'][ModulePosition::GRID][ModulePosition::BUTTONS];
890
-    }
891
-
892
-    /**
893
-     * @param array $components
894
-     * @return $this
895
-     */
896
-    public function setGridButtonsComponents(array $components): self
897
-    {
898
-        $this->components[ModulePosition::GRID][ModulePosition::BUTTONS] = $components;
899
-        return $this;
900
-    }
901
-
902
-    /**
903
-     * @param string|array $components
904
-     * @return $this
905
-     */
906
-    public function addGridButtonsComponents($components): self
907
-    {
908
-        if (is_string($components)) {
909
-            $components = [$components];
910
-        }
911
-        $currentComponents = $this->components[ModulePosition::GRID][ModulePosition::BUTTONS];
912
-        $this->components[ModulePosition::GRID][ModulePosition::BUTTONS] = array_merge($components, $currentComponents);
913
-        return $this;
914
-    }
915
-
916
-    /**
917
-     * @return $array
918
-     */
919
-    public function getMenuMassActionComponents()
920
-    {
921
-        $configuration = $this->getModuleConfiguration();
922
-        return $configuration['components'][ModulePosition::MENU_MASS_ACTION];
923
-    }
924
-
925
-    /**
926
-     * @param array $components
927
-     * @return $this
928
-     */
929
-    public function setMenuMassActionComponents(array $components): self
930
-    {
931
-        $this->components[ModulePosition::MENU_MASS_ACTION] = $components;
932
-        return $this;
933
-    }
934
-
935
-    /**
936
-     * @param string|array $components
937
-     * @return $this
938
-     */
939
-    public function addMenuMassActionComponents($components): self
940
-    {
941
-        if (is_string($components)) {
942
-            $components = [$components];
943
-        }
944
-        $currentComponents = $this->components[ModulePosition::MENU_MASS_ACTION];
945
-        $this->components[ModulePosition::MENU_MASS_ACTION] = array_merge($components, $currentComponents);
946
-        return $this;
947
-    }
948
-
949
-    /**
950
-     * @return string
951
-     */
952
-    protected function getAccess(): string
953
-    {
954
-        $moduleConfiguration = $this->getExistingMainConfiguration();
955
-
956
-        if ($this->access !== null) {
957
-            $access = $this->access;
958
-        } elseif (!empty($moduleConfiguration['access'])) { // existing configuration may override.
959
-            $access = $moduleConfiguration['access'];
960
-        } else {
961
-            $access = Access::USER; //default value.
962
-        }
963
-        return $access;
964
-    }
965
-
966
-    /**
967
-     * @param string $access
968
-     * @return $this
969
-     */
970
-    public function setAccess($access): self
971
-    {
972
-        $this->access = $access;
973
-        return $this;
974
-    }
975
-
976
-    /**
977
-     * @return \string[]
978
-     */
979
-    public function getAdditionalJavaScriptFiles(): array
980
-    {
981
-        if (empty($this->additionalJavaScriptFiles)) {
982
-            $this->additionalJavaScriptFiles = $this->getModuleConfiguration('additionalJavaScriptFiles');
983
-        }
984
-        return $this->additionalJavaScriptFiles;
985
-    }
986
-
987
-    /**
988
-     * @return \string[]
989
-     */
990
-    public function getAdditionalStyleSheetFiles(): array
991
-    {
992
-        if (empty($this->additionalStyleSheetFiles)) {
993
-            $this->additionalStyleSheetFiles = $this->getModuleConfiguration('additionalStyleSheetFiles');
994
-        }
995
-        return $this->additionalStyleSheetFiles;
996
-    }
997
-
998
-    /**
999
-     * @return array
1000
-     */
1001
-    public function getComponents(): array
1002
-    {
1003
-        return $this->components;
1004
-    }
1005
-
1006
-    /**
1007
-     * @param string $pluginName
1008
-     * @return bool
1009
-     */
1010
-    public function hasPlugin($pluginName = ''): bool
1011
-    {
1012
-        $parameterPrefix = $this->getParameterPrefix();
1013
-        $parameters = GeneralUtility::_GET($parameterPrefix);
1014
-
1015
-        $hasPlugin = !empty($parameters['plugins']) && is_array($parameters['plugins']);
1016
-        if ($hasPlugin && $pluginName) {
1017
-            $hasPlugin = in_array($pluginName, $parameters['plugins']);
1018
-        }
1019
-        return $hasPlugin;
1020
-    }
1021
-
1022
-    /**
1023
-     * Compute the internal module code
1024
-     *
1025
-     * @param null|string $dataType
1026
-     * @return string
1027
-     */
1028
-    protected function getInternalModuleSignature($dataType = null): string
1029
-    {
1030
-        // Else we forge the module signature
1031
-        if ($dataType === null) {
1032
-            $dataType = $this->dataType;
1033
-        }
1034
-        $subModuleName = $dataType . '_' . $this->moduleKey;
1035
-
1036
-        $mainModule = $this->mainModule ?: self::DEFAULT_MAIN_MODULE;
1037
-        return $mainModule . '_Vidi' . GeneralUtility::underscoredToUpperCamelCase($subModuleName);
1038
-    }
40
+	/**
41
+	 * Define the default main module
42
+	 */
43
+	const DEFAULT_MAIN_MODULE = 'content';
44
+
45
+	/**
46
+	 * Define the default pid
47
+	 */
48
+	const DEFAULT_PID = 0;
49
+
50
+	/**
51
+	 * The type of data being listed (which corresponds to a table name in TCA)
52
+	 *
53
+	 * @var string
54
+	 */
55
+	protected $dataType;
56
+
57
+	/**
58
+	 * @var string
59
+	 */
60
+	protected $defaultPid;
61
+
62
+	/**
63
+	 * @var bool
64
+	 */
65
+	protected $isPidIgnored = false;
66
+
67
+	/**
68
+	 * @var bool
69
+	 */
70
+	protected $showPageTree = false;
71
+
72
+	/**
73
+	 * @var bool
74
+	 */
75
+	protected $isShown = true;
76
+
77
+	/**
78
+	 * @var string
79
+	 */
80
+	protected $access;
81
+
82
+	/**
83
+	 * @var string
84
+	 */
85
+	protected $mainModule;
86
+
87
+	/**
88
+	 * @var string
89
+	 */
90
+	protected $position = '';
91
+
92
+	/**
93
+	 * @var string
94
+	 */
95
+	protected $icon;
96
+
97
+	/**
98
+	 * @var string
99
+	 */
100
+	protected $moduleLanguageFile;
101
+
102
+	/**
103
+	 * The module key such as m1, m2.
104
+	 *
105
+	 * @var string
106
+	 */
107
+	protected $moduleKey = 'm1';
108
+
109
+	/**
110
+	 * @var string[]
111
+	 */
112
+	protected $additionalJavaScriptFiles = [];
113
+
114
+	/**
115
+	 * @var string[]
116
+	 */
117
+	protected $additionalStyleSheetFiles = [];
118
+
119
+	/**
120
+	 * @var array
121
+	 */
122
+	protected $components = [];
123
+
124
+	/**
125
+	 * @param string $dataType
126
+	 */
127
+	public function __construct($dataType = null)
128
+	{
129
+		$this->dataType = $dataType;
130
+
131
+		// Initialize components
132
+		$this->components = [
133
+			ModulePosition::DOC_HEADER => [
134
+				ModulePosition::TOP => [
135
+					ModulePosition::LEFT => [],
136
+					ModulePosition::RIGHT => [
137
+						ToolButton::class,
138
+					],
139
+				],
140
+				ModulePosition::BOTTOM => [
141
+					ModulePosition::LEFT => [
142
+						NewButton::class,
143
+						BackViewHelper::class,
144
+					],
145
+					ModulePosition::RIGHT => [],
146
+				],
147
+			],
148
+			ModulePosition::GRID => [
149
+				ModulePosition::TOP => [
150
+					RelationsCheck::class,
151
+					#\Fab\Vidi\View\Tab\DataTypeTab::class,
152
+				],
153
+				ModulePosition::BUTTONS => [
154
+					EditButton::class,
155
+					DeleteButton::class,
156
+				],
157
+				ModulePosition::BOTTOM => [],
158
+			],
159
+			ModulePosition::MENU_MASS_ACTION => [
160
+				ExportXlsMenuItem::class,
161
+				ExportXmlMenuItem::class,
162
+				ExportCsvMenuItem::class,
163
+				DividerMenuItem::class,
164
+				MassDeleteMenuItem::class,
165
+				#\Fab\Vidi\View\MenuItem\MassEditMenuItem::class,
166
+			],
167
+		];
168
+	}
169
+
170
+	/**
171
+	 * Tell whether a module is already registered.
172
+	 *
173
+	 * @param string $dataType
174
+	 * @return bool
175
+	 */
176
+	public function isRegistered($dataType): bool
177
+	{
178
+		$internalModuleSignature = $this->getInternalModuleSignature($dataType);
179
+		return !empty($GLOBALS['TBE_MODULES_EXT']['vidi'][$internalModuleSignature]);
180
+	}
181
+
182
+	/**
183
+	 * @return array
184
+	 */
185
+	protected function getExistingInternalConfiguration(): array
186
+	{
187
+		$internalModuleSignature = $this->getInternalModuleSignature();
188
+		return $GLOBALS['TBE_MODULES_EXT']['vidi'][$internalModuleSignature] ?? [];
189
+	}
190
+
191
+	/**
192
+	 * @return array
193
+	 */
194
+	protected function getExistingMainConfiguration(): array
195
+	{
196
+		$moduleSignature = $this->computeMainModule() . '_' . $this->getInternalModuleSignature();
197
+		return $GLOBALS['TBE_MODULES']['_configuration'][$moduleSignature] ?? [];
198
+	}
199
+
200
+	/**
201
+	 * @return string
202
+	 */
203
+	protected function computeMainModule(): string
204
+	{
205
+		$existingConfiguration = $this->getExistingInternalConfiguration();
206
+
207
+		if ($this->mainModule !== null) {
208
+			$mainModule = $this->mainModule;
209
+		} elseif (!empty($existingConfiguration['mainModule'])) { // existing configuration may override.
210
+			$mainModule = $existingConfiguration['mainModule'];
211
+		} else {
212
+			$mainModule = self::DEFAULT_MAIN_MODULE; //default value.
213
+		}
214
+		return $mainModule;
215
+	}
216
+
217
+	/**
218
+	 * @return string
219
+	 */
220
+	protected function computeDefaultPid(): string
221
+	{
222
+		$existingConfiguration = $this->getExistingInternalConfiguration();
223
+
224
+		if ($this->defaultPid !== null) {
225
+			$defaultPid = $this->defaultPid;
226
+		} elseif (!empty($existingConfiguration['defaultPid'])) { // existing configuration may override.
227
+			$defaultPid = $existingConfiguration['defaultPid'];
228
+		} else {
229
+			$defaultPid = self::DEFAULT_PID; //default value.
230
+		}
231
+		return $defaultPid;
232
+	}
233
+
234
+	/**
235
+	 * @return array
236
+	 */
237
+	protected function computeAdditionalJavaScriptFiles(): array
238
+	{
239
+		$additionalJavaScriptFiles = $this->additionalJavaScriptFiles;
240
+
241
+		// Possible merge of existing javascript files.
242
+		$existingConfiguration = $this->getExistingInternalConfiguration();
243
+		if (!empty($existingConfiguration['additionalJavaScriptFiles'])) {
244
+			$additionalJavaScriptFiles = array_merge($additionalJavaScriptFiles, $existingConfiguration['additionalJavaScriptFiles']);
245
+		}
246
+
247
+		return $additionalJavaScriptFiles;
248
+	}
249
+
250
+	/**
251
+	 * @return array
252
+	 */
253
+	protected function computeAdditionalStyleSheetFiles(): array
254
+	{
255
+		$additionalStyleSheetFiles = $this->additionalStyleSheetFiles;
256
+
257
+		// Possible merge of existing style sheets.
258
+		$existingConfiguration = $this->getExistingInternalConfiguration();
259
+		if (!empty($existingConfiguration['additionalStyleSheetFiles'])) {
260
+			$additionalStyleSheetFiles = array_merge($additionalStyleSheetFiles, $existingConfiguration['additionalStyleSheetFiles']);
261
+		}
262
+
263
+		return $additionalStyleSheetFiles;
264
+	}
265
+
266
+	/**
267
+	 * @return array
268
+	 */
269
+	protected function computeComponents(): array
270
+	{
271
+		// We override the config in any case. See if we need more than that.
272
+		return $this->components;
273
+	}
274
+
275
+	/**
276
+	 * Register the module in two places: core + vidi internal.
277
+	 *
278
+	 * @return $this
279
+	 */
280
+	public function register(): self
281
+	{
282
+		// Internal Vidi module registration.
283
+		$configuration = [];
284
+		$configuration['dataType'] = $this->dataType;
285
+		$configuration['mainModule'] = $this->computeMainModule();
286
+		$configuration['defaultPid'] = $this->computeDefaultPid();
287
+		$configuration['additionalJavaScriptFiles'] = $this->computeAdditionalJavaScriptFiles();
288
+		$configuration['additionalStyleSheetFiles'] = $this->computeAdditionalStyleSheetFiles();
289
+		$configuration['components'] = $this->computeComponents();
290
+		$configuration['isPidIgnored'] = $this->isPidIgnored;
291
+
292
+		$internalModuleSignature = $this->getInternalModuleSignature();
293
+		$GLOBALS['TBE_MODULES_EXT']['vidi'][$internalModuleSignature] = $configuration;
294
+
295
+		// Core module registration.
296
+		// Register and displays module in the BE only if told, default is "true".
297
+		if ($this->isShown) {
298
+
299
+			$moduleConfiguration = [];
300
+			#$moduleConfiguration['routeTarget'] = \Fab\Vidi\Controller\ContentController::class . '::mainAction', // what to do here?
301
+			$moduleConfiguration['access'] = $this->getAccess();
302
+			$moduleConfiguration['labels'] = $this->getModuleLanguageFile();
303
+			$icon = $this->getIcon();
304
+			if ($icon) {
305
+				$moduleConfiguration['icon'] = $icon;
306
+			}
307
+
308
+			if ($this->showPageTree) {
309
+				$moduleConfiguration['navigationComponentId'] = 'TYPO3/CMS/Backend/PageTree/PageTreeElement';
310
+				$moduleConfiguration['inheritNavigationComponentFromMainModule'] = true;
311
+			} else {
312
+				$moduleConfiguration['inheritNavigationComponentFromMainModule'] = true;
313
+			}
314
+
315
+			ExtensionUtility::registerModule(
316
+				'Fab.vidi',
317
+				$this->computeMainModule(),
318
+				$this->dataType . '_' . $this->moduleKey,
319
+				$this->position,
320
+				[
321
+					ContentController::class => 'index, list, delete, update, edit, copy, move, localize, sort, copyClipboard, moveClipboard',
322
+					ToolController::class => 'welcome, work',
323
+					FacetController::class => 'autoSuggest, autoSuggests',
324
+					SelectionController::class => 'edit, update, create, delete, list, show',
325
+					UserPreferencesController::class => 'save',
326
+					ClipboardController::class => 'save, flush, show',
327
+				],
328
+				$moduleConfiguration
329
+			);
330
+		}
331
+		return $this;
332
+	}
333
+
334
+	/**
335
+	 * Return the module code for a BE module.
336
+	 *
337
+	 * @return string
338
+	 */
339
+	public function getSignature(): string
340
+	{
341
+		$signature = GeneralUtility::_GP(Parameter::MODULE);
342
+		$trimmedSignature = trim($signature, '/');
343
+		return str_replace(['/', 'module_'], ['_', ''], $trimmedSignature);
344
+	}
345
+
346
+	/**
347
+	 * Returns the current pid.
348
+	 *
349
+	 * @return int
350
+	 */
351
+	public function getCurrentPid(): int
352
+	{
353
+		return GeneralUtility::_GET(Parameter::PID) > 0 ? (int)GeneralUtility::_GET(Parameter::PID) : 0;
354
+	}
355
+
356
+	/**
357
+	 * Return the module URL.
358
+	 *
359
+	 * @param array $additionalParameters
360
+	 * @return string
361
+	 */
362
+	public function getModuleUrl(array $additionalParameters = []): string
363
+	{
364
+		$moduleCode = $this->getSignature();
365
+
366
+		// And don't forget the pid!
367
+		if (GeneralUtility::_GET(Parameter::PID)) {
368
+			$additionalParameters[Parameter::PID] = GeneralUtility::_GET(Parameter::PID);
369
+		}
370
+
371
+		return BackendUtility::getModuleUrl($moduleCode, $additionalParameters);
372
+	}
373
+
374
+	/**
375
+	 * Return the parameter prefix for a BE module.
376
+	 *
377
+	 * @return string
378
+	 */
379
+	public function getParameterPrefix(): string
380
+	{
381
+		return 'tx_vidi_' . strtolower($this->getSignature());
382
+	}
383
+
384
+	/**
385
+	 * Return a configuration key or the entire module configuration array if not key is given.
386
+	 *
387
+	 * @param string $key
388
+	 * @return mixed
389
+	 */
390
+	public function getModuleConfiguration($key = '')
391
+	{
392
+
393
+		$vidiModuleCode = $this->getSignature();
394
+
395
+		// Module code must exist
396
+		if (empty($GLOBALS['TBE_MODULES_EXT']['vidi'][$vidiModuleCode])) {
397
+			$message = sprintf('Invalid or not existing module code "%s"', $vidiModuleCode);
398
+			throw new InvalidKeyInArrayException($message, 1375092053);
399
+		}
400
+
401
+		$result = $GLOBALS['TBE_MODULES_EXT']['vidi'][$vidiModuleCode];
402
+
403
+		if (!empty($key)) {
404
+			if (isset($result[$key])) {
405
+				$result = $result[$key];
406
+			} else {
407
+				// key must exist
408
+				$message = sprintf('Invalid key configuration "%s"', $key);
409
+				throw new InvalidKeyInArrayException($message, 1375092054);
410
+			}
411
+		}
412
+		return $result;
413
+	}
414
+
415
+	/**
416
+	 * @param string $icon
417
+	 * @return $this
418
+	 */
419
+	public function setIcon($icon): self
420
+	{
421
+		$this->icon = $icon;
422
+		return $this;
423
+	}
424
+
425
+	/**
426
+	 * @return string
427
+	 */
428
+	protected function getIcon(): string
429
+	{
430
+		$moduleConfiguration = $this->getExistingMainConfiguration();
431
+
432
+
433
+		if ($this->icon) {
434
+			$icon = $this->icon;
435
+		} elseif ($moduleConfiguration['icon']) { // existing configuration may override.
436
+			$icon = $moduleConfiguration['icon'];
437
+		} else {
438
+			$icon = ''; //default value.
439
+		}
440
+
441
+		return $icon;
442
+	}
443
+
444
+	/**
445
+	 * @param string $mainModule
446
+	 * @return $this
447
+	 */
448
+	public function setMainModule($mainModule): self
449
+	{
450
+		$this->mainModule = $mainModule;
451
+		return $this;
452
+	}
453
+
454
+	/**
455
+	 * @return string
456
+	 */
457
+	public function getMainModule(): string
458
+	{
459
+		if ($this->mainModule === null) {
460
+			$this->mainModule = $this->getModuleConfiguration('mainModule');
461
+		}
462
+		return $this->mainModule;
463
+	}
464
+
465
+	/**
466
+	 * @param string $moduleLanguageFile
467
+	 * @return $this
468
+	 */
469
+	public function setModuleLanguageFile($moduleLanguageFile): self
470
+	{
471
+		$this->moduleLanguageFile = $moduleLanguageFile;
472
+		return $this;
473
+	}
474
+
475
+	/**
476
+	 * @param string $component
477
+	 * @return $this
478
+	 */
479
+	public function removeComponentFromDocHeader(string $component): self
480
+	{
481
+		foreach ($this->components[ModulePosition::DOC_HEADER] as $verticalPosition => $docHeaders) {
482
+			foreach ($docHeaders as $horizontalPosition => $docHeader) {
483
+
484
+				$index = array_search($component, $docHeader, true);
485
+				if ($index !== false) {
486
+					// $verticalPosition: top or bottom
487
+					// $horizontalPosition: left or right
488
+					unset($this->components[ModulePosition::DOC_HEADER][$verticalPosition][$horizontalPosition][$index]);
489
+				}
490
+			}
491
+		}
492
+		return $this;
493
+	}
494
+
495
+	/**
496
+	 * @param bool $isPidIgnored
497
+	 * @return $this
498
+	 */
499
+	public function ignorePid(bool $isPidIgnored): self
500
+	{
501
+		$this->isPidIgnored = $isPidIgnored;
502
+		return $this;
503
+	}
504
+
505
+	/**
506
+	 * @return bool
507
+	 */
508
+	public function isPidIgnored(): bool
509
+	{
510
+		return $this->getModuleConfiguration('isPidIgnored');
511
+	}
512
+
513
+	/**
514
+	 * @param string $component
515
+	 * @return bool
516
+	 */
517
+	public function hasComponentInDocHeader(string $component): bool
518
+	{
519
+		foreach ($this->getModuleConfiguration('components')[ModulePosition::DOC_HEADER] as $verticalPosition => $docHeaders) {
520
+			foreach ($docHeaders as $horizontalPosition => $docHeader) {
521
+
522
+				$index = array_search($component, $docHeader, true);
523
+				if ($index !== false) {
524
+					return true;
525
+				}
526
+			}
527
+		}
528
+		return false;
529
+	}
530
+
531
+	/**
532
+	 * @return string
533
+	 */
534
+	protected function getModuleLanguageFile(): string
535
+	{
536
+		$moduleConfiguration = $this->getExistingMainConfiguration();
537
+
538
+		if ($this->moduleLanguageFile) {
539
+			$moduleLanguageFile = $this->moduleLanguageFile;
540
+		} elseif ($moduleConfiguration['labels']) { // existing configuration may override.
541
+			$moduleLanguageFile = $moduleConfiguration['labels'];
542
+		} else {
543
+			$moduleLanguageFile = ''; //default value.
544
+		}
545
+
546
+		return $moduleLanguageFile;
547
+	}
548
+
549
+	/**
550
+	 * @param string $position
551
+	 * @return $this
552
+	 */
553
+	public function setPosition($position): self
554
+	{
555
+		$this->position = $position;
556
+		return $this;
557
+	}
558
+
559
+	/**
560
+	 * @return string
561
+	 */
562
+	public function getPosition(): string
563
+	{
564
+		return $this->position;
565
+	}
566
+
567
+	/**
568
+	 * @param array $files
569
+	 * @return $this
570
+	 */
571
+	public function addJavaScriptFiles(array $files): self
572
+	{
573
+		foreach ($files as $file) {
574
+			$this->additionalJavaScriptFiles[] = $file;
575
+		}
576
+		return $this;
577
+	}
578
+
579
+	/**
580
+	 * @param string $fileNameAndPath
581
+	 * @return $this
582
+	 */
583
+	public function addJavaScriptFile($fileNameAndPath): self
584
+	{
585
+		$this->additionalJavaScriptFiles[] = $fileNameAndPath;
586
+		return $this;
587
+	}
588
+
589
+	/**
590
+	 * @param array $files
591
+	 * @return $this
592
+	 */
593
+	public function addStyleSheetFiles(array $files): self
594
+	{
595
+		foreach ($files as $file) {
596
+			$this->additionalStyleSheetFiles[] = $file;
597
+		}
598
+		return $this;
599
+	}
600
+
601
+	/**
602
+	 * @param string $fileNameAndPath
603
+	 * @return $this
604
+	 */
605
+	public function addStyleSheetFile($fileNameAndPath): self
606
+	{
607
+		$this->additionalStyleSheetFiles[] = $fileNameAndPath;
608
+		return $this;
609
+	}
610
+
611
+	/**
612
+	 * @return string
613
+	 */
614
+	public function getDataType(): string
615
+	{
616
+		if ($this->dataType === null) {
617
+			$this->dataType = $this->getModuleConfiguration('dataType');
618
+		}
619
+		return $this->dataType;
620
+	}
621
+
622
+	/**
623
+	 * @return array
624
+	 */
625
+	public function getDataTypes(): array
626
+	{
627
+		$dataTypes = [];
628
+		foreach ($GLOBALS['TBE_MODULES_EXT']['vidi'] as $module) {
629
+			$dataTypes[] = $module['dataType'];
630
+		}
631
+		return $dataTypes;
632
+	}
633
+
634
+	/**
635
+	 * @param string $dataType
636
+	 * @return $this
637
+	 */
638
+	public function setDataType($dataType): self
639
+	{
640
+		$this->dataType = $dataType;
641
+		return $this;
642
+	}
643
+
644
+	/**
645
+	 * @return int
646
+	 */
647
+	public function getDefaultPid(): int
648
+	{
649
+		if (empty($this->defaultPid)) {
650
+			$this->defaultPid = $this->getModuleConfiguration('defaultPid');
651
+		}
652
+		return (int)$this->defaultPid;
653
+	}
654
+
655
+	/**
656
+	 * @param string $defaultPid
657
+	 * @return $this
658
+	 */
659
+	public function setDefaultPid($defaultPid): self
660
+	{
661
+		$this->defaultPid = $defaultPid;
662
+		return $this;
663
+	}
664
+
665
+	/**
666
+	 * @param bool $isPageTreeShown
667
+	 * @return $this
668
+	 */
669
+	public function showPageTree($isPageTreeShown): self
670
+	{
671
+		$this->showPageTree = $isPageTreeShown;
672
+		return $this;
673
+	}
674
+
675
+	/**
676
+	 * @param string $isShown
677
+	 * @return $this
678
+	 */
679
+	public function isShown($isShown): self
680
+	{
681
+		$this->isShown = $isShown;
682
+		return $this;
683
+	}
684
+
685
+	/**
686
+	 * @return $array
687
+	 */
688
+	public function getDocHeaderTopLeftComponents()
689
+	{
690
+		$configuration = $this->getModuleConfiguration();
691
+		return $configuration['components'][ModulePosition::DOC_HEADER][ModulePosition::TOP][ModulePosition::LEFT];
692
+	}
693
+
694
+	/**
695
+	 * @param array $components
696
+	 * @return $this
697
+	 */
698
+	public function setDocHeaderTopLeftComponents(array $components): self
699
+	{
700
+		$this->components[ModulePosition::DOC_HEADER][ModulePosition::TOP][ModulePosition::LEFT] = $components;
701
+		return $this;
702
+	}
703
+
704
+	/**
705
+	 * @param string|array $components
706
+	 * @return $this
707
+	 */
708
+	public function addDocHeaderTopLeftComponents($components): self
709
+	{
710
+		if (is_string($components)) {
711
+			$components = [$components];
712
+		}
713
+		$currentComponents = $this->components[ModulePosition::DOC_HEADER][ModulePosition::TOP][ModulePosition::LEFT];
714
+		$this->components[ModulePosition::DOC_HEADER][ModulePosition::TOP][ModulePosition::LEFT] = array_merge($currentComponents, $components);
715
+		return $this;
716
+	}
717
+
718
+	/**
719
+	 * @return $array
720
+	 */
721
+	public function getDocHeaderTopRightComponents()
722
+	{
723
+		$configuration = $this->getModuleConfiguration();
724
+		return $configuration['components'][ModulePosition::DOC_HEADER][ModulePosition::TOP][ModulePosition::RIGHT];
725
+	}
726
+
727
+	/**
728
+	 * @param array $components
729
+	 * @return $this
730
+	 */
731
+	public function setDocHeaderTopRightComponents(array $components): self
732
+	{
733
+		$this->components[ModulePosition::DOC_HEADER][ModulePosition::TOP][ModulePosition::RIGHT] = $components;
734
+		return $this;
735
+	}
736
+
737
+	/**
738
+	 * @param string|array $components
739
+	 * @return $this
740
+	 */
741
+	public function addDocHeaderTopRightComponents($components): self
742
+	{
743
+		if (is_string($components)) {
744
+			$components = [$components];
745
+		}
746
+		$currentComponents = $this->components[ModulePosition::DOC_HEADER][ModulePosition::TOP][ModulePosition::RIGHT];
747
+		$this->components[ModulePosition::DOC_HEADER][ModulePosition::TOP][ModulePosition::RIGHT] = array_merge($currentComponents, $components);
748
+		return $this;
749
+	}
750
+
751
+	/**
752
+	 * @return $array
753
+	 */
754
+	public function getDocHeaderBottomLeftComponents()
755
+	{
756
+		$configuration = $this->getModuleConfiguration();
757
+		return $configuration['components'][ModulePosition::DOC_HEADER][ModulePosition::BOTTOM][ModulePosition::LEFT];
758
+	}
759
+
760
+	/**
761
+	 * @param array $components
762
+	 * @return $this
763
+	 */
764
+	public function setDocHeaderBottomLeftComponents(array $components): self
765
+	{
766
+		$this->components[ModulePosition::DOC_HEADER][ModulePosition::BOTTOM][ModulePosition::LEFT] = $components;
767
+		return $this;
768
+	}
769
+
770
+	/**
771
+	 * @param string|array $components
772
+	 * @return $this
773
+	 */
774
+	public function addDocHeaderBottomLeftComponents($components): self
775
+	{
776
+		if (is_string($components)) {
777
+			$components = [$components];
778
+		}
779
+		$currentComponents = $this->components[ModulePosition::DOC_HEADER][ModulePosition::BOTTOM][ModulePosition::LEFT];
780
+		$this->components[ModulePosition::DOC_HEADER][ModulePosition::BOTTOM][ModulePosition::LEFT] = array_merge($currentComponents, $components);
781
+		return $this;
782
+	}
783
+
784
+	/**
785
+	 * @return $array
786
+	 */
787
+	public function getDocHeaderBottomRightComponents()
788
+	{
789
+		$configuration = $this->getModuleConfiguration();
790
+		return $configuration['components'][ModulePosition::DOC_HEADER][ModulePosition::BOTTOM][ModulePosition::RIGHT];
791
+	}
792
+
793
+	/**
794
+	 * @param array $components
795
+	 * @return $this
796
+	 */
797
+	public function setDocHeaderBottomRightComponents(array $components): self
798
+	{
799
+		$this->components[ModulePosition::DOC_HEADER][ModulePosition::BOTTOM][ModulePosition::RIGHT] = $components;
800
+		return $this;
801
+	}
802
+
803
+	/**
804
+	 * @param string|array $components
805
+	 * @return $this
806
+	 */
807
+	public function addDocHeaderBottomRightComponents($components): self
808
+	{
809
+		if (is_string($components)) {
810
+			$components = [$components];
811
+		}
812
+		$currentComponents = $this->components[ModulePosition::DOC_HEADER][ModulePosition::BOTTOM][ModulePosition::RIGHT];
813
+		$this->components[ModulePosition::DOC_HEADER][ModulePosition::BOTTOM][ModulePosition::RIGHT] = array_merge($currentComponents, $components);
814
+		return $this;
815
+	}
816
+
817
+	/**
818
+	 * @return $array
819
+	 */
820
+	public function getGridTopComponents()
821
+	{
822
+		$configuration = $this->getModuleConfiguration();
823
+		return $configuration['components'][ModulePosition::GRID][ModulePosition::TOP];
824
+	}
825
+
826
+	/**
827
+	 * @param array $components
828
+	 * @return $this
829
+	 */
830
+	public function setGridTopComponents(array $components): self
831
+	{
832
+		$this->components[ModulePosition::GRID][ModulePosition::TOP] = $components;
833
+		return $this;
834
+	}
835
+
836
+	/**
837
+	 * @param string|array $components
838
+	 * @return $this
839
+	 */
840
+	public function addGridTopComponents($components): self
841
+	{
842
+		if (is_string($components)) {
843
+			$components = [$components];
844
+		}
845
+		$currentComponents = $this->components[ModulePosition::GRID][ModulePosition::TOP];
846
+		$this->components[ModulePosition::GRID][ModulePosition::TOP] = array_merge($currentComponents, $components);
847
+		return $this;
848
+	}
849
+
850
+	/**
851
+	 * @return mixed $array
852
+	 */
853
+	public function getGridBottomComponents()
854
+	{
855
+		$configuration = $this->getModuleConfiguration();
856
+		return $configuration['components'][ModulePosition::GRID][ModulePosition::BOTTOM];
857
+	}
858
+
859
+	/**
860
+	 * @param array $components
861
+	 * @return $this
862
+	 */
863
+	public function setGridBottomComponents(array $components): self
864
+	{
865
+		$this->components[ModulePosition::GRID][ModulePosition::BOTTOM] = $components;
866
+		return $this;
867
+	}
868
+
869
+	/**
870
+	 * @param string|array $components
871
+	 * @return $this
872
+	 */
873
+	public function addGridBottomComponents($components): self
874
+	{
875
+		if (is_string($components)) {
876
+			$components = [$components];
877
+		}
878
+		$currentComponents = $this->components[ModulePosition::GRID][ModulePosition::BOTTOM];
879
+		$this->components[ModulePosition::GRID][ModulePosition::BOTTOM] = array_merge($currentComponents, $components);
880
+		return $this;
881
+	}
882
+
883
+	/**
884
+	 * @return $array
885
+	 */
886
+	public function getGridButtonsComponents()
887
+	{
888
+		$configuration = $this->getModuleConfiguration();
889
+		return $configuration['components'][ModulePosition::GRID][ModulePosition::BUTTONS];
890
+	}
891
+
892
+	/**
893
+	 * @param array $components
894
+	 * @return $this
895
+	 */
896
+	public function setGridButtonsComponents(array $components): self
897
+	{
898
+		$this->components[ModulePosition::GRID][ModulePosition::BUTTONS] = $components;
899
+		return $this;
900
+	}
901
+
902
+	/**
903
+	 * @param string|array $components
904
+	 * @return $this
905
+	 */
906
+	public function addGridButtonsComponents($components): self
907
+	{
908
+		if (is_string($components)) {
909
+			$components = [$components];
910
+		}
911
+		$currentComponents = $this->components[ModulePosition::GRID][ModulePosition::BUTTONS];
912
+		$this->components[ModulePosition::GRID][ModulePosition::BUTTONS] = array_merge($components, $currentComponents);
913
+		return $this;
914
+	}
915
+
916
+	/**
917
+	 * @return $array
918
+	 */
919
+	public function getMenuMassActionComponents()
920
+	{
921
+		$configuration = $this->getModuleConfiguration();
922
+		return $configuration['components'][ModulePosition::MENU_MASS_ACTION];
923
+	}
924
+
925
+	/**
926
+	 * @param array $components
927
+	 * @return $this
928
+	 */
929
+	public function setMenuMassActionComponents(array $components): self
930
+	{
931
+		$this->components[ModulePosition::MENU_MASS_ACTION] = $components;
932
+		return $this;
933
+	}
934
+
935
+	/**
936
+	 * @param string|array $components
937
+	 * @return $this
938
+	 */
939
+	public function addMenuMassActionComponents($components): self
940
+	{
941
+		if (is_string($components)) {
942
+			$components = [$components];
943
+		}
944
+		$currentComponents = $this->components[ModulePosition::MENU_MASS_ACTION];
945
+		$this->components[ModulePosition::MENU_MASS_ACTION] = array_merge($components, $currentComponents);
946
+		return $this;
947
+	}
948
+
949
+	/**
950
+	 * @return string
951
+	 */
952
+	protected function getAccess(): string
953
+	{
954
+		$moduleConfiguration = $this->getExistingMainConfiguration();
955
+
956
+		if ($this->access !== null) {
957
+			$access = $this->access;
958
+		} elseif (!empty($moduleConfiguration['access'])) { // existing configuration may override.
959
+			$access = $moduleConfiguration['access'];
960
+		} else {
961
+			$access = Access::USER; //default value.
962
+		}
963
+		return $access;
964
+	}
965
+
966
+	/**
967
+	 * @param string $access
968
+	 * @return $this
969
+	 */
970
+	public function setAccess($access): self
971
+	{
972
+		$this->access = $access;
973
+		return $this;
974
+	}
975
+
976
+	/**
977
+	 * @return \string[]
978
+	 */
979
+	public function getAdditionalJavaScriptFiles(): array
980
+	{
981
+		if (empty($this->additionalJavaScriptFiles)) {
982
+			$this->additionalJavaScriptFiles = $this->getModuleConfiguration('additionalJavaScriptFiles');
983
+		}
984
+		return $this->additionalJavaScriptFiles;
985
+	}
986
+
987
+	/**
988
+	 * @return \string[]
989
+	 */
990
+	public function getAdditionalStyleSheetFiles(): array
991
+	{
992
+		if (empty($this->additionalStyleSheetFiles)) {
993
+			$this->additionalStyleSheetFiles = $this->getModuleConfiguration('additionalStyleSheetFiles');
994
+		}
995
+		return $this->additionalStyleSheetFiles;
996
+	}
997
+
998
+	/**
999
+	 * @return array
1000
+	 */
1001
+	public function getComponents(): array
1002
+	{
1003
+		return $this->components;
1004
+	}
1005
+
1006
+	/**
1007
+	 * @param string $pluginName
1008
+	 * @return bool
1009
+	 */
1010
+	public function hasPlugin($pluginName = ''): bool
1011
+	{
1012
+		$parameterPrefix = $this->getParameterPrefix();
1013
+		$parameters = GeneralUtility::_GET($parameterPrefix);
1014
+
1015
+		$hasPlugin = !empty($parameters['plugins']) && is_array($parameters['plugins']);
1016
+		if ($hasPlugin && $pluginName) {
1017
+			$hasPlugin = in_array($pluginName, $parameters['plugins']);
1018
+		}
1019
+		return $hasPlugin;
1020
+	}
1021
+
1022
+	/**
1023
+	 * Compute the internal module code
1024
+	 *
1025
+	 * @param null|string $dataType
1026
+	 * @return string
1027
+	 */
1028
+	protected function getInternalModuleSignature($dataType = null): string
1029
+	{
1030
+		// Else we forge the module signature
1031
+		if ($dataType === null) {
1032
+			$dataType = $this->dataType;
1033
+		}
1034
+		$subModuleName = $dataType . '_' . $this->moduleKey;
1035
+
1036
+		$mainModule = $this->mainModule ?: self::DEFAULT_MAIN_MODULE;
1037
+		return $mainModule . '_Vidi' . GeneralUtility::underscoredToUpperCamelCase($subModuleName);
1038
+	}
1039 1039
 
1040 1040
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
      */
194 194
     protected function getExistingMainConfiguration(): array
195 195
     {
196
-        $moduleSignature = $this->computeMainModule() . '_' . $this->getInternalModuleSignature();
196
+        $moduleSignature = $this->computeMainModule().'_'.$this->getInternalModuleSignature();
197 197
         return $GLOBALS['TBE_MODULES']['_configuration'][$moduleSignature] ?? [];
198 198
     }
199 199
 
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
             ExtensionUtility::registerModule(
316 316
                 'Fab.vidi',
317 317
                 $this->computeMainModule(),
318
-                $this->dataType . '_' . $this->moduleKey,
318
+                $this->dataType.'_'.$this->moduleKey,
319 319
                 $this->position,
320 320
                 [
321 321
                     ContentController::class => 'index, list, delete, update, edit, copy, move, localize, sort, copyClipboard, moveClipboard',
@@ -378,7 +378,7 @@  discard block
 block discarded – undo
378 378
      */
379 379
     public function getParameterPrefix(): string
380 380
     {
381
-        return 'tx_vidi_' . strtolower($this->getSignature());
381
+        return 'tx_vidi_'.strtolower($this->getSignature());
382 382
     }
383 383
 
384 384
     /**
@@ -1031,10 +1031,10 @@  discard block
 block discarded – undo
1031 1031
         if ($dataType === null) {
1032 1032
             $dataType = $this->dataType;
1033 1033
         }
1034
-        $subModuleName = $dataType . '_' . $this->moduleKey;
1034
+        $subModuleName = $dataType.'_'.$this->moduleKey;
1035 1035
 
1036 1036
         $mainModule = $this->mainModule ?: self::DEFAULT_MAIN_MODULE;
1037
-        return $mainModule . '_Vidi' . GeneralUtility::underscoredToUpperCamelCase($subModuleName);
1037
+        return $mainModule.'_Vidi'.GeneralUtility::underscoredToUpperCamelCase($subModuleName);
1038 1038
     }
1039 1039
 
1040 1040
 }
Please login to merge, or discard this patch.