Completed
Push — master ( 892a3f...068784 )
by Fabien
50:28
created
Classes/ViewHelpers/Content/AbstractContentViewHelper.php 1 patch
Indentation   +201 added lines, -201 removed lines patch added patch discarded remove patch
@@ -27,206 +27,206 @@
 block discarded – undo
27 27
 abstract class AbstractContentViewHelper extends AbstractViewHelper
28 28
 {
29 29
 
30
-    /**
31
-     * @return void
32
-     * @throws Exception
33
-     */
34
-    public function initializeArguments()
35
-    {
36
-        $this->registerArgument('type', 'string', 'Corresponds to the type of data to be fetched. It will basically be a table name e.g. fe_users.', false, '');
37
-        $this->registerArgument('matches', 'array', 'Key / value array to be used as filter. The key corresponds to a field name.', false, array());
38
-        $this->registerArgument('selection', 'int', 'A possible selection defined in the BE and stored in the database.', false, 0);
39
-        $this->registerArgument('ignoreEnableFields', 'bool', 'Whether to ignore enable fields or not (AKA hidden, deleted, starttime, ...).', false, false);
40
-        $this->registerArgument('aliases', 'array', 'Attribute "matches" does not support certain character such as "." in field name. Use this to create aliases.', false, array());
41
-    }
42
-
43
-    /**
44
-     * Generate a signature to be used for storing the result set.
45
-     *
46
-     * @param string $dataType
47
-     * @param array $matches
48
-     * @param array $orderings
49
-     * @param $limit
50
-     * @param $offset
51
-     * @return string
52
-     */
53
-    protected function getQuerySignature($dataType, array $matches, array $orderings, $limit, $offset)
54
-    {
55
-        $serializedMatches = serialize($matches);
56
-        $serializedOrderings = serialize($orderings);
57
-        return md5($dataType . $serializedMatches . $serializedOrderings . $limit . $offset);
58
-    }
59
-
60
-    /**
61
-     * Returns a matcher object.
62
-     *
63
-     * @param string $dataType
64
-     * @param array $matches
65
-     * @return Matcher
66
-     * @throws NotExistingClassException
67
-     * @throws \InvalidArgumentException
68
-     */
69
-    protected function getMatcher($dataType, $matches = array())
70
-    {
71
-
72
-        /** @var $matcher Matcher */
73
-        $matcher = GeneralUtility::makeInstance(Matcher::class, [], $dataType);
74
-
75
-        // @todo implement advanced selection parsing {or: {usergroup.title: {like: foo}}, {tstamp: {greaterThan: 1234}}}
76
-        foreach ($matches as $fieldNameAndPath => $value) {
77
-
78
-            // CSV values should be considered as "in" operator in Query, otherwise "equals".
79
-            $explodedValues = GeneralUtility::trimExplode(',', $value, true);
80
-
81
-            // The matching value contains a "1,2" as example
82
-            if (count($explodedValues) > 1) {
83
-
84
-                $resolvedDataType = $this->getFieldPathResolver()->getDataType($fieldNameAndPath, $dataType);
85
-                $resolvedFieldName = $this->getFieldPathResolver()->stripFieldPath($fieldNameAndPath, $dataType);
86
-
87
-                // "equals" if in presence of a relation.
88
-                // "in" if not a relation.
89
-                if (Tca::table($resolvedDataType)->field($resolvedFieldName)->hasRelation()) {
90
-                    foreach ($explodedValues as $explodedValue) {
91
-                        $matcher->equals($fieldNameAndPath, $explodedValue);
92
-                    }
93
-                } else {
94
-                    $matcher->in($fieldNameAndPath, $explodedValues);
95
-                }
96
-            } else {
97
-                $matcher->equals($fieldNameAndPath, $explodedValues[0]);
98
-            }
99
-        }
100
-
101
-        // Trigger signal for post processing Matcher Object.
102
-        $this->emitPostProcessMatcherObjectSignal($matcher->getDataType(), $matcher);
103
-
104
-        return $matcher;
105
-    }
106
-
107
-    /**
108
-     * Replace possible aliases.
109
-     *
110
-     * @param array $values
111
-     * @return array
112
-     */
113
-    protected function replacesAliases(array $values)
114
-    {
115
-
116
-        $aliases = $this->arguments['aliases'];
117
-
118
-        foreach ($aliases as $aliasName => $aliasValue) {
119
-            if (isset($values[$aliasName])) {
120
-                $values[$aliasValue] = $values[$aliasName];
121
-                unset($values[$aliasName]); // remove the alias.
122
-            }
123
-        }
124
-
125
-        return $values;
126
-    }
127
-
128
-    /**
129
-     * Returns an order object.
130
-     *
131
-     * @param string $dataType
132
-     * @param array $order
133
-     * @return Order
134
-     */
135
-    public function getOrder($dataType, array $order = array())
136
-    {
137
-        // Default orderings in case order is empty.
138
-        if (empty($order)) {
139
-            $order = Tca::table($dataType)->getDefaultOrderings();
140
-        }
141
-
142
-        $order = GeneralUtility::makeInstance(Order::class, $order);
143
-
144
-        // Trigger signal for post processing Order Object.
145
-        $this->emitPostProcessOrderObjectSignal($dataType, $order);
146
-
147
-        return $order;
148
-    }
149
-
150
-    /**
151
-     * @return ResultSetStorage
152
-     */
153
-    public function getResultSetStorage()
154
-    {
155
-        return GeneralUtility::makeInstance(ResultSetStorage::class);
156
-    }
157
-
158
-    /**
159
-     * Signal that is called for post-processing a "order" object.
160
-     *
161
-     * @param string $dataType
162
-     * @param Order $order
163
-     */
164
-    protected function emitPostProcessOrderObjectSignal($dataType, Order $order)
165
-    {
166
-        $this->getSignalSlotDispatcher()->dispatch('Fab\Vidi\ViewHelper\Content\AbstractContentViewHelper', 'postProcessOrderObject', array($order, $dataType));
167
-    }
168
-
169
-    /**
170
-     * Signal that is called for post-processing a "matcher" object.
171
-     *
172
-     * @param string $dataType
173
-     * @param Matcher $matcher
174
-     */
175
-    protected function emitPostProcessMatcherObjectSignal($dataType, Matcher $matcher)
176
-    {
177
-        $this->getSignalSlotDispatcher()->dispatch('Fab\Vidi\ViewHelper\Content\AbstractContentViewHelper', 'postProcessMatcherObject', array($matcher, $dataType));
178
-    }
179
-
180
-    /**
181
-     * Signal that is called for post-processing a "limit".
182
-     *
183
-     * @param string $dataType
184
-     * @param int $limit
185
-     */
186
-    protected function emitPostProcessLimitSignal($dataType, $limit)
187
-    {
188
-        $this->getSignalSlotDispatcher()->dispatch('Fab\Vidi\ViewHelper\Content\AbstractContentViewHelper', 'postProcessLimit', array($limit, $dataType));
189
-    }
190
-
191
-    /**
192
-     * Signal that is called for post-processing a "offset".
193
-     *
194
-     * @param string $dataType
195
-     * @param int $offset
196
-     */
197
-    protected function emitPostProcessOffsetSignal($dataType, $offset)
198
-    {
199
-        $this->getSignalSlotDispatcher()->dispatch('Fab\Vidi\ViewHelper\Content\AbstractContentViewHelper', 'postProcessLimit', array($offset, $dataType));
200
-    }
201
-
202
-    /**
203
-     * Get the SignalSlot dispatcher
204
-     *
205
-     * @return Dispatcher
206
-     */
207
-    protected function getSignalSlotDispatcher()
208
-    {
209
-        return GeneralUtility::makeInstance(Dispatcher::class);
210
-    }
211
-
212
-    /**
213
-     * @param $ignoreEnableFields
214
-     * @return QuerySettingsInterface
215
-     */
216
-    protected function getDefaultQuerySettings($ignoreEnableFields)
217
-    {
218
-        /** @var Typo3QuerySettings $defaultQuerySettings */
219
-        $defaultQuerySettings = GeneralUtility::makeInstance(Typo3QuerySettings::class);
220
-        $defaultQuerySettings->setIgnoreEnableFields($ignoreEnableFields);
221
-        return $defaultQuerySettings;
222
-    }
223
-
224
-    /**
225
-     * @return FieldPathResolver
226
-     */
227
-    protected function getFieldPathResolver()
228
-    {
229
-        return GeneralUtility::makeInstance(FieldPathResolver::class);
230
-    }
30
+	/**
31
+	 * @return void
32
+	 * @throws Exception
33
+	 */
34
+	public function initializeArguments()
35
+	{
36
+		$this->registerArgument('type', 'string', 'Corresponds to the type of data to be fetched. It will basically be a table name e.g. fe_users.', false, '');
37
+		$this->registerArgument('matches', 'array', 'Key / value array to be used as filter. The key corresponds to a field name.', false, array());
38
+		$this->registerArgument('selection', 'int', 'A possible selection defined in the BE and stored in the database.', false, 0);
39
+		$this->registerArgument('ignoreEnableFields', 'bool', 'Whether to ignore enable fields or not (AKA hidden, deleted, starttime, ...).', false, false);
40
+		$this->registerArgument('aliases', 'array', 'Attribute "matches" does not support certain character such as "." in field name. Use this to create aliases.', false, array());
41
+	}
42
+
43
+	/**
44
+	 * Generate a signature to be used for storing the result set.
45
+	 *
46
+	 * @param string $dataType
47
+	 * @param array $matches
48
+	 * @param array $orderings
49
+	 * @param $limit
50
+	 * @param $offset
51
+	 * @return string
52
+	 */
53
+	protected function getQuerySignature($dataType, array $matches, array $orderings, $limit, $offset)
54
+	{
55
+		$serializedMatches = serialize($matches);
56
+		$serializedOrderings = serialize($orderings);
57
+		return md5($dataType . $serializedMatches . $serializedOrderings . $limit . $offset);
58
+	}
59
+
60
+	/**
61
+	 * Returns a matcher object.
62
+	 *
63
+	 * @param string $dataType
64
+	 * @param array $matches
65
+	 * @return Matcher
66
+	 * @throws NotExistingClassException
67
+	 * @throws \InvalidArgumentException
68
+	 */
69
+	protected function getMatcher($dataType, $matches = array())
70
+	{
71
+
72
+		/** @var $matcher Matcher */
73
+		$matcher = GeneralUtility::makeInstance(Matcher::class, [], $dataType);
74
+
75
+		// @todo implement advanced selection parsing {or: {usergroup.title: {like: foo}}, {tstamp: {greaterThan: 1234}}}
76
+		foreach ($matches as $fieldNameAndPath => $value) {
77
+
78
+			// CSV values should be considered as "in" operator in Query, otherwise "equals".
79
+			$explodedValues = GeneralUtility::trimExplode(',', $value, true);
80
+
81
+			// The matching value contains a "1,2" as example
82
+			if (count($explodedValues) > 1) {
83
+
84
+				$resolvedDataType = $this->getFieldPathResolver()->getDataType($fieldNameAndPath, $dataType);
85
+				$resolvedFieldName = $this->getFieldPathResolver()->stripFieldPath($fieldNameAndPath, $dataType);
86
+
87
+				// "equals" if in presence of a relation.
88
+				// "in" if not a relation.
89
+				if (Tca::table($resolvedDataType)->field($resolvedFieldName)->hasRelation()) {
90
+					foreach ($explodedValues as $explodedValue) {
91
+						$matcher->equals($fieldNameAndPath, $explodedValue);
92
+					}
93
+				} else {
94
+					$matcher->in($fieldNameAndPath, $explodedValues);
95
+				}
96
+			} else {
97
+				$matcher->equals($fieldNameAndPath, $explodedValues[0]);
98
+			}
99
+		}
100
+
101
+		// Trigger signal for post processing Matcher Object.
102
+		$this->emitPostProcessMatcherObjectSignal($matcher->getDataType(), $matcher);
103
+
104
+		return $matcher;
105
+	}
106
+
107
+	/**
108
+	 * Replace possible aliases.
109
+	 *
110
+	 * @param array $values
111
+	 * @return array
112
+	 */
113
+	protected function replacesAliases(array $values)
114
+	{
115
+
116
+		$aliases = $this->arguments['aliases'];
117
+
118
+		foreach ($aliases as $aliasName => $aliasValue) {
119
+			if (isset($values[$aliasName])) {
120
+				$values[$aliasValue] = $values[$aliasName];
121
+				unset($values[$aliasName]); // remove the alias.
122
+			}
123
+		}
124
+
125
+		return $values;
126
+	}
127
+
128
+	/**
129
+	 * Returns an order object.
130
+	 *
131
+	 * @param string $dataType
132
+	 * @param array $order
133
+	 * @return Order
134
+	 */
135
+	public function getOrder($dataType, array $order = array())
136
+	{
137
+		// Default orderings in case order is empty.
138
+		if (empty($order)) {
139
+			$order = Tca::table($dataType)->getDefaultOrderings();
140
+		}
141
+
142
+		$order = GeneralUtility::makeInstance(Order::class, $order);
143
+
144
+		// Trigger signal for post processing Order Object.
145
+		$this->emitPostProcessOrderObjectSignal($dataType, $order);
146
+
147
+		return $order;
148
+	}
149
+
150
+	/**
151
+	 * @return ResultSetStorage
152
+	 */
153
+	public function getResultSetStorage()
154
+	{
155
+		return GeneralUtility::makeInstance(ResultSetStorage::class);
156
+	}
157
+
158
+	/**
159
+	 * Signal that is called for post-processing a "order" object.
160
+	 *
161
+	 * @param string $dataType
162
+	 * @param Order $order
163
+	 */
164
+	protected function emitPostProcessOrderObjectSignal($dataType, Order $order)
165
+	{
166
+		$this->getSignalSlotDispatcher()->dispatch('Fab\Vidi\ViewHelper\Content\AbstractContentViewHelper', 'postProcessOrderObject', array($order, $dataType));
167
+	}
168
+
169
+	/**
170
+	 * Signal that is called for post-processing a "matcher" object.
171
+	 *
172
+	 * @param string $dataType
173
+	 * @param Matcher $matcher
174
+	 */
175
+	protected function emitPostProcessMatcherObjectSignal($dataType, Matcher $matcher)
176
+	{
177
+		$this->getSignalSlotDispatcher()->dispatch('Fab\Vidi\ViewHelper\Content\AbstractContentViewHelper', 'postProcessMatcherObject', array($matcher, $dataType));
178
+	}
179
+
180
+	/**
181
+	 * Signal that is called for post-processing a "limit".
182
+	 *
183
+	 * @param string $dataType
184
+	 * @param int $limit
185
+	 */
186
+	protected function emitPostProcessLimitSignal($dataType, $limit)
187
+	{
188
+		$this->getSignalSlotDispatcher()->dispatch('Fab\Vidi\ViewHelper\Content\AbstractContentViewHelper', 'postProcessLimit', array($limit, $dataType));
189
+	}
190
+
191
+	/**
192
+	 * Signal that is called for post-processing a "offset".
193
+	 *
194
+	 * @param string $dataType
195
+	 * @param int $offset
196
+	 */
197
+	protected function emitPostProcessOffsetSignal($dataType, $offset)
198
+	{
199
+		$this->getSignalSlotDispatcher()->dispatch('Fab\Vidi\ViewHelper\Content\AbstractContentViewHelper', 'postProcessLimit', array($offset, $dataType));
200
+	}
201
+
202
+	/**
203
+	 * Get the SignalSlot dispatcher
204
+	 *
205
+	 * @return Dispatcher
206
+	 */
207
+	protected function getSignalSlotDispatcher()
208
+	{
209
+		return GeneralUtility::makeInstance(Dispatcher::class);
210
+	}
211
+
212
+	/**
213
+	 * @param $ignoreEnableFields
214
+	 * @return QuerySettingsInterface
215
+	 */
216
+	protected function getDefaultQuerySettings($ignoreEnableFields)
217
+	{
218
+		/** @var Typo3QuerySettings $defaultQuerySettings */
219
+		$defaultQuerySettings = GeneralUtility::makeInstance(Typo3QuerySettings::class);
220
+		$defaultQuerySettings->setIgnoreEnableFields($ignoreEnableFields);
221
+		return $defaultQuerySettings;
222
+	}
223
+
224
+	/**
225
+	 * @return FieldPathResolver
226
+	 */
227
+	protected function getFieldPathResolver()
228
+	{
229
+		return GeneralUtility::makeInstance(FieldPathResolver::class);
230
+	}
231 231
 
232 232
 }
