Completed
Push — master ( 38526a...2da125 )
by Fabien
52:09
created
Classes/Configuration/TcaGridAspect.php 1 patch
Indentation   +94 added lines, -94 removed lines patch added patch discarded remove patch
@@ -21,99 +21,99 @@
 block discarded – undo
21 21
 class TcaGridAspect implements TableConfigurationPostProcessingHookInterface
22 22
 {
23 23
 
24
-    /**
25
-     * Scans each data type of the TCA and add a Grid TCA if missing.
26
-     *
27
-     * @return array
28
-     */
29
-    public function processData()
30
-    {
31
-
32
-        /** @var ConfigurationUtility $configurationUtility */
33
-        $configurationUtility = $this->getObjectManager()->get(ConfigurationUtility::class);
34
-        $configuration = $configurationUtility->getCurrentConfiguration('vidi');
35
-
36
-        $dataTypes = GeneralUtility::trimExplode(',', $configuration['data_types']['value'], true);
37
-
38
-        if (ExtensionManagementUtility::isLoaded('vidi_frontend')) {
39
-            $extendedConfiguration = $configurationUtility->getCurrentConfiguration('vidi_frontend');
40
-            $vidiFrontendContentTypes = GeneralUtility::trimExplode(',', $extendedConfiguration['content_types']['value'], true);
41
-            $extendedDataTypes = array_merge($dataTypes, $vidiFrontendContentTypes);
42
-            $dataTypes = array_unique($extendedDataTypes);
43
-        }
44
-
45
-        foreach ($dataTypes as $dataType) {
46
-            $this->ensureMinimumTcaForGrid($dataType);
47
-        }
48
-
49
-        return array($GLOBALS['TCA']);
50
-    }
51
-
52
-    /**
53
-     * @param string $dataType
54
-     */
55
-    protected function ensureMinimumTcaForGrid($dataType)
56
-    {
57
-        $labelField = $this->getLabelField($dataType);
58
-        if (empty($GLOBALS['TCA'][$dataType]['grid'])) {
59
-            $GLOBALS['TCA'][$dataType]['grid'] = [];
60
-        }
61
-
62
-        if (empty($GLOBALS['TCA'][$dataType]['grid']['facets'])) {
63
-            $GLOBALS['TCA'][$dataType]['grid']['facets'] = [
64
-                'uid',
65
-                $labelField,
66
-            ];
67
-        }
68
-
69
-        if (empty($GLOBALS['TCA'][$dataType]['grid']['columns'])) {
70
-            $GLOBALS['TCA'][$dataType]['grid']['columns'] = [
71
-                '__checkbox' => [
72
-                    'renderer' => CheckBoxRenderer::class,
73
-                ],
74
-                'uid' => [
75
-                    'visible' => false,
76
-                    'label' => '',
77
-                    'width' => '5px',
78
-                ],
79
-                $labelField => [
80
-                    'editable' => true,
81
-                ],
82
-                '__buttons' => [
83
-                    'renderer' => ButtonGroupRenderer::class,
84
-                ],
85
-            ];
86
-        }
87
-    }
88
-
89
-    /**
90
-     * Get the label name of table name.
91
-     *
92
-     * @param string $dataType
93
-     * @return bool
94
-     */
95
-    protected function getLabelField($dataType)
96
-    {
97
-        return $GLOBALS['TCA'][$dataType]['ctrl']['label'];
98
-    }
99
-
100
-    /**
101
-     * Tell whether the table has a label field.
102
-     *
103
-     * @param string $dataType
104
-     * @return bool
105
-     */
106
-    protected function hasLabelField($dataType)
107
-    {
108
-        return isset($GLOBALS['TCA'][$dataType]['ctrl']['label']);
109
-    }
110
-
111
-    /**
112
-     * @return \TYPO3\CMS\Extbase\Object\ObjectManager
113
-     */
114
-    protected function getObjectManager()
115
-    {
116
-        return GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class);
117
-    }
24
+	/**
25
+	 * Scans each data type of the TCA and add a Grid TCA if missing.
26
+	 *
27
+	 * @return array
28
+	 */
29
+	public function processData()
30
+	{
31
+
32
+		/** @var ConfigurationUtility $configurationUtility */
33
+		$configurationUtility = $this->getObjectManager()->get(ConfigurationUtility::class);
34
+		$configuration = $configurationUtility->getCurrentConfiguration('vidi');
35
+
36
+		$dataTypes = GeneralUtility::trimExplode(',', $configuration['data_types']['value'], true);
37
+
38
+		if (ExtensionManagementUtility::isLoaded('vidi_frontend')) {
39
+			$extendedConfiguration = $configurationUtility->getCurrentConfiguration('vidi_frontend');
40
+			$vidiFrontendContentTypes = GeneralUtility::trimExplode(',', $extendedConfiguration['content_types']['value'], true);
41
+			$extendedDataTypes = array_merge($dataTypes, $vidiFrontendContentTypes);
42
+			$dataTypes = array_unique($extendedDataTypes);
43
+		}
44
+
45
+		foreach ($dataTypes as $dataType) {
46
+			$this->ensureMinimumTcaForGrid($dataType);
47
+		}
48
+
49
+		return array($GLOBALS['TCA']);
50
+	}
51
+
52
+	/**
53
+	 * @param string $dataType
54
+	 */
55
+	protected function ensureMinimumTcaForGrid($dataType)
56
+	{
57
+		$labelField = $this->getLabelField($dataType);
58
+		if (empty($GLOBALS['TCA'][$dataType]['grid'])) {
59
+			$GLOBALS['TCA'][$dataType]['grid'] = [];
60
+		}
61
+
62
+		if (empty($GLOBALS['TCA'][$dataType]['grid']['facets'])) {
63
+			$GLOBALS['TCA'][$dataType]['grid']['facets'] = [
64
+				'uid',
65
+				$labelField,
66
+			];
67
+		}
68
+
69
+		if (empty($GLOBALS['TCA'][$dataType]['grid']['columns'])) {
70
+			$GLOBALS['TCA'][$dataType]['grid']['columns'] = [
71
+				'__checkbox' => [
72
+					'renderer' => CheckBoxRenderer::class,
73
+				],
74
+				'uid' => [
75
+					'visible' => false,
76
+					'label' => '',
77
+					'width' => '5px',
78
+				],
79
+				$labelField => [
80
+					'editable' => true,
81
+				],
82
+				'__buttons' => [
83
+					'renderer' => ButtonGroupRenderer::class,
84
+				],
85
+			];
86
+		}
87
+	}
88
+
89
+	/**
90
+	 * Get the label name of table name.
91
+	 *
92
+	 * @param string $dataType
93
+	 * @return bool
94
+	 */
95
+	protected function getLabelField($dataType)
96
+	{
97
+		return $GLOBALS['TCA'][$dataType]['ctrl']['label'];
98
+	}
99
+
100
+	/**
101
+	 * Tell whether the table has a label field.
102
+	 *
103
+	 * @param string $dataType
104
+	 * @return bool
105
+	 */
106
+	protected function hasLabelField($dataType)
107
+	{
108
+		return isset($GLOBALS['TCA'][$dataType]['ctrl']['label']);
109
+	}
110
+
111
+	/**
112
+	 * @return \TYPO3\CMS\Extbase\Object\ObjectManager
113
+	 */
114
+	protected function getObjectManager()
115
+	{
116
+		return GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class);
117
+	}
118 118
 
119 119
 }
Please login to merge, or discard this patch.