Please login to merge, or discard this patch.
Classes/ViewHelpers/Content/FindViewHelper.php 1 patch
Indentation   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -19,70 +19,70 @@
 block discarded – undo
19 19
 class FindViewHelper extends AbstractContentViewHelper
20 20
 {
21 21
 
22
-    /**
23
-     * @return void
24
-     * @throws Exception
25
-     */
26
-    public function initializeArguments()
27
-    {
28
-        parent::initializeArguments();
29
-
30
-        $this->registerArgument('orderings', 'array', 'Key / value array to be used for ordering. The key corresponds to a field name. The value can be "DESC" or "ASC".', false, array());
31
-        $this->registerArgument('limit', 'int', 'Limit the number of records being fetched.', false, 0);
32
-        $this->registerArgument('offset', 'int', 'Where to start the list of records.', false, 0);
33
-    }
34
-
35
-    /**
36
-     * Fetch and returns a list of content objects.
37
-     *
38
-     * @return array
39
-     * @throws \BadMethodCallException
40
-     */
41
-    public function render()
42
-    {
43
-        $selectionIdentifier = (int)$this->arguments['selection'];
44
-
45
-        if ($selectionIdentifier > 0) {
46
-
47
-            /** @var SelectionRepository $selectionRepository */
48
-            $selectionRepository = GeneralUtility::makeInstance(SelectionRepository::class);
49
-
50
-            /** @var Selection $selection */
51
-            $selection = $selectionRepository->findByUid($selectionIdentifier);
52
-            $matches = json_decode($selection->getQuery(), true);
53
-            $dataType = $selection->getDataType();
54
-        } else {
55
-            $dataType = $this->arguments['type'];
56
-            if (!empty($this->arguments['dataType'])) {
57
-                print 'Sorry to be so rude! There is something to change in the View Helper "v:find". Please replace attribute "dataType" by "type". This is a shorter syntax...';
58
-                exit();
59
-            }
60
-            $matches = $this->replacesAliases($this->arguments['matches']);
61
-        }
62
-
63
-        $orderings = $this->replacesAliases($this->arguments['orderings']);
64
-        $limit = $this->arguments['limit'];
65
-        $offset = $this->arguments['offset'];
66
-        $ignoreEnableFields = $this->arguments['ignoreEnableFields'];
67
-
68
-        $querySignature = $this->getQuerySignature($dataType, $matches, $orderings, $limit, $offset);
69
-
70
-        $resultSet = $this->getResultSetStorage()->get($querySignature);
71
-        if (!$resultSet) {
72
-            $matcher = $this->getMatcher($dataType, $matches);
73
-            $orderings = $this->getOrder($dataType, $orderings);
74
-
75
-            $this->emitPostProcessLimitSignal($dataType, $limit);
76
-            $this->emitPostProcessOffsetSignal($dataType, $offset);
77
-
78
-            $contentRepository = ContentRepositoryFactory::getInstance($dataType);
79
-            $contentRepository->setDefaultQuerySettings($this->getDefaultQuerySettings($ignoreEnableFields));
80
-
81
-            $resultSet = $contentRepository->findBy($matcher, $orderings, $limit, $offset);
82
-            $this->getResultSetStorage()->set($querySignature, $resultSet); // store the result set for performance sake.
83
-        }
84
-
85
-        return $resultSet;
86
-    }
22
+	/**
23
+	 * @return void
24
+	 * @throws Exception
25
+	 */
26
+	public function initializeArguments()
27
+	{
28
+		parent::initializeArguments();
29
+
30
+		$this->registerArgument('orderings', 'array', 'Key / value array to be used for ordering. The key corresponds to a field name. The value can be "DESC" or "ASC".', false, array());
31
+		$this->registerArgument('limit', 'int', 'Limit the number of records being fetched.', false, 0);
32
+		$this->registerArgument('offset', 'int', 'Where to start the list of records.', false, 0);
33
+	}
34
+
35
+	/**
36
+	 * Fetch and returns a list of content objects.
37
+	 *
38
+	 * @return array
39
+	 * @throws \BadMethodCallException
40
+	 */
41
+	public function render()
42
+	{
43
+		$selectionIdentifier = (int)$this->arguments['selection'];
44
+
45
+		if ($selectionIdentifier > 0) {
46
+
47
+			/** @var SelectionRepository $selectionRepository */
48
+			$selectionRepository = GeneralUtility::makeInstance(SelectionRepository::class);
49
+
50
+			/** @var Selection $selection */
51
+			$selection = $selectionRepository->findByUid($selectionIdentifier);
52
+			$matches = json_decode($selection->getQuery(), true);
53
+			$dataType = $selection->getDataType();
54
+		} else {
55
+			$dataType = $this->arguments['type'];
56
+			if (!empty($this->arguments['dataType'])) {
57
+				print 'Sorry to be so rude! There is something to change in the View Helper "v:find". Please replace attribute "dataType" by "type". This is a shorter syntax...';
58
+				exit();
59
+			}
60
+			$matches = $this->replacesAliases($this->arguments['matches']);
61
+		}
62
+
63
+		$orderings = $this->replacesAliases($this->arguments['orderings']);
64
+		$limit = $this->arguments['limit'];
65
+		$offset = $this->arguments['offset'];
66
+		$ignoreEnableFields = $this->arguments['ignoreEnableFields'];
67
+
68
+		$querySignature = $this->getQuerySignature($dataType, $matches, $orderings, $limit, $offset);
69
+
70
+		$resultSet = $this->getResultSetStorage()->get($querySignature);
71
+		if (!$resultSet) {
72
+			$matcher = $this->getMatcher($dataType, $matches);
73
+			$orderings = $this->getOrder($dataType, $orderings);
74
+
75
+			$this->emitPostProcessLimitSignal($dataType, $limit);
76
+			$this->emitPostProcessOffsetSignal($dataType, $offset);
77
+
78
+			$contentRepository = ContentRepositoryFactory::getInstance($dataType);
79
+			$contentRepository->setDefaultQuerySettings($this->getDefaultQuerySettings($ignoreEnableFields));
80
+
81
+			$resultSet = $contentRepository->findBy($matcher, $orderings, $limit, $offset);
82
+			$this->getResultSetStorage()->set($querySignature, $resultSet); // store the result set for performance sake.
83
+		}
84
+
85
+		return $resultSet;
86
+	}
87 87
 
88 88
 }
Please login to merge, or discard this patch.
Classes/ViewHelpers/Be/AdditionalAssetsViewHelper.php 1 patch
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -20,43 +20,43 @@
 block discarded – undo
20 20
 class AdditionalAssetsViewHelper extends AbstractBackendViewHelper
21 21
 {
22 22
 
23
-    /**
24
-     * Load the assets (JavaScript, CSS) for this Vidi module.
25
-     *
26
-     * @return void
27
-     * @api
28
-     */
29
-    public function render()
30
-    {
31
-        $pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
32
-        /** @var ModuleLoader $moduleLoader */
33
-        $moduleLoader = GeneralUtility::makeInstance(ModuleLoader::class);
23
+	/**
24
+	 * Load the assets (JavaScript, CSS) for this Vidi module.
25
+	 *
26
+	 * @return void
27
+	 * @api
28
+	 */
29
+	public function render()
30
+	{
31
+		$pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
32
+		/** @var ModuleLoader $moduleLoader */
33
+		$moduleLoader = GeneralUtility::makeInstance(ModuleLoader::class);
34 34
 
35
-        foreach ($moduleLoader->getAdditionalStyleSheetFiles() as $addCssFile) {
36
-            $fileNameAndPath = $this->resolvePath($addCssFile);
37
-            $pageRenderer->addCssFile($fileNameAndPath);
38
-        }
35
+		foreach ($moduleLoader->getAdditionalStyleSheetFiles() as $addCssFile) {
36
+			$fileNameAndPath = $this->resolvePath($addCssFile);
37
+			$pageRenderer->addCssFile($fileNameAndPath);
38
+		}
39 39
 
40
-        foreach ($moduleLoader->getAdditionalJavaScriptFiles() as $addJsFile) {
41
-            $fileNameAndPath = $this->resolvePath($addJsFile);
42
-            $pageRenderer->addJsFile($fileNameAndPath);
43
-        }
44
-    }
40
+		foreach ($moduleLoader->getAdditionalJavaScriptFiles() as $addJsFile) {
41
+			$fileNameAndPath = $this->resolvePath($addJsFile);
42
+			$pageRenderer->addJsFile($fileNameAndPath);
43
+		}
44
+	}
45 45
 
46
-    /**
47
-     * Resolve a resource path.
48
-     *
49
-     * @param string $uri
50
-     * @return string
51
-     */
52
-    protected function resolvePath($uri)
53
-    {
54
-        $uri = GeneralUtility::getFileAbsFileName($uri);
55
-        $uri = substr($uri, strlen(Environment::getPublicPath() . '/'));
56
-        if (ApplicationType::fromRequest($GLOBALS['TYPO3_REQUEST'])->isBackend() && $uri !== false) {
57
-            $uri = '../' . $uri;
58
-        }
59
-        return $uri;
60
-    }
46
+	/**
47
+	 * Resolve a resource path.
48
+	 *
49
+	 * @param string $uri
50
+	 * @return string
51
+	 */
52
+	protected function resolvePath($uri)
53
+	{
54
+		$uri = GeneralUtility::getFileAbsFileName($uri);
55
+		$uri = substr($uri, strlen(Environment::getPublicPath() . '/'));
56
+		if (ApplicationType::fromRequest($GLOBALS['TYPO3_REQUEST'])->isBackend() && $uri !== false) {
57
+			$uri = '../' . $uri;
58
+		}
59
+		return $uri;
60
+	}
61 61
 
62 62
 }
Please login to merge, or discard this patch.
Classes/ViewHelpers/Render/ComponentsViewHelper.php 2 patches
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -18,57 +18,57 @@
 block discarded – undo
18 18
  */
19 19
 class ComponentsViewHelper extends AbstractViewHelper
20 20
 {
21
-    /**
22
-     * @return void
23
-     */
24
-    public function initializeArguments()
25
-    {
26
-        $this->registerArgument('part', 'string', 'Template part', true);
27
-    }
21
+	/**
22
+	 * @return void
23
+	 */
24
+	public function initializeArguments()
25
+	{
26
+		$this->registerArgument('part', 'string', 'Template part', true);
27
+	}
28 28
 
29
-    /**
30
-     * Escapes special characters with their escaped counterparts as needed using PHPs strip_tags() function.
31
-     *
32
-     * @return mixed
33
-     */
34
-    public function render()
35
-    {
36
-        return static::renderStatic(
37
-            $this->arguments,
38
-            $this->buildRenderChildrenClosure(),
39
-            $this->renderingContext
40
-        );
41
-    }
29
+	/**
30
+	 * Escapes special characters with their escaped counterparts as needed using PHPs strip_tags() function.
31
+	 *
32
+	 * @return mixed
33
+	 */
34
+	public function render()
35
+	{
36
+		return static::renderStatic(
37
+			$this->arguments,
38
+			$this->buildRenderChildrenClosure(),
39
+			$this->renderingContext
40
+		);
41
+	}
42 42
 
43
-    /**
44
-     * Applies strip_tags() on the specified value.
45
-     *
46
-     * @param array $arguments
47
-     * @param \Closure $renderChildrenClosure
48
-     * @param RenderingContextInterface $renderingContext
49
-     * @return string
50
-     */
51
-    public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
52
-    {
53
-        /** @var ModuleLoader $moduleLoader */
54
-        $moduleLoader = GeneralUtility::makeInstance(ModuleLoader::class);
43
+	/**
44
+	 * Applies strip_tags() on the specified value.
45
+	 *
46
+	 * @param array $arguments
47
+	 * @param \Closure $renderChildrenClosure
48
+	 * @param RenderingContextInterface $renderingContext
49
+	 * @return string
50
+	 */
51
+	public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
52
+	{
53
+		/** @var ModuleLoader $moduleLoader */
54
+		$moduleLoader = GeneralUtility::makeInstance(ModuleLoader::class);
55 55
 
56
-        $part = $arguments['part'];
56
+		$part = $arguments['part'];
57 57
 
58
-        $getComponents = 'get' . ucfirst($part) . 'Components';
59
-        $components = $moduleLoader->$getComponents();
58
+		$getComponents = 'get' . ucfirst($part) . 'Components';
59
+		$components = $moduleLoader->$getComponents();
60 60
 
61
-        $result = '';
62
-        foreach ($components as $component) {
63
-            $viewHelper = GeneralUtility::makeInstance($component);
61
+		$result = '';
62
+		foreach ($components as $component) {
63
+			$viewHelper = GeneralUtility::makeInstance($component);
64 64
 
65
-            // Get possible arguments but remove first one.
66
-            $arguments = func_get_args();
67
-            array_shift($arguments);
68
-            $result .= call_user_func_array(array($viewHelper, 'render'), $arguments);
69
-        }
65
+			// Get possible arguments but remove first one.
66
+			$arguments = func_get_args();
67
+			array_shift($arguments);
68
+			$result .= call_user_func_array(array($viewHelper, 'render'), $arguments);
69
+		}
70 70
 
71
-        return $result;
72
-    }
71
+		return $result;
72
+	}
73 73
 
74 74
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@
 block discarded – undo
55 55
 
56 56
         $part = $arguments['part'];
57 57
 
58
-        $getComponents = 'get' . ucfirst($part) . 'Components';
58
+        $getComponents = 'get'.ucfirst($part).'Components';
59 59
         $components = $moduleLoader->$getComponents();
60 60
 
61 61
         $result = '';
Please login to merge, or discard this patch.
Classes/Configuration/TcaGridAspect.php 1 patch
Indentation   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -20,89 +20,89 @@
 block discarded – undo
20 20
 class TcaGridAspect implements TableConfigurationPostProcessingHookInterface
21 21
 {
22 22
 
23
-    /**
24
-     * Scans each data type of the TCA and add a Grid TCA if missing.
25
-     *
26
-     * @return array
27
-     */
28
-    public function processData()
29
-    {
30
-        $configuration = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get('vidi');
23
+	/**
24
+	 * Scans each data type of the TCA and add a Grid TCA if missing.
25
+	 *
26
+	 * @return array
27
+	 */
28
+	public function processData()
29
+	{
30
+		$configuration = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get('vidi');
31 31
 
32
-        $dataTypes = GeneralUtility::trimExplode(',', $configuration['data_types'], true);
32
+		$dataTypes = GeneralUtility::trimExplode(',', $configuration['data_types'], true);
33 33
 
34
-        if (ExtensionManagementUtility::isLoaded('vidi_frontend')) {
34
+		if (ExtensionManagementUtility::isLoaded('vidi_frontend')) {
35 35
 
36
-            $extendedConfiguration = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get('vidi_frontend');
37
-            $vidiFrontendContentTypes = GeneralUtility::trimExplode(',', $extendedConfiguration['content_types'], true);
38
-            $extendedDataTypes = array_merge($dataTypes, $vidiFrontendContentTypes);
39
-            $dataTypes = array_unique($extendedDataTypes);
40
-        }
36
+			$extendedConfiguration = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get('vidi_frontend');
37
+			$vidiFrontendContentTypes = GeneralUtility::trimExplode(',', $extendedConfiguration['content_types'], true);
38
+			$extendedDataTypes = array_merge($dataTypes, $vidiFrontendContentTypes);
39
+			$dataTypes = array_unique($extendedDataTypes);
40
+		}
41 41
 
42
-        foreach ($dataTypes as $dataType) {
43
-            $this->ensureMinimumTcaForGrid($dataType);
44
-        }
42
+		foreach ($dataTypes as $dataType) {
43
+			$this->ensureMinimumTcaForGrid($dataType);
44
+		}
45 45
 
46
-        return array($GLOBALS['TCA']);
47
-    }
46
+		return array($GLOBALS['TCA']);
47
+	}
48 48
 
49
-    /**
50
-     * @param string $dataType
51
-     */
52
-    protected function ensureMinimumTcaForGrid($dataType)
53
-    {
54
-        $labelField = $this->getLabelField($dataType);
55
-        if (empty($GLOBALS['TCA'][$dataType]['grid'])) {
56
-            $GLOBALS['TCA'][$dataType]['grid'] = [];
57
-        }
49
+	/**
50
+	 * @param string $dataType
51
+	 */
52
+	protected function ensureMinimumTcaForGrid($dataType)
53
+	{
54
+		$labelField = $this->getLabelField($dataType);
55
+		if (empty($GLOBALS['TCA'][$dataType]['grid'])) {
56
+			$GLOBALS['TCA'][$dataType]['grid'] = [];
57
+		}
58 58
 
59
-        if (empty($GLOBALS['TCA'][$dataType]['grid']['facets'])) {
60
-            $GLOBALS['TCA'][$dataType]['grid']['facets'] = [
61
-                'uid',
62
-                $labelField,
63
-            ];
64
-        }
59
+		if (empty($GLOBALS['TCA'][$dataType]['grid']['facets'])) {
60
+			$GLOBALS['TCA'][$dataType]['grid']['facets'] = [
61
+				'uid',
62
+				$labelField,
63
+			];
64
+		}
65 65
 
66
-        if (empty($GLOBALS['TCA'][$dataType]['grid']['columns'])) {
67
-            $GLOBALS['TCA'][$dataType]['grid']['columns'] = [
68
-                '__checkbox' => [
69
-                    'renderer' => CheckBoxRenderer::class,
70
-                ],
71
-                'uid' => [
72
-                    'visible' => false,
73
-                    'label' => '',
74
-                    'width' => '5px',
75
-                ],
76
-                $labelField => [
77
-                    'editable' => true,
78
-                ],
79
-                '__buttons' => [
80
-                    'renderer' => ButtonGroupRenderer::class,
81
-                ],
82
-            ];
83
-        }
84
-    }
66
+		if (empty($GLOBALS['TCA'][$dataType]['grid']['columns'])) {
67
+			$GLOBALS['TCA'][$dataType]['grid']['columns'] = [
68
+				'__checkbox' => [
69
+					'renderer' => CheckBoxRenderer::class,
70
+				],
71
+				'uid' => [
72
+					'visible' => false,
73
+					'label' => '',
74
+					'width' => '5px',
75
+				],
76
+				$labelField => [
77
+					'editable' => true,
78
+				],
79
+				'__buttons' => [
80
+					'renderer' => ButtonGroupRenderer::class,
81
+				],
82
+			];
83
+		}
84
+	}
85 85
 
86
-    /**
87
-     * Get the label name of table name.
88
-     *
89
-     * @param string $dataType
90
-     * @return bool
91
-     */
92
-    protected function getLabelField($dataType)
93
-    {
94
-        return $GLOBALS['TCA'][$dataType]['ctrl']['label'];
95
-    }
86
+	/**
87
+	 * Get the label name of table name.
88
+	 *
89
+	 * @param string $dataType
90
+	 * @return bool
91
+	 */
92
+	protected function getLabelField($dataType)
93
+	{
94
+		return $GLOBALS['TCA'][$dataType]['ctrl']['label'];
95
+	}
96 96
 
97
-    /**
98
-     * Tell whether the table has a label field.
99
-     *
100
-     * @param string $dataType
101
-     * @return bool
102
-     */
103
-    protected function hasLabelField($dataType)
104
-    {
105
-        return isset($GLOBALS['TCA'][$dataType]['ctrl']['label']);
106
-    }
97
+	/**
98
+	 * Tell whether the table has a label field.
99
+	 *
100
+	 * @param string $dataType
101
+	 * @return bool
102
+	 */
103
+	protected function hasLabelField($dataType)
104
+	{
105
+		return isset($GLOBALS['TCA'][$dataType]['ctrl']['label']);
106
+	}
107 107
 
108 108
 }
Please login to merge, or discard this patch.
Classes/Tca/Tca.php 1 patch
Indentation   +129 added lines, -129 removed lines patch added patch discarded remove patch
@@ -24,134 +24,134 @@
 block discarded – undo
24 24
 class Tca implements SingletonInterface, TcaServiceInterface
25 25
 {
26 26
 
27
-    /**
28
-     * Fields that are considered as system.
29
-     *
30
-     * @var array
31
-     */
32
-    static protected $systemFields = array(
33
-        'uid',
34
-        'pid',
35
-        'tstamp',
36
-        'crdate',
37
-        'deleted',
38
-        'hidden',
39
-        'sys_language_uid',
40
-        'l18n_parent',
41
-        'l18n_diffsource',
42
-        't3ver_oid',
43
-        't3ver_id',
44
-        't3ver_wsid',
45
-        't3ver_label',
46
-        't3ver_state',
47
-        't3ver_stage',
48
-        't3ver_count',
49
-        't3ver_tstamp',
50
-        't3_origuid',
51
-    );
52
-
53
-    /**
54
-     * @var array
55
-     */
56
-    static protected $instances;
57
-
58
-    /**
59
-     * Returns a class instance of a corresponding TCA service.
60
-     * If the class instance does not exist, create one.
61
-     *
62
-     * @throws NotExistingClassException
63
-     * @param string $dataType
64
-     * @param string $serviceType
65
-     * @return TcaServiceInterface
66
-     * @throws InvalidKeyInArrayException
67
-     * @throws \InvalidArgumentException
68
-     */
69
-    static protected function getService($dataType, $serviceType)
70
-    {
71
-        if (ApplicationType::fromRequest($GLOBALS['TYPO3_REQUEST'])->isBackend() && empty($dataType)) {
72
-
73
-            /** @var ModuleLoader $moduleLoader */
74
-            $moduleLoader = GeneralUtility::makeInstance(ModuleLoader::class);
75
-            $dataType = $moduleLoader->getDataType();
76
-        }
77
-
78
-        if (empty(self::$instances[$dataType][$serviceType])) {
79
-            $className = sprintf('Fab\Vidi\Tca\%sService', ucfirst($serviceType));
80
-
81
-            // Signal to pre-process the TCA of the given $dataType.
82
-            self::emitPreProcessTcaSignal($dataType, $serviceType);
83
-
84
-            $instance = GeneralUtility::makeInstance($className, $dataType, $serviceType);
85
-            self::$instances[$dataType][$serviceType] = $instance;
86
-        }
87
-        return self::$instances[$dataType][$serviceType];
88
-    }
89
-
90
-    /**
91
-     * Returns a "grid" service instance.
92
-     *
93
-     * @param string|Content $tableNameOrContentObject
94
-     * @return GridService
95
-     * @throws NotExistingClassException
96
-     */
97
-    static public function grid($tableNameOrContentObject = '')
98
-    {
99
-        $tableName = $tableNameOrContentObject instanceof Content ? $tableNameOrContentObject->getDataType() : $tableNameOrContentObject;
100
-        return self::getService($tableName, self::TYPE_GRID);
101
-    }
102
-
103
-    /**
104
-     * Returns a "table" service instance ("ctrl" part of the TCA).
105
-     *
106
-     * @param string|Content $tableNameOrContentObject
107
-     * @return TableService
108
-     * @throws NotExistingClassException
109
-     */
110
-    static public function table($tableNameOrContentObject = '')
111
-    {
112
-        $tableName = $tableNameOrContentObject instanceof Content ? $tableNameOrContentObject->getDataType() : $tableNameOrContentObject;
113
-        return self::getService($tableName, self::TYPE_TABLE);
114
-    }
115
-
116
-    /**
117
-     * @return array
118
-     */
119
-    public static function getInstanceStorage()
120
-    {
121
-        return self::$instances;
122
-    }
123
-
124
-    /**
125
-     * @return array
126
-     */
127
-    public static function getSystemFields()
128
-    {
129
-        return self::$systemFields;
130
-    }
131
-
132
-    /**
133
-     * Signal that is called after the content repository for a content type has been instantiated.
134
-     *
135
-     * @param string $dataType
136
-     * @param string $serviceType
137
-     * @throws InvalidSlotException
138
-     * @throws InvalidSlotReturnException
139
-     * @throws \InvalidArgumentException
140
-     */
141
-    static protected function emitPreProcessTcaSignal($dataType, $serviceType)
142
-    {
143
-        self::getSignalSlotDispatcher()->dispatch(Tca::class, 'preProcessTca', array($dataType, $serviceType));
144
-    }
145
-
146
-    /**
147
-     * Get the SignalSlot dispatcher
148
-     *
149
-     * @return Dispatcher
150
-     * @throws \InvalidArgumentException
151
-     */
152
-    static protected function getSignalSlotDispatcher()
153
-    {
154
-        return GeneralUtility::makeInstance(Dispatcher::class);
155
-    }
27
+	/**
28
+	 * Fields that are considered as system.
29
+	 *
30
+	 * @var array
31
+	 */
32
+	static protected $systemFields = array(
33
+		'uid',
34
+		'pid',
35
+		'tstamp',
36
+		'crdate',
37
+		'deleted',
38
+		'hidden',
39
+		'sys_language_uid',
40
+		'l18n_parent',
41
+		'l18n_diffsource',
42
+		't3ver_oid',
43
+		't3ver_id',
44
+		't3ver_wsid',
45
+		't3ver_label',
46
+		't3ver_state',
47
+		't3ver_stage',
48
+		't3ver_count',
49
+		't3ver_tstamp',
50
+		't3_origuid',
51
+	);
52
+
53
+	/**
54
+	 * @var array
55
+	 */
56
+	static protected $instances;
57
+
58
+	/**
59
+	 * Returns a class instance of a corresponding TCA service.
60
+	 * If the class instance does not exist, create one.
61
+	 *
62
+	 * @throws NotExistingClassException
63
+	 * @param string $dataType
64
+	 * @param string $serviceType
65
+	 * @return TcaServiceInterface
66
+	 * @throws InvalidKeyInArrayException
67
+	 * @throws \InvalidArgumentException
68
+	 */
69
+	static protected function getService($dataType, $serviceType)
70
+	{
71
+		if (ApplicationType::fromRequest($GLOBALS['TYPO3_REQUEST'])->isBackend() && empty($dataType)) {
72
+
73
+			/** @var ModuleLoader $moduleLoader */
74
+			$moduleLoader = GeneralUtility::makeInstance(ModuleLoader::class);
75
+			$dataType = $moduleLoader->getDataType();
76
+		}
77
+
78
+		if (empty(self::$instances[$dataType][$serviceType])) {
79
+			$className = sprintf('Fab\Vidi\Tca\%sService', ucfirst($serviceType));
80
+
81
+			// Signal to pre-process the TCA of the given $dataType.
82
+			self::emitPreProcessTcaSignal($dataType, $serviceType);
83
+
84
+			$instance = GeneralUtility::makeInstance($className, $dataType, $serviceType);
85
+			self::$instances[$dataType][$serviceType] = $instance;
86
+		}
87
+		return self::$instances[$dataType][$serviceType];
88
+	}
89
+
90
+	/**
91
+	 * Returns a "grid" service instance.
92
+	 *
93
+	 * @param string|Content $tableNameOrContentObject
94
+	 * @return GridService
95
+	 * @throws NotExistingClassException
96
+	 */
97
+	static public function grid($tableNameOrContentObject = '')
98
+	{
99
+		$tableName = $tableNameOrContentObject instanceof Content ? $tableNameOrContentObject->getDataType() : $tableNameOrContentObject;
100
+		return self::getService($tableName, self::TYPE_GRID);
101
+	}
102
+
103
+	/**
104
+	 * Returns a "table" service instance ("ctrl" part of the TCA).
105
+	 *
106
+	 * @param string|Content $tableNameOrContentObject
107
+	 * @return TableService
108
+	 * @throws NotExistingClassException
109
+	 */
110
+	static public function table($tableNameOrContentObject = '')
111
+	{
112
+		$tableName = $tableNameOrContentObject instanceof Content ? $tableNameOrContentObject->getDataType() : $tableNameOrContentObject;
113
+		return self::getService($tableName, self::TYPE_TABLE);
114
+	}
115
+
116
+	/**
117
+	 * @return array
118
+	 */
119
+	public static function getInstanceStorage()
120
+	{
121
+		return self::$instances;
122
+	}
123
+
124
+	/**
125
+	 * @return array
126
+	 */
127
+	public static function getSystemFields()
128
+	{
129
+		return self::$systemFields;
130
+	}
131
+
132
+	/**
133
+	 * Signal that is called after the content repository for a content type has been instantiated.
134
+	 *
135
+	 * @param string $dataType
136
+	 * @param string $serviceType
137
+	 * @throws InvalidSlotException
138
+	 * @throws InvalidSlotReturnException
139
+	 * @throws \InvalidArgumentException
140
+	 */
141
+	static protected function emitPreProcessTcaSignal($dataType, $serviceType)
142
+	{
143
+		self::getSignalSlotDispatcher()->dispatch(Tca::class, 'preProcessTca', array($dataType, $serviceType));
144
+	}
145
+
146
+	/**
147
+	 * Get the SignalSlot dispatcher
148
+	 *
149
+	 * @return Dispatcher
150
+	 * @throws \InvalidArgumentException
151
+	 */
152
+	static protected function getSignalSlotDispatcher()
153
+	{
154
+		return GeneralUtility::makeInstance(Dispatcher::class);
155
+	}
156 156
 
157 157
 }
Please login to merge, or discard this patch.
ext_tables.php 2 patches
Indentation   +165 added lines, -165 removed lines patch added patch discarded remove patch
@@ -19,169 +19,169 @@
 block discarded – undo
19 19
 
20 20
 call_user_func(function () {
21 21
 
22
-    // Check from Vidi configuration what default module should be loaded.
23
-    // Make sure the class exists to avoid a Runtime Error
24
-
25
-    // Add content main module before 'user'
26
-    if (!isset($GLOBALS['TBE_MODULES']['content'])) {
27
-
28
-        // Position module "content" after module "user" manually. No API is available for that, it seems...
29
-        $modules = [];
30
-        foreach ($GLOBALS['TBE_MODULES'] as $key => $val) {
31
-            if ($key === 'user') {
32
-                $modules['content'] = '';
33
-            }
34
-            $modules[$key] = $val;
35
-        }
36
-        $GLOBALS['TBE_MODULES'] = $modules;
37
-
38
-        // Register "data management" module.
39
-        ExtensionManagementUtility::addModule(
40
-            'content',
41
-            '',
42
-            '',
43
-            '',
44
-            [
45
-                'name' => 'content',
46
-                'access' => 'user,group',
47
-                'labels' => [
48
-                    'll_ref' => 'LLL:EXT:vidi/Resources/Private/Language/content_module.xlf',
49
-                ],
50
-            ]
51
-        );
52
-    }
53
-
54
-    $configuration = GeneralUtility::makeInstance(
55
-        ExtensionConfiguration::class
56
-    )->get('vidi');
57
-
58
-    $pids = GeneralUtility::trimExplode(',', $configuration['default_pid'], true);
59
-    $defaultPid = array_shift($pids);
60
-    $defaultPids = [];
61
-    foreach ($pids as $dataTypeAndPid) {
62
-        $parts = GeneralUtility::trimExplode(':', $dataTypeAndPid);
63
-        if (count($parts) === 2) {
64
-            $defaultPids[$parts[0]] = $parts[1];
65
-        }
66
-    }
67
-
68
-    // Loop around the data types and register them to be displayed within a BE module.
69
-    if ($configuration['data_types']) {
70
-
71
-        $dataTypes = GeneralUtility::trimExplode(',', $configuration['data_types'], true);
72
-        foreach ($dataTypes as $dataType) {
73
-
74
-
75
-            /** @var ModuleLoader $moduleLoader */
76
-            $moduleLoader = GeneralUtility::makeInstance(ModuleLoader::class, $dataType);
77
-
78
-            // Special case already defined in Vidi.
79
-            if ($dataType === 'fe_users') {
80
-                $languageFile = 'LLL:EXT:vidi/Resources/Private/Language/fe_users.xlf';
81
-                $icon = 'EXT:vidi/Resources/Public/Images/fe_users.svg';
82
-            } elseif ($dataType === 'fe_groups') {
83
-                $languageFile = 'LLL:EXT:vidi/Resources/Private/Language/fe_groups.xlf';
84
-                $icon = 'EXT:vidi/Resources/Public/Images/fe_groups.svg';
85
-            } else {
86
-                /** @var LanguageFileGenerator $languageService */
87
-                $languageService = GeneralUtility::makeInstance(LanguageFileGenerator::class);
88
-                $languageFile = $languageService->generate($dataType);
89
-                $icon = '';
90
-            }
91
-
92
-            $pid = $defaultPids[$dataType] ?? $defaultPid;
93
-
94
-            /** @var ModuleLoader $moduleLoader */
95
-            $moduleLoader->setIcon($icon)
96
-                ->setModuleLanguageFile($languageFile)
97
-                ->setDefaultPid($pid)
98
-                ->register();
99
-        }
100
-    }
101
-
102
-    // Possible Static TS loading
103
-    if (true === isset($configuration['autoload_typoscript']) && false === (bool)$configuration['autoload_typoscript']) {
104
-        ExtensionManagementUtility::addStaticFile('vidi', 'Configuration/TypoScript', 'Vidi: versatile and interactive display');
105
-    }
106
-
107
-    // Register List2 only if beta feature is enabled.
108
-    // @todo let see what we do with that
109
-    #if ($configuration['activate_beta_features']) {
110
-    #	$labelFile = 'LLL:EXT:vidi/Resources/Private/Language/locallang_module.xlf';
111
-    #
112
-    #	if (!$configuration['hide_module_list']) {
113
-    #		$labelFile = 'LLL:EXT:vidi/Resources/Private/Language/locallang_module_transitional.xlf';
114
-    #	}
115
-    #
116
-    #	\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerModule(
117
-    #		'vidi',
118
-    #		'web', // Make module a submodule of 'web'
119
-    #		'm1', // Submodule key
120
-    #		'after:list', // Position
121
-    #		array(
122
-    #			'Content' => 'index, list, delete, update, edit, copy, move, localize, sort, copyClipboard, moveClipboard',
123
-    #			'Tool' => 'welcome, work',
124
-    #			'Facet' => 'autoSuggest, autoSuggests',
125
-    #			'Selection' => 'edit, update, create, delete, list, show',
126
-    #			'UserPreferences' => 'save',
127
-    #			'Clipboard' => 'save, flush, show',
128
-    #		), array(
129
-    #			'access' => 'user,group',
130
-    #			'icon' => 'EXT:vidi/Resources/Public/Images/list.png',
131
-    #			'labels' => $labelFile,
132
-    #		)
133
-    #	);
134
-    #}
135
-    #if ($configuration['hide_module_list']) {
136
-    #
137
-    #	// Default User TSConfig to be added in any case.
138
-    #	TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addUserTSConfig('
139
-    #
140
-    #		# Hide the module in the BE.
141
-    #		options.hideModules.web := addToList(list)
142
-    #	');
143
-    #}
144
-
145
-    /** @var $signalSlotDispatcher \TYPO3\CMS\Extbase\SignalSlot\Dispatcher */
146
-    $signalSlotDispatcher = GeneralUtility::makeInstance(Dispatcher::class);
147
-
148
-    // Connect "processContentData" signal slot with the "ContentObjectProcessor".
149
-    $signalSlotDispatcher->connect(
150
-        'Fab\Vidi\Controller\Backend\ContentController',
151
-        'processContentData',
152
-        ContentObjectProcessor::class,
153
-        'processRelations',
154
-        true
155
-    );
156
-
157
-    // Connect "processContentData" signal with the "MarkerProcessor".
158
-    $signalSlotDispatcher->connect(
159
-        'Fab\Vidi\Controller\Backend\ContentController',
160
-        'processContentData',
161
-        MarkerProcessor::class,
162
-        'processMarkers',
163
-        true
164
-    );
165
-
166
-    // Register default Tools for Vidi.
167
-    ToolRegistry::getInstance()->register('*', ModulePreferencesTool::class);
168
-    ToolRegistry::getInstance()->register('*', RelationAnalyserTool::class);
169
-    ToolRegistry::getInstance()->register('*', ConfiguredPidTool::class);
170
-
171
-    // Add new sprite icon.
172
-    $icons = [
173
-        'go' => 'EXT:vidi/Resources/Public/Images/bullet_go.png',
174
-        'query' => 'EXT:vidi/Resources/Public/Images/drive_disk.png',
175
-    ];
176
-    /** @var IconRegistry $iconRegistry */
177
-    $iconRegistry = GeneralUtility::makeInstance(IconRegistry::class);
178
-    foreach ($icons as $key => $icon) {
179
-        $iconRegistry->registerIcon('extensions-vidi-' . $key,
180
-            BitmapIconProvider::class,
181
-            [
182
-                'source' => $icon
183
-            ]
184
-        );
185
-    }
186
-    unset($iconRegistry);
22
+	// Check from Vidi configuration what default module should be loaded.
23
+	// Make sure the class exists to avoid a Runtime Error
24
+
25
+	// Add content main module before 'user'
26
+	if (!isset($GLOBALS['TBE_MODULES']['content'])) {
27
+
28
+		// Position module "content" after module "user" manually. No API is available for that, it seems...
29
+		$modules = [];
30
+		foreach ($GLOBALS['TBE_MODULES'] as $key => $val) {
31
+			if ($key === 'user') {
32
+				$modules['content'] = '';
33
+			}
34
+			$modules[$key] = $val;
35
+		}
36
+		$GLOBALS['TBE_MODULES'] = $modules;
37
+
38
+		// Register "data management" module.
39
+		ExtensionManagementUtility::addModule(
40
+			'content',
41
+			'',
42
+			'',
43
+			'',
44
+			[
45
+				'name' => 'content',
46
+				'access' => 'user,group',
47
+				'labels' => [
48
+					'll_ref' => 'LLL:EXT:vidi/Resources/Private/Language/content_module.xlf',
49
+				],
50
+			]
51
+		);
52
+	}
53
+
54
+	$configuration = GeneralUtility::makeInstance(
55
+		ExtensionConfiguration::class
56
+	)->get('vidi');
57
+
58
+	$pids = GeneralUtility::trimExplode(',', $configuration['default_pid'], true);
59
+	$defaultPid = array_shift($pids);
60
+	$defaultPids = [];
61
+	foreach ($pids as $dataTypeAndPid) {
62
+		$parts = GeneralUtility::trimExplode(':', $dataTypeAndPid);
63
+		if (count($parts) === 2) {
64
+			$defaultPids[$parts[0]] = $parts[1];
65
+		}
66
+	}
67
+
68
+	// Loop around the data types and register them to be displayed within a BE module.
69
+	if ($configuration['data_types']) {
70
+
71
+		$dataTypes = GeneralUtility::trimExplode(',', $configuration['data_types'], true);
72
+		foreach ($dataTypes as $dataType) {
73
+
74
+
75
+			/** @var ModuleLoader $moduleLoader */
76
+			$moduleLoader = GeneralUtility::makeInstance(ModuleLoader::class, $dataType);
77
+
78
+			// Special case already defined in Vidi.
79
+			if ($dataType === 'fe_users') {
80
+				$languageFile = 'LLL:EXT:vidi/Resources/Private/Language/fe_users.xlf';
81
+				$icon = 'EXT:vidi/Resources/Public/Images/fe_users.svg';
82
+			} elseif ($dataType === 'fe_groups') {
83
+				$languageFile = 'LLL:EXT:vidi/Resources/Private/Language/fe_groups.xlf';
84
+				$icon = 'EXT:vidi/Resources/Public/Images/fe_groups.svg';
85
+			} else {
86
+				/** @var LanguageFileGenerator $languageService */
87
+				$languageService = GeneralUtility::makeInstance(LanguageFileGenerator::class);
88
+				$languageFile = $languageService->generate($dataType);
89
+				$icon = '';
90
+			}
91
+
92
+			$pid = $defaultPids[$dataType] ?? $defaultPid;
93
+
94
+			/** @var ModuleLoader $moduleLoader */
95
+			$moduleLoader->setIcon($icon)
96
+				->setModuleLanguageFile($languageFile)
97
+				->setDefaultPid($pid)
98
+				->register();
99
+		}
100
+	}
101
+
102
+	// Possible Static TS loading
103
+	if (true === isset($configuration['autoload_typoscript']) && false === (bool)$configuration['autoload_typoscript']) {
104
+		ExtensionManagementUtility::addStaticFile('vidi', 'Configuration/TypoScript', 'Vidi: versatile and interactive display');
105
+	}
106
+
107
+	// Register List2 only if beta feature is enabled.
108
+	// @todo let see what we do with that
109
+	#if ($configuration['activate_beta_features']) {
110
+	#	$labelFile = 'LLL:EXT:vidi/Resources/Private/Language/locallang_module.xlf';
111
+	#
112
+	#	if (!$configuration['hide_module_list']) {
113
+	#		$labelFile = 'LLL:EXT:vidi/Resources/Private/Language/locallang_module_transitional.xlf';
114
+	#	}
115
+	#
116
+	#	\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerModule(
117
+	#		'vidi',
118
+	#		'web', // Make module a submodule of 'web'
119
+	#		'm1', // Submodule key
120
+	#		'after:list', // Position
121
+	#		array(
122
+	#			'Content' => 'index, list, delete, update, edit, copy, move, localize, sort, copyClipboard, moveClipboard',
123
+	#			'Tool' => 'welcome, work',
124
+	#			'Facet' => 'autoSuggest, autoSuggests',
125
+	#			'Selection' => 'edit, update, create, delete, list, show',
126
+	#			'UserPreferences' => 'save',
127
+	#			'Clipboard' => 'save, flush, show',
128
+	#		), array(
129
+	#			'access' => 'user,group',
130
+	#			'icon' => 'EXT:vidi/Resources/Public/Images/list.png',
131
+	#			'labels' => $labelFile,
132
+	#		)
133
+	#	);
134
+	#}
135
+	#if ($configuration['hide_module_list']) {
136
+	#
137
+	#	// Default User TSConfig to be added in any case.
138
+	#	TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addUserTSConfig('
139
+	#
140
+	#		# Hide the module in the BE.
141
+	#		options.hideModules.web := addToList(list)
142
+	#	');
143
+	#}
144
+
145
+	/** @var $signalSlotDispatcher \TYPO3\CMS\Extbase\SignalSlot\Dispatcher */
146
+	$signalSlotDispatcher = GeneralUtility::makeInstance(Dispatcher::class);
147
+
148
+	// Connect "processContentData" signal slot with the "ContentObjectProcessor".
149
+	$signalSlotDispatcher->connect(
150
+		'Fab\Vidi\Controller\Backend\ContentController',
151
+		'processContentData',
152
+		ContentObjectProcessor::class,
153
+		'processRelations',
154
+		true
155
+	);
156
+
157
+	// Connect "processContentData" signal with the "MarkerProcessor".
158
+	$signalSlotDispatcher->connect(
159
+		'Fab\Vidi\Controller\Backend\ContentController',
160
+		'processContentData',
161
+		MarkerProcessor::class,
162
+		'processMarkers',
163
+		true
164
+	);
165
+
166
+	// Register default Tools for Vidi.
167
+	ToolRegistry::getInstance()->register('*', ModulePreferencesTool::class);
168
+	ToolRegistry::getInstance()->register('*', RelationAnalyserTool::class);
169
+	ToolRegistry::getInstance()->register('*', ConfiguredPidTool::class);
170
+
171
+	// Add new sprite icon.
172
+	$icons = [
173
+		'go' => 'EXT:vidi/Resources/Public/Images/bullet_go.png',
174
+		'query' => 'EXT:vidi/Resources/Public/Images/drive_disk.png',
175
+	];
176
+	/** @var IconRegistry $iconRegistry */
177
+	$iconRegistry = GeneralUtility::makeInstance(IconRegistry::class);
178
+	foreach ($icons as $key => $icon) {
179
+		$iconRegistry->registerIcon('extensions-vidi-' . $key,
180
+			BitmapIconProvider::class,
181
+			[
182
+				'source' => $icon
183
+			]
184
+		);
185
+	}
186
+	unset($iconRegistry);
187 187
 });
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 
18 18
 defined('TYPO3') or die();
19 19
 
20
-call_user_func(function () {
20
+call_user_func(function() {
21 21
 
22 22
     // Check from Vidi configuration what default module should be loaded.
23 23
     // Make sure the class exists to avoid a Runtime Error
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
     /** @var IconRegistry $iconRegistry */
177 177
     $iconRegistry = GeneralUtility::makeInstance(IconRegistry::class);
178 178
     foreach ($icons as $key => $icon) {
179
-        $iconRegistry->registerIcon('extensions-vidi-' . $key,
179
+        $iconRegistry->registerIcon('extensions-vidi-'.$key,
180 180
             BitmapIconProvider::class,
181 181
             [
182 182
                 'source' => $icon
Please login to merge, or discard this patch.