Completed
Push — master ( ee04f3...91f999 )
by Fabien
48:32 queued 44:31
created
Classes/View/Check/RelationsCheck.php 1 patch
Indentation   +82 added lines, -82 removed lines patch added patch discarded remove patch
@@ -17,38 +17,38 @@  discard block
 block discarded – undo
17 17
 class RelationsCheck extends AbstractComponentView
18 18
 {
19 19
 
20
-    /**
21
-     * @var array
22
-     */
23
-    protected $invalidFields = [];
24
-
25
-    /**
26
-     * Renders a button for uploading assets.
27
-     *
28
-     * @return string
29
-     */
30
-    public function render()
31
-    {
32
-
33
-        $result = '';
34
-
35
-        // Check whether storage is configured or not.
36
-        if (!$this->isTcaValid()) {
37
-            $result .= $this->formatMessageTcaIsNotValid();
38
-        }
39
-
40
-        return $result;
41
-    }
42
-
43
-    /**
44
-     * Format a message whenever the storage is offline.
45
-     *
46
-     * @return string
47
-     */
48
-    protected function formatMessageTcaIsNotValid()
49
-    {
50
-
51
-        $result = <<< EOF
20
+	/**
21
+	 * @var array
22
+	 */
23
+	protected $invalidFields = [];
24
+
25
+	/**
26
+	 * Renders a button for uploading assets.
27
+	 *
28
+	 * @return string
29
+	 */
30
+	public function render()
31
+	{
32
+
33
+		$result = '';
34
+
35
+		// Check whether storage is configured or not.
36
+		if (!$this->isTcaValid()) {
37
+			$result .= $this->formatMessageTcaIsNotValid();
38
+		}
39
+
40
+		return $result;
41
+	}
42
+
43
+	/**
44
+	 * Format a message whenever the storage is offline.
45
+	 *
46
+	 * @return string
47
+	 */
48
+	protected function formatMessageTcaIsNotValid()
49
+	{
50
+
51
+		$result = <<< EOF
52 52
 			<div class="typo3-message message-warning">
53 53
 				<div class="message-header">
54 54
 					Grid may have trouble to render because of wrong / missing TCA.
@@ -63,19 +63,19 @@  discard block
 block discarded – undo
63 63
 				</div>
64 64
 			</div>
65 65
 EOF;
66
-        return $result;
67
-    }
68
-
69
-    /**
70
-     * Check relations of current data type in the Grid.
71
-     *
72
-     * @return string
73
-     */
74
-    protected function formatMessageHelperText()
75
-    {
76
-        $helperText = '';
77
-        foreach ($this->invalidFields as $invalidField) {
78
-            $helperText .= <<<EOF
66
+		return $result;
67
+	}
68
+
69
+	/**
70
+	 * Check relations of current data type in the Grid.
71
+	 *
72
+	 * @return string
73
+	 */
74
+	protected function formatMessageHelperText()
75
+	{
76
+		$helperText = '';
77
+		foreach ($this->invalidFields as $invalidField) {
78
+			$helperText .= <<<EOF
79 79
 				<br />
80 80
 				In file EXT:my_ext/Configuration/TCA/{$this->getModuleLoader()->getDataType()}.php
81 81
 <pre>
@@ -109,42 +109,42 @@  discard block
 block discarded – undo
109 109
 
110 110
 </pre>
111 111
 EOF;
112
-        }
113
-        return $helperText;
114
-    }
115
-
116
-    /**
117
-     * Check relations of current data type in the Grid.
118
-     *
119
-     * @return boolean
120
-     */
121
-    protected function isTcaValid()
122
-    {
123
-
124
-        $dataType = $this->getModuleLoader()->getDataType();
125
-        $table = Tca::table($dataType);
126
-
127
-        foreach (Tca::grid($dataType)->getFields() as $fieldName => $configuration) {
128
-
129
-            if ($table->hasField($fieldName) && $table->field($fieldName)->hasMany()) {
130
-                if ($table->field($fieldName)->hasRelationManyToMany()) {
131
-
132
-                    $foreignTable = $table->field($fieldName)->getForeignTable();
133
-                    $manyToManyTable = $table->field($fieldName)->getManyToManyTable();
134
-                    $foreignField = $table->field($fieldName)->getForeignField();
135
-
136
-                    if (!$foreignField) {
137
-                        $this->invalidFields[] = $fieldName;
138
-                    } elseif (!$foreignTable) {
139
-                        $this->invalidFields[] = $fieldName;
140
-                    } elseif (!$manyToManyTable) {
141
-                        $this->invalidFields[] = $fieldName;
142
-                    }
143
-                }
144
-            }
145
-        }
146
-
147
-        return empty($this->invalidFields);
148
-    }
112
+		}
113
+		return $helperText;
114
+	}
115
+
116
+	/**
117
+	 * Check relations of current data type in the Grid.
118
+	 *
119
+	 * @return boolean
120
+	 */
121
+	protected function isTcaValid()
122
+	{
123
+
124
+		$dataType = $this->getModuleLoader()->getDataType();
125
+		$table = Tca::table($dataType);
126
+
127
+		foreach (Tca::grid($dataType)->getFields() as $fieldName => $configuration) {
128
+
129
+			if ($table->hasField($fieldName) && $table->field($fieldName)->hasMany()) {
130
+				if ($table->field($fieldName)->hasRelationManyToMany()) {
131
+
132
+					$foreignTable = $table->field($fieldName)->getForeignTable();
133
+					$manyToManyTable = $table->field($fieldName)->getManyToManyTable();
134
+					$foreignField = $table->field($fieldName)->getForeignField();
135
+
136
+					if (!$foreignField) {
137
+						$this->invalidFields[] = $fieldName;
138
+					} elseif (!$foreignTable) {
139
+						$this->invalidFields[] = $fieldName;
140
+					} elseif (!$manyToManyTable) {
141
+						$this->invalidFields[] = $fieldName;
142
+					}
143
+				}
144
+			}
145
+		}
146
+
147
+		return empty($this->invalidFields);
148
+	}
149 149
 
150 150
 }
Please login to merge, or discard this patch.
Classes/View/Button/EditButton.php 1 patch
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -20,35 +20,35 @@
 block discarded – undo
20 20
 class EditButton extends AbstractComponentView
21 21
 {
22 22
 
23
-    /**
24
-     * Renders a "edit" button to be placed in the grid.
25
-     *
26
-     * @param Content $object
27
-     * @return string
28
-     */
29
-    public function render(Content $object = null)
30
-    {
31
-        $editUri = $this->getUriRenderer()->render($object);
23
+	/**
24
+	 * Renders a "edit" button to be placed in the grid.
25
+	 *
26
+	 * @param Content $object
27
+	 * @return string
28
+	 */
29
+	public function render(Content $object = null)
30
+	{
31
+		$editUri = $this->getUriRenderer()->render($object);
32 32
 
33
-        return $this->makeLinkButton()
34
-            ->setHref($editUri)
35
-            ->setDataAttributes([
36
-                'uid' => $object->getUid(),
37
-                'toggle' => 'tooltip',
38
-            ])
39
-            ->setClasses('btn-edit')
40
-            ->setTitle($this->getLanguageService()->sL('LLL:EXT:lang/locallang_mod_web_list.xlf:edit'))
41
-            ->setIcon($this->getIconFactory()->getIcon('actions-document-open', Icon::SIZE_SMALL))
42
-            ->render();
43
-    }
33
+		return $this->makeLinkButton()
34
+			->setHref($editUri)
35
+			->setDataAttributes([
36
+				'uid' => $object->getUid(),
37
+				'toggle' => 'tooltip',
38
+			])
39
+			->setClasses('btn-edit')
40
+			->setTitle($this->getLanguageService()->sL('LLL:EXT:lang/locallang_mod_web_list.xlf:edit'))
41
+			->setIcon($this->getIconFactory()->getIcon('actions-document-open', Icon::SIZE_SMALL))
42
+			->render();
43
+	}
44 44
 
45
-    /**
46
-     * @return \Fab\Vidi\View\Uri\EditUri
47
-     * @throws \InvalidArgumentException
48
-     */
49
-    protected function getUriRenderer()
50
-    {
51
-        return GeneralUtility::makeInstance(EditUri::class);
52
-    }
45
+	/**
46
+	 * @return \Fab\Vidi\View\Uri\EditUri
47
+	 * @throws \InvalidArgumentException
48
+	 */
49
+	protected function getUriRenderer()
50
+	{
51
+		return GeneralUtility::makeInstance(EditUri::class);
52
+	}
53 53
 
54 54
 }
Please login to merge, or discard this patch.
Classes/View/Button/DeleteButton.php 1 patch
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -19,47 +19,47 @@
 block discarded – undo
19 19
 class DeleteButton extends AbstractComponentView
20 20
 {
21 21
 
22
-    /**
23
-     * Renders a "delete" button to be placed in the grid.
24
-     *
25
-     * @param Content $object
26
-     * @return string
27
-     */
28
-    public function render(Content $object = null)
29
-    {
30
-        $labelField = Tca::table($object->getDataType())->getLabelField();
31
-        $label = $object[$labelField] ? $object[$labelField] : $object->getUid();
22
+	/**
23
+	 * Renders a "delete" button to be placed in the grid.
24
+	 *
25
+	 * @param Content $object
26
+	 * @return string
27
+	 */
28
+	public function render(Content $object = null)
29
+	{
30
+		$labelField = Tca::table($object->getDataType())->getLabelField();
31
+		$label = $object[$labelField] ? $object[$labelField] : $object->getUid();
32 32
 
33
-        return $this->makeLinkButton()
34
-            ->setHref($this->getDeleteUri($object))
35
-            ->setDataAttributes([
36
-                'uid' => $object->getUid(),
37
-                'toggle' => 'tooltip',
38
-                'label' => $label,
39
-            ])
40
-            ->setClasses('btn-delete')
41
-            ->setTitle($this->getLanguageService()->sL('LLL:EXT:lang/locallang_mod_web_list.xlf:delete'))
42
-            ->setIcon($this->getIconFactory()->getIcon('actions-edit-delete', Icon::SIZE_SMALL))
43
-            ->render();
44
-    }
33
+		return $this->makeLinkButton()
34
+			->setHref($this->getDeleteUri($object))
35
+			->setDataAttributes([
36
+				'uid' => $object->getUid(),
37
+				'toggle' => 'tooltip',
38
+				'label' => $label,
39
+			])
40
+			->setClasses('btn-delete')
41
+			->setTitle($this->getLanguageService()->sL('LLL:EXT:lang/locallang_mod_web_list.xlf:delete'))
42
+			->setIcon($this->getIconFactory()->getIcon('actions-edit-delete', Icon::SIZE_SMALL))
43
+			->render();
44
+	}
45 45
 
46
-    /**
47
-     * @param Content $object
48
-     * @return string
49
-     */
50
-    protected function getDeleteUri(Content $object)
51
-    {
52
-        $additionalParameters = array(
53
-            $this->getModuleLoader()->getParameterPrefix() => array(
54
-                'controller' => 'Content',
55
-                'action' => 'delete',
56
-                'format' => 'json',
57
-                'matches' => array(
58
-                    'uid' => $object->getUid(),
59
-                ),
60
-            ),
61
-        );
62
-        return $this->getModuleLoader()->getModuleUrl($additionalParameters);
63
-    }
46
+	/**
47
+	 * @param Content $object
48
+	 * @return string
49
+	 */
50
+	protected function getDeleteUri(Content $object)
51
+	{
52
+		$additionalParameters = array(
53
+			$this->getModuleLoader()->getParameterPrefix() => array(
54
+				'controller' => 'Content',
55
+				'action' => 'delete',
56
+				'format' => 'json',
57
+				'matches' => array(
58
+					'uid' => $object->getUid(),
59
+				),
60
+			),
61
+		);
62
+		return $this->getModuleLoader()->getModuleUrl($additionalParameters);
63
+	}
64 64
 
65 65
 }
Please login to merge, or discard this patch.
Classes/View/Button/NewButton.php 1 patch
Indentation   +128 added lines, -128 removed lines patch added patch discarded remove patch
@@ -21,133 +21,133 @@
 block discarded – undo
21 21
 class NewButton extends AbstractComponentView
22 22
 {
23 23
 
24
-    /**
25
-     * Renders a "new" button to be placed in the doc header.
26
-     *
27
-     * @return string
28
-     */
29
-    public function render()
30
-    {
31
-
32
-        // General New button
33
-        if ($this->getModuleLoader()->copeWithPageTree()) {
34
-
35
-            // Wizard "new"
36
-            $buttons[] = $this->makeLinkButton()
37
-                ->setHref($this->getNewUri())
38
-                ->setTitle($this->getLanguageService()->sL('LLL:EXT:lang/locallang_mod_web_list.xlf:newRecordGeneral'))
39
-                ->setIcon($this->getIconFactory()->getIcon('actions-document-new', Icon::SIZE_SMALL))
40
-                ->render();
41
-
42
-            $buttons[] = $this->makeLinkButton()
43
-                ->setHref($this->getNewUri())
44
-                ->setTitle($this->getLanguageService()->sL('LLL:EXT:lang/locallang_mod_web_list.xlf:newRecordGeneral'))
45
-                ->setIcon(
46
-                    $this->getIconFactory()->getIconForRecord(
47
-                        $this->getModuleLoader()->getDataType(),
48
-                        [],
49
-                        Icon::SIZE_SMALL
50
-                    )
51
-                )
52
-                ->render();
53
-
54
-            $output = '<div class="btn-toolbar" role="toolbar" aria-label="">' . implode("\n", $buttons) . '</div>';
55
-
56
-        } else {
57
-
58
-            // New button only for the current data type.
59
-            $output = $this->makeLinkButton()->setHref($this->getNewUri())
60
-                ->setTitle($this->getLanguageService()->sL('LLL:EXT:lang/locallang_mod_web_list.xlf:newRecordGeneral'))
61
-                ->setIcon($this->getIconFactory()->getIcon('actions-document-new', Icon::SIZE_SMALL))
62
-                ->render();
63
-        }
64
-
65
-
66
-        return $output;
67
-    }
68
-
69
-    /**
70
-     * Render a create URI given a data type.
71
-     *
72
-     * @return string
73
-     * @throws \InvalidArgumentException
74
-     */
75
-    protected function getUriWizardNew()
76
-    {
77
-        // Return URL in any case.
78
-        $arguments['returnUrl'] = $this->getModuleLoader()->getModuleUrl();
79
-
80
-        // Add possible id parameter
81
-        if (GeneralUtility::_GP(Parameter::PID)) {
82
-            $arguments['id'] = GeneralUtility::_GP(Parameter::PID);
83
-        }
84
-
85
-        $uri = BackendUtility::getModuleUrl(
86
-            'db_new',
87
-            $arguments
88
-        );
89
-
90
-        return $uri;
91
-    }
92
-
93
-    /**
94
-     * Render a create URI given a data type.
95
-     *
96
-     * @return string
97
-     * @throws \InvalidArgumentException
98
-     * @throws \Fab\Vidi\Exception\InvalidKeyInArrayException
99
-     */
100
-    protected function getNewUri()
101
-    {
102
-        $uri = BackendUtility::getModuleUrl(
103
-            'record_edit',
104
-            array(
105
-                $this->getNewParameterName() => 'new',
106
-                'returnUrl' => $this->getModuleLoader()->getModuleUrl()
107
-            )
108
-        );
109
-        return $uri;
110
-    }
111
-
112
-    /**
113
-     * @return string
114
-     * @throws \Fab\Vidi\Exception\InvalidKeyInArrayException
115
-     * @throws \InvalidArgumentException
116
-     */
117
-    protected function getNewParameterName()
118
-    {
119
-        return sprintf(
120
-            'edit[%s][%s]',
121
-            $this->getModuleLoader()->getDataType(),
122
-            $this->getStoragePid()
123
-        );
124
-    }
125
-
126
-    /**
127
-     * Return the default configured pid.
128
-     *
129
-     * @return int
130
-     * @throws \InvalidArgumentException
131
-     * @throws \Fab\Vidi\Exception\InvalidKeyInArrayException
132
-     */
133
-    protected function getStoragePid()
134
-    {
135
-        if (GeneralUtility::_GP(Parameter::PID)) {
136
-            $pid = GeneralUtility::_GP(Parameter::PID);
137
-        } elseif ((int)Tca::table()->get('rootLevel') === 1) {
138
-            $pid = 0;
139
-        } else {
140
-            // Get configuration from User TSConfig if any
141
-            $tsConfigPath = sprintf('tx_vidi.dataType.%s.storagePid', $this->getModuleLoader()->getDataType());
142
-            $tsConfig = $this->getBackendUser()->getTSConfig($tsConfigPath);
143
-            $pid = $tsConfig['value'];
144
-
145
-            // Get pid from Module Loader
146
-            if (null === $pid) {
147
-                $pid = $this->getModuleLoader()->getDefaultPid();
148
-            }
149
-        }
150
-        return (int)$pid;
151
-    }
24
+	/**
25
+	 * Renders a "new" button to be placed in the doc header.
26
+	 *
27
+	 * @return string
28
+	 */
29
+	public function render()
30
+	{
31
+
32
+		// General New button
33
+		if ($this->getModuleLoader()->copeWithPageTree()) {
34
+
35
+			// Wizard "new"
36
+			$buttons[] = $this->makeLinkButton()
37
+				->setHref($this->getNewUri())
38
+				->setTitle($this->getLanguageService()->sL('LLL:EXT:lang/locallang_mod_web_list.xlf:newRecordGeneral'))
39
+				->setIcon($this->getIconFactory()->getIcon('actions-document-new', Icon::SIZE_SMALL))
40
+				->render();
41
+
42
+			$buttons[] = $this->makeLinkButton()
43
+				->setHref($this->getNewUri())
44
+				->setTitle($this->getLanguageService()->sL('LLL:EXT:lang/locallang_mod_web_list.xlf:newRecordGeneral'))
45
+				->setIcon(
46
+					$this->getIconFactory()->getIconForRecord(
47
+						$this->getModuleLoader()->getDataType(),
48
+						[],
49
+						Icon::SIZE_SMALL
50
+					)
51
+				)
52
+				->render();
53
+
54
+			$output = '<div class="btn-toolbar" role="toolbar" aria-label="">' . implode("\n", $buttons) . '</div>';
55
+
56
+		} else {
57
+
58
+			// New button only for the current data type.
59
+			$output = $this->makeLinkButton()->setHref($this->getNewUri())
60
+				->setTitle($this->getLanguageService()->sL('LLL:EXT:lang/locallang_mod_web_list.xlf:newRecordGeneral'))
61
+				->setIcon($this->getIconFactory()->getIcon('actions-document-new', Icon::SIZE_SMALL))
62
+				->render();
63
+		}
64
+
65
+
66
+		return $output;
67
+	}
68
+
69
+	/**
70
+	 * Render a create URI given a data type.
71
+	 *
72
+	 * @return string
73
+	 * @throws \InvalidArgumentException
74
+	 */
75
+	protected function getUriWizardNew()
76
+	{
77
+		// Return URL in any case.
78
+		$arguments['returnUrl'] = $this->getModuleLoader()->getModuleUrl();
79
+
80
+		// Add possible id parameter
81
+		if (GeneralUtility::_GP(Parameter::PID)) {
82
+			$arguments['id'] = GeneralUtility::_GP(Parameter::PID);
83
+		}
84
+
85
+		$uri = BackendUtility::getModuleUrl(
86
+			'db_new',
87
+			$arguments
88
+		);
89
+
90
+		return $uri;
91
+	}
92
+
93
+	/**
94
+	 * Render a create URI given a data type.
95
+	 *
96
+	 * @return string
97
+	 * @throws \InvalidArgumentException
98
+	 * @throws \Fab\Vidi\Exception\InvalidKeyInArrayException
99
+	 */
100
+	protected function getNewUri()
101
+	{
102
+		$uri = BackendUtility::getModuleUrl(
103
+			'record_edit',
104
+			array(
105
+				$this->getNewParameterName() => 'new',
106
+				'returnUrl' => $this->getModuleLoader()->getModuleUrl()
107
+			)
108
+		);
109
+		return $uri;
110
+	}
111
+
112
+	/**
113
+	 * @return string
114
+	 * @throws \Fab\Vidi\Exception\InvalidKeyInArrayException
115
+	 * @throws \InvalidArgumentException
116
+	 */
117
+	protected function getNewParameterName()
118
+	{
119
+		return sprintf(
120
+			'edit[%s][%s]',
121
+			$this->getModuleLoader()->getDataType(),
122
+			$this->getStoragePid()
123
+		);
124
+	}
125
+
126
+	/**
127
+	 * Return the default configured pid.
128
+	 *
129
+	 * @return int
130
+	 * @throws \InvalidArgumentException
131
+	 * @throws \Fab\Vidi\Exception\InvalidKeyInArrayException
132
+	 */
133
+	protected function getStoragePid()
134
+	{
135
+		if (GeneralUtility::_GP(Parameter::PID)) {
136
+			$pid = GeneralUtility::_GP(Parameter::PID);
137
+		} elseif ((int)Tca::table()->get('rootLevel') === 1) {
138
+			$pid = 0;
139
+		} else {
140
+			// Get configuration from User TSConfig if any
141
+			$tsConfigPath = sprintf('tx_vidi.dataType.%s.storagePid', $this->getModuleLoader()->getDataType());
142
+			$tsConfig = $this->getBackendUser()->getTSConfig($tsConfigPath);
143
+			$pid = $tsConfig['value'];
144
+
145
+			// Get pid from Module Loader
146
+			if (null === $pid) {
147
+				$pid = $this->getModuleLoader()->getDefaultPid();
148
+			}
149
+		}
150
+		return (int)$pid;
151
+	}
152 152
 
153 153
 }
Please login to merge, or discard this patch.
Classes/View/Tab/DataTypeTab.php 1 patch
Indentation   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -20,86 +20,86 @@
 block discarded – undo
20 20
 class DataTypeTab extends AbstractComponentView
21 21
 {
22 22
 
23
-    /**
24
-     * Renders a "new" button to be placed in the doc header.
25
-     *
26
-     * @return string
27
-     */
28
-    public function render()
29
-    {
30
-        $output = ''; // Initialize variable as string.
31
-        if ($this->getModuleLoader()->copeWithPageTree()) {
32
-            $moduleCodes = ModuleService::getInstance()->getModulesForCurrentPid();
33
-            $output = $this->assembleDataTypeTab($moduleCodes);
34
-        }
35
-        return $output;
36
-    }
23
+	/**
24
+	 * Renders a "new" button to be placed in the doc header.
25
+	 *
26
+	 * @return string
27
+	 */
28
+	public function render()
29
+	{
30
+		$output = ''; // Initialize variable as string.
31
+		if ($this->getModuleLoader()->copeWithPageTree()) {
32
+			$moduleCodes = ModuleService::getInstance()->getModulesForCurrentPid();
33
+			$output = $this->assembleDataTypeTab($moduleCodes);
34
+		}
35
+		return $output;
36
+	}
37 37
 
38
-    /**
39
-     * @param array $moduleCodes
40
-     * @return string
41
-     */
42
-    protected function assembleDataTypeTab(array $moduleCodes)
43
-    {
44
-        return sprintf('<ul class="nav nav-tabs">%s</ul>',
45
-            $this->assembleTab($moduleCodes)
46
-        );
47
-    }
38
+	/**
39
+	 * @param array $moduleCodes
40
+	 * @return string
41
+	 */
42
+	protected function assembleDataTypeTab(array $moduleCodes)
43
+	{
44
+		return sprintf('<ul class="nav nav-tabs">%s</ul>',
45
+			$this->assembleTab($moduleCodes)
46
+		);
47
+	}
48 48
 
49
-    /**
50
-     * @return string
51
-     */
52
-    protected function getModuleToken()
53
-    {
54
-        $moduleName = GeneralUtility::_GET(Parameter::MODULE);
55
-        return FormProtectionFactory::get()->generateToken('moduleCall', $moduleName);
56
-    }
49
+	/**
50
+	 * @return string
51
+	 */
52
+	protected function getModuleToken()
53
+	{
54
+		$moduleName = GeneralUtility::_GET(Parameter::MODULE);
55
+		return FormProtectionFactory::get()->generateToken('moduleCall', $moduleName);
56
+	}
57 57
 
58
-    /**
59
-     * @param array $moduleCodes
60
-     * @return string
61
-     */
62
-    protected function assembleTab(array $moduleCodes)
63
-    {
64
-        $tabs = [];
65
-        foreach ($moduleCodes as $moduleCode => $title) {
66
-            $dataType = $this->getDataTypeForModuleCode($moduleCode);
67
-            $tabs[] = sprintf('<li %s><a href="%s">%s %s</a></li>',
68
-                $this->getModuleLoader()->getVidiModuleCode() === $moduleCode ? 'class="active"' : '',
69
-                $this->getModuleLoader()->getModuleUrl(array(Parameter::SUBMODULE => $moduleCode)),
70
-                $this->getIconFactory()->getIconForRecord($dataType, [], Icon::SIZE_SMALL),
71
-                $title
72
-            );
73
-        }
74
-        return implode("\n", $tabs);
75
-    }
58
+	/**
59
+	 * @param array $moduleCodes
60
+	 * @return string
61
+	 */
62
+	protected function assembleTab(array $moduleCodes)
63
+	{
64
+		$tabs = [];
65
+		foreach ($moduleCodes as $moduleCode => $title) {
66
+			$dataType = $this->getDataTypeForModuleCode($moduleCode);
67
+			$tabs[] = sprintf('<li %s><a href="%s">%s %s</a></li>',
68
+				$this->getModuleLoader()->getVidiModuleCode() === $moduleCode ? 'class="active"' : '',
69
+				$this->getModuleLoader()->getModuleUrl(array(Parameter::SUBMODULE => $moduleCode)),
70
+				$this->getIconFactory()->getIconForRecord($dataType, [], Icon::SIZE_SMALL),
71
+				$title
72
+			);
73
+		}
74
+		return implode("\n", $tabs);
75
+	}
76 76
 
77
-    /**
78
-     * @param $moduleCode
79
-     * @return string
80
-     */
81
-    protected function getDataTypeForModuleCode($moduleCode)
82
-    {
83
-        return $GLOBALS['TBE_MODULES_EXT']['vidi'][$moduleCode]['dataType'];
84
-    }
77
+	/**
78
+	 * @param $moduleCode
79
+	 * @return string
80
+	 */
81
+	protected function getDataTypeForModuleCode($moduleCode)
82
+	{
83
+		return $GLOBALS['TBE_MODULES_EXT']['vidi'][$moduleCode]['dataType'];
84
+	}
85 85
 
86
-    /**
87
-     * @param array $moduleCodes
88
-     * @return string
89
-     */
90
-    protected function assembleMenuOptions(array $moduleCodes)
91
-    {
92
-        $options = '';
93
-        foreach ($moduleCodes as $moduleCode => $title) {
94
-            $options .= sprintf('<option class="menu-dataType-item" value="%s" style="background-url(sysext/t3skin/icons/gfx/i/pages.gif)" %s>%s</option>%s',
95
-                $moduleCode,
96
-                $this->getModuleLoader()->getVidiModuleCode() === $moduleCode ? 'selected' : '',
97
-                $title,
98
-                chr(10)
99
-            );
100
-        }
86
+	/**
87
+	 * @param array $moduleCodes
88
+	 * @return string
89
+	 */
90
+	protected function assembleMenuOptions(array $moduleCodes)
91
+	{
92
+		$options = '';
93
+		foreach ($moduleCodes as $moduleCode => $title) {
94
+			$options .= sprintf('<option class="menu-dataType-item" value="%s" style="background-url(sysext/t3skin/icons/gfx/i/pages.gif)" %s>%s</option>%s',
95
+				$moduleCode,
96
+				$this->getModuleLoader()->getVidiModuleCode() === $moduleCode ? 'selected' : '',
97
+				$title,
98
+				chr(10)
99
+			);
100
+		}
101 101
 
102
-        return $options;
103
-    }
102
+		return $options;
103
+	}
104 104
 
105 105
 }
Please login to merge, or discard this patch.
Classes/View/System/ButtonsSystem.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -19,15 +19,15 @@
 block discarded – undo
19 19
 class ButtonsSystem extends AbstractComponentView
20 20
 {
21 21
 
22
-    /**
23
-     * Rendering buttons in the grids given a Content object.
24
-     *
25
-     * @param Content $object
26
-     * @return string
27
-     */
28
-    public function render(Content $object = null)
29
-    {
30
-        return '';
31
-    }
22
+	/**
23
+	 * Rendering buttons in the grids given a Content object.
24
+	 *
25
+	 * @param Content $object
26
+	 * @return string
27
+	 */
28
+	public function render(Content $object = null)
29
+	{
30
+		return '';
31
+	}
32 32
 
33 33
 }
Please login to merge, or discard this patch.
Classes/View/System/CheckboxSystem.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -18,15 +18,15 @@
 block discarded – undo
18 18
 class CheckboxSystem extends AbstractComponentView
19 19
 {
20 20
 
21
-    /**
22
-     * Returns a checkbox for the grids.
23
-     *
24
-     * @param Content $object
25
-     * @param  int $offset
26
-     * @return string
27
-     */
28
-    public function render(Content $object = null, $offset = 0)
29
-    {
30
-        return '';
31
-    }
21
+	/**
22
+	 * Returns a checkbox for the grids.
23
+	 *
24
+	 * @param Content $object
25
+	 * @param  int $offset
26
+	 * @return string
27
+	 */
28
+	public function render(Content $object = null, $offset = 0)
29
+	{
30
+		return '';
31
+	}
32 32
 }
Please login to merge, or discard this patch.
Classes/View/Uri/EditUri.php 1 patch
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -18,35 +18,35 @@
 block discarded – undo
18 18
 class EditUri extends AbstractComponentView
19 19
 {
20 20
 
21
-    /**
22
-     * Renders a "edit" button to be placed in the grid.
23
-     *
24
-     * @param Content $object
25
-     * @return string
26
-     */
27
-    public function render(Content $object = null)
28
-    {
29
-        $uri = BackendUtility::getModuleUrl(
30
-            'record_edit',
31
-            array(
32
-                $this->getEditParameterName($object) => 'edit',
33
-                'returnUrl' => $this->getModuleLoader()->getModuleUrl()
34
-            )
35
-        );
36
-        return $uri;
37
-    }
21
+	/**
22
+	 * Renders a "edit" button to be placed in the grid.
23
+	 *
24
+	 * @param Content $object
25
+	 * @return string
26
+	 */
27
+	public function render(Content $object = null)
28
+	{
29
+		$uri = BackendUtility::getModuleUrl(
30
+			'record_edit',
31
+			array(
32
+				$this->getEditParameterName($object) => 'edit',
33
+				'returnUrl' => $this->getModuleLoader()->getModuleUrl()
34
+			)
35
+		);
36
+		return $uri;
37
+	}
38 38
 
39
-    /**
40
-     * @param Content $object
41
-     * @return string
42
-     */
43
-    protected function getEditParameterName(Content $object)
44
-    {
45
-        return sprintf(
46
-            'edit[%s][%s]',
47
-            $object->getDataType(),
48
-            $object->getUid()
49
-        );
50
-    }
39
+	/**
40
+	 * @param Content $object
41
+	 * @return string
42
+	 */
43
+	protected function getEditParameterName(Content $object)
44
+	{
45
+		return sprintf(
46
+			'edit[%s][%s]',
47
+			$object->getDataType(),
48
+			$object->getUid()
49
+		);
50
+	}
51 51
 
52 52
 }
Please login to merge, or discard this patch.
Classes/View/Grid/Row.php 1 patch
Indentation   +624 added lines, -624 removed lines patch added patch discarded remove patch
@@ -25,629 +25,629 @@
 block discarded – undo
25 25
 class Row extends AbstractComponentView
26 26
 {
27 27
 
28
-    /**
29
-     * @var array
30
-     */
31
-    protected $columns = [];
32
-
33
-    /**
34
-     * Registry for storing variable values and speed up the processing.
35
-     *
36
-     * @var array
37
-     */
38
-    protected $variables = [];
39
-
40
-    /**
41
-     * @param array $columns
42
-     */
43
-    public function __construct(array $columns = [])
44
-    {
45
-        $this->columns = $columns;
46
-    }
47
-
48
-    /**
49
-     * Render a row to be displayed in the Grid given an Content Object.
50
-     *
51
-     * @param \Fab\Vidi\Domain\Model\Content $object
52
-     * @param int $rowIndex
53
-     * @return array
54
-     * @throws \Exception
55
-     */
56
-    public function render(Content $object = null, $rowIndex = 0)
57
-    {
58
-
59
-        // Initialize returned array
60
-        $output = [];
61
-
62
-        foreach (Tca::grid()->getFields() as $fieldNameAndPath => $configuration) {
63
-
64
-            $value = ''; // default is empty at first.
65
-
66
-            $this->computeVariables($object, $fieldNameAndPath);
67
-
68
-            // Only compute the value if it is going to be shown in the Grid. Lost of time otherwise!
69
-            if (in_array($fieldNameAndPath, $this->columns)) {
70
-
71
-                // Fetch value
72
-                if (Tca::grid()->hasRenderers($fieldNameAndPath)) {
73
-
74
-                    $value = '';
75
-                    $renderers = Tca::grid()->getRenderers($fieldNameAndPath);
76
-
77
-                    // if is relation has one
78
-                    foreach ($renderers as $rendererClassName => $rendererConfiguration) {
79
-
80
-                        // @todo when removing ColumnInterface in v2.0 + 2 version, GeneralUtility::makeInstance is not always necessary as it could be an object already
81
-                        /** @var $rendererObject \Fab\Vidi\Grid\ColumnRendererInterface */
82
-                        $rendererObject = GeneralUtility::makeInstance($rendererClassName);
83
-                        $value .= $rendererObject
84
-                            ->setObject($object)
85
-                            ->setFieldName($fieldNameAndPath)
86
-                            ->setRowIndex($rowIndex)
87
-                            ->setFieldConfiguration($configuration)
88
-                            ->setGridRendererConfiguration($rendererConfiguration)
89
-                            ->render();
90
-                    }
91
-                } else {
92
-                    $value = $this->resolveValue($object, $fieldNameAndPath);
93
-                    $value = $this->processValue($value, $object, $fieldNameAndPath); // post resolve processing.
94
-                }
95
-
96
-                // Possible formatting given by configuration. @see TCA['grid']
97
-                $value = $this->formatValue($value, $configuration);
98
-
99
-                // Here, there is the chance to further "decorate" the value for inline editing, localization, ...
100
-                if ($this->willBeEnriched()) {
101
-
102
-                    $localizedStructure = $this->initializeLocalizedStructure($value);
103
-
104
-                    if ($this->isEditable()) {
105
-                        $localizedStructure = $this->addEditableMarkup($localizedStructure);
106
-                    }
107
-
108
-                    if ($this->isLocalized()) {
109
-                        $localizedStructure = $this->addLocalizationMarkup($localizedStructure);
110
-                    }
111
-
112
-                    if ($this->hasIcon()) {
113
-                        $localizedStructure = $this->addSpriteIconMarkup($localizedStructure);
114
-                    }
115
-
116
-                    $value = $this->flattenStructure($localizedStructure);
117
-                }
118
-
119
-                // Final wrap given by configuration. @see TCA['grid']
120
-                $value = $this->wrapValue($value, $configuration);
121
-            }
122
-
123
-            $output[$this->getFieldName()] = $value;
124
-        }
125
-
126
-        $output['DT_RowId'] = 'row-' . $object->getUid();
127
-        $output['DT_RowClass'] = sprintf('%s_%s', $object->getDataType(), $object->getUid());
128
-
129
-        return $output;
130
-    }
131
-
132
-    /**
133
-     * Flatten the localized structure to render the final value
134
-     *
135
-     * @param array $localizedStructure
136
-     * @return array
137
-     */
138
-    protected function flattenStructure(array $localizedStructure)
139
-    {
140
-
141
-        // Flatten the structure.
142
-        $value = '';
143
-        foreach ($localizedStructure as $structure) {
144
-            $value .= sprintf('<div class="%s">%s</div>',
145
-                $structure['status'] !== LocalizationStatus::LOCALIZED ? 'invisible' : '',
146
-                $structure['value']
147
-            );
148
-        }
149
-        return $value;
150
-    }
151
-
152
-    /**
153
-     * Store some often used variable values and speed up the processing.
154
-     *
155
-     * @param \Fab\Vidi\Domain\Model\Content $object
156
-     * @param string $fieldNameAndPath
157
-     * @return array
158
-     */
159
-    protected function computeVariables(Content $object, $fieldNameAndPath)
160
-    {
161
-        $this->variables = [];
162
-        $this->variables['dataType'] = $this->getFieldPathResolver()->getDataType($fieldNameAndPath);
163
-        $this->variables['fieldName'] = $this->getFieldPathResolver()->stripFieldPath($fieldNameAndPath);
164
-        $this->variables['fieldNameAndPath'] = $fieldNameAndPath;
165
-        $this->variables['object'] = $object;
166
-    }
167
-
168
-    /**
169
-     * Tell whether the object will be decorated / wrapped such as
170
-     *
171
-     * @param string $value
172
-     * @return array
173
-     */
174
-    protected function initializeLocalizedStructure($value)
175
-    {
176
-
177
-        $localizedStructure[] = [
178
-            'value' => empty($value) && $this->isEditable() ? $this->getEmptyValuePlaceholder() : $value,
179
-            'status' => empty($value) ? LocalizationStatus::EMPTY_VALUE : LocalizationStatus::LOCALIZED,
180
-            'language' => 0,
181
-            'languageFlag' => $defaultLanguage = $this->getLanguageService()->getDefaultFlag(),
182
-        ];
183
-
184
-        if ($this->isLocalized()) {
185
-
186
-            foreach ($this->getLanguageService()->getLanguages() as $language) {
187
-
188
-                // Make sure the language is allowed for the current Backend User.
189
-                if ($this->isLanguageAllowedForBackendUser($language)) {
190
-
191
-                    $resolvedObject = $this->getResolvedObject();
192
-                    $fieldName = $this->getFieldName();
193
-
194
-                    if ($this->getLanguageService()->hasLocalization($resolvedObject, $language['uid'])) {
195
-                        $localizedValue = $this->getLanguageService()->getLocalizedFieldName($resolvedObject, $language['uid'], $fieldName);
196
-                        $status = LocalizationStatus::LOCALIZED;
197
-
198
-                        // Replace blank value by something more meaningful for the End User.
199
-                        if (empty($localizedValue)) {
200
-                            $status = LocalizationStatus::EMPTY_VALUE;
201
-                            $localizedValue = $this->isEditable() ? $this->getEmptyValuePlaceholder() : '';
202
-                        }
203
-                    } else {
204
-                        $localizedValue = sprintf('<a href="%s" style="color: black">%s</a>',
205
-                            $this->getLocalizedUri($language['uid']),
206
-                            $this->getLabelService()->sL('LLL:EXT:vidi/Resources/Private/Language/locallang.xlf:create_translation')
207
-                        );
208
-                        $status = LocalizationStatus::NOT_YET_LOCALIZED;
209
-                    }
210
-
211
-                    // Feed structure.
212
-                    $localizedStructure[] = [
213
-                        'value' => $localizedValue,
214
-                        'status' => $status,
215
-                        'language' => (int)$language['uid'],
216
-                        'languageFlag' => $language['flag'],
217
-                    ];
218
-                }
219
-            }
220
-        }
221
-
222
-        return $localizedStructure;
223
-    }
224
-
225
-    /**
226
-     * @param array $language
227
-     * @return bool
228
-     */
229
-    protected function isLanguageAllowedForBackendUser(array $language)
230
-    {
231
-        return $this->getBackendUser()->checkLanguageAccess($language['uid']);
232
-    }
233
-
234
-    /**
235
-     * Returns a placeholder when the value is empty.
236
-     *
237
-     * @return string
238
-     */
239
-    protected function getEmptyValuePlaceholder()
240
-    {
241
-        return sprintf('<i>%s</i>',
242
-            $this->getLabelService()->sL('LLL:EXT:vidi/Resources/Private/Language/locallang.xlf:start_editing')
243
-        );
244
-    }
245
-
246
-    /**
247
-     * Tell whether the object will be decorated (or wrapped) for inline editing, localization purpose.
248
-     *
249
-     * @return bool
250
-     */
251
-    protected function willBeEnriched()
252
-    {
253
-
254
-        $willBeEnriched = false;
255
-
256
-        if ($this->fieldExists()) {
257
-            $willBeEnriched = $this->isEditable() || $this->hasIcon() || $this->isLocalized();
258
-        }
259
-
260
-        return $willBeEnriched;
261
-    }
262
-
263
-    /**
264
-     * Tell whether the field in the context will be prepended by an icon.
265
-     *
266
-     * @return bool
267
-     */
268
-    protected function hasIcon()
269
-    {
270
-        $dataType = $this->getDataType();
271
-        return Tca::table($dataType)->getLabelField() === $this->getFieldName();
272
-    }
273
-
274
-    /**
275
-     * Tell whether the field in the context will be prepended by an icon.
276
-     *
277
-     * @return bool
278
-     */
279
-    protected function isLocalized()
280
-    {
281
-        $object = $this->getObject();
282
-        $fieldName = $this->getFieldName();
283
-        $dataType = $this->getDataType();
284
-        $fieldNameAndPath = $this->getFieldNameAndPath();
285
-
286
-        return $this->getLanguageService()->hasLanguages()
287
-        && Tca::grid($object)->isLocalized($fieldNameAndPath)
288
-        && Tca::table($dataType)->field($fieldName)->isLocalized();
289
-    }
290
-
291
-    /**
292
-     * Add some markup to have the content editable in the Grid.
293
-     *
294
-     * @param array $localizedStructure
295
-     * @return array
296
-     */
297
-    protected function addEditableMarkup(array $localizedStructure)
298
-    {
299
-
300
-        $dataType = $this->getDataType();
301
-        $fieldName = $this->getFieldName();
302
-
303
-        foreach ($localizedStructure as $index => $structure) {
304
-            if ($structure['status'] !== LocalizationStatus::NOT_YET_LOCALIZED) {
305
-                $localizedStructure[$index]['value'] = sprintf('<span class="%s" data-language="%s">%s</span>',
306
-                    Tca::table($dataType)->field($fieldName)->isTextArea() ? 'editable-textarea' : 'editable-textfield',
307
-                    $structure['language'],
308
-                    $structure['value']
309
-                );
310
-            }
311
-        }
312
-        return $localizedStructure;
313
-    }
314
-
315
-    /**
316
-     * Add some markup related to the localization.
317
-     *
318
-     * @param array $localizedStructure
319
-     * @return array
320
-     */
321
-    protected function addLocalizationMarkup(array $localizedStructure)
322
-    {
323
-
324
-        foreach ($localizedStructure as $index => $structure) {
325
-
326
-            $localizedStructure[$index]['value'] = sprintf('<span>%s %s</span>',
327
-                empty($structure['languageFlag']) ? '' : $this->getIconFactory()->getIcon('flags-' . $structure['languageFlag'], Icon::SIZE_SMALL),
328
-                $structure['value']
329
-            );
330
-        }
331
-        return $localizedStructure;
332
-    }
333
-
334
-    /**
335
-     * Add some markup related to the prepended icon.
336
-     *
337
-     * @param array $localizedStructure
338
-     * @return array
339
-     */
340
-    protected function addSpriteIconMarkup(array $localizedStructure)
341
-    {
342
-
343
-        $object = $this->getObject();
344
-
345
-        foreach ($localizedStructure as $index => $structure) {
346
-
347
-            $recordData = [];
348
-
349
-            $enablesMethods = array('Hidden', 'Deleted', 'StartTime', 'EndTime');
350
-            foreach ($enablesMethods as $enableMethod) {
351
-
352
-                $methodName = 'get' . $enableMethod . 'Field';
353
-
354
-                // Fetch possible hidden filed.
355
-                $enableField = Tca::table($object)->$methodName();
356
-                if ($enableField) {
357
-                    $recordData[$enableField] = $object[$enableField];
358
-                }
359
-            }
360
-
361
-            // Get Enable Fields of the object to render the sprite with overlays.
362
-            $localizedStructure[$index]['value'] = sprintf('%s %s',
363
-                $this->getIconFactory()->getIconForRecord($object->getDataType(), $recordData, Icon::SIZE_SMALL),
364
-                $structure['value']
365
-            );
366
-        }
367
-
368
-        return $localizedStructure;
369
-    }
370
-
371
-    /**
372
-     * Return whether the field given by the context is editable.
373
-     *
374
-     * @return boolean
375
-     */
376
-    protected function isEditable()
377
-    {
378
-        $fieldNameAndPath = $this->getFieldNameAndPath();
379
-        $dataType = $this->getDataType();
380
-        $fieldName = $this->getFieldName();
381
-
382
-        return Tca::grid()->isEditable($fieldNameAndPath)
383
-        && Tca::table($dataType)->hasField($fieldName)
384
-        && Tca::table($dataType)->field($fieldName)->hasNoRelation(); // relation are editable through Renderers only.
385
-    }
386
-
387
-    /**
388
-     * Return the appropriate URI to create the translation.
389
-     *
390
-     * @param int $language
391
-     * @return string
392
-     */
393
-    protected function getLocalizedUri($language)
394
-    {
395
-
396
-        // Transmit recursive selection parameter.
397
-        $parameterPrefix = $this->getModuleLoader()->getParameterPrefix();
398
-        $parameters = GeneralUtility::_GP($parameterPrefix);
399
-
400
-        $additionalParameters = array(
401
-            $this->getModuleLoader()->getParameterPrefix() => array(
402
-                'controller' => 'Content',
403
-                'action' => 'localize',
404
-                'format' => 'json',
405
-                'hasRecursiveSelection' => isset($parameters['hasRecursiveSelection']) ? (int)$parameters['hasRecursiveSelection'] : 0,
406
-                'fieldNameAndPath' => $this->getFieldNameAndPath(),
407
-                'language' => $language,
408
-                'matches' => array(
409
-                    'uid' => $this->getObject()->getUid(),
410
-                ),
411
-            ),
412
-        );
413
-
414
-        return $this->getModuleLoader()->getModuleUrl($additionalParameters);
415
-    }
416
-
417
-    /**
418
-     * Compute the value for the Content object according to a field name.
419
-     *
420
-     * @param \Fab\Vidi\Domain\Model\Content $object
421
-     * @param string $fieldNameAndPath
422
-     * @return string
423
-     */
424
-    protected function resolveValue(Content $object, $fieldNameAndPath)
425
-    {
426
-
427
-        // Get the first part of the field name and
428
-        $fieldName = $this->getFieldPathResolver()->stripFieldName($fieldNameAndPath);
429
-
430
-        $value = $object[$fieldName];
431
-
432
-        // Relation but contains no data.
433
-        if (is_array($value) && empty($value)) {
434
-            $value = '';
435
-        } elseif ($value instanceof Content) {
436
-
437
-            $fieldNameOfForeignTable = $this->getFieldPathResolver()->stripFieldPath($fieldNameAndPath);
438
-
439
-            // true means the field name does not contains a path. "title" vs "metadata.title"
440
-            // Fetch the default label
441
-            if ($fieldNameOfForeignTable === $fieldName) {
442
-                $foreignTable = Tca::table($object->getDataType())->field($fieldName)->getForeignTable();
443
-                $fieldNameOfForeignTable = Tca::table($foreignTable)->getLabelField();
444
-            }
445
-
446
-            $value = $object[$fieldName][$fieldNameOfForeignTable];
447
-        }
448
-
449
-        return $value;
450
-    }
451
-
452
-    /**
453
-     * Check whether a string contains HTML tags.
454
-     *
455
-     * @param string $string the content to be analyzed
456
-     * @return boolean
457
-     */
458
-    protected function hasHtml($string)
459
-    {
460
-        $result = false;
461
-
462
-        // We compare the length of the string with html tags and without html tags.
463
-        if (strlen($string) != strlen(strip_tags($string))) {
464
-            $result = true;
465
-        }
466
-        return $result;
467
-    }
468
-
469
-    /**
470
-     * Check whether a string contains potential XSS.
471
-     *
472
-     * @param string $string the content to be analyzed
473
-     * @return boolean
474
-     */
475
-    protected function isClean($string)
476
-    {
477
-
478
-        // @todo implement me!
479
-        $result = true;
480
-        return $result;
481
-    }
482
-
483
-    /**
484
-     * Process the value
485
-     *
486
-     * @todo implement me as a processor chain to be cleaner implementation wise. Look out at the performance however!
487
-     *       e.g DefaultValueGridProcessor, TextAreaGridProcessor, ...
488
-     *
489
-     * @param string $value
490
-     * @param \Fab\Vidi\Domain\Model\Content $object
491
-     * @param string $fieldNameAndPath
492
-     * @return string
493
-     * @throws \Fab\Vidi\Exception\InvalidKeyInArrayException
494
-     */
495
-    protected function processValue($value, Content $object, $fieldNameAndPath)
496
-    {
497
-
498
-        // Set default value if $field name correspond to the label of the table
499
-        $fieldName = $this->getFieldPathResolver()->stripFieldPath($fieldNameAndPath);
500
-        if (Tca::table($object->getDataType())->getLabelField() === $fieldName && empty($value)) {
501
-            $value = sprintf('[%s]', $this->getLabelService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.no_title', 1));
502
-        }
503
-
504
-        // Sanitize the value in case of "select" or "radio button".
505
-        if (is_scalar($value)) {
506
-            $fieldType = Tca::table($object->getDataType())->field($fieldNameAndPath)->getType();
507
-            if ($fieldType !== FieldType::TEXTAREA) {
508
-                $value = htmlspecialchars($value);
509
-            } elseif ($fieldType === FieldType::TEXTAREA && !$this->isClean($value)) {
510
-                $value = htmlspecialchars($value); // Avoid bad surprise, converts characters to HTML.
511
-            } elseif ($fieldType === FieldType::TEXTAREA && !$this->hasHtml($value)) {
512
-                $value = nl2br($value);
513
-            }
514
-        }
515
-
516
-        return $value;
517
-    }
518
-
519
-    /**
520
-     * Possible value formatting.
521
-     *
522
-     * @param string $value
523
-     * @param array $configuration
524
-     * @return string
525
-     * @throws \InvalidArgumentException
526
-     */
527
-    protected function formatValue($value, array $configuration)
528
-    {
529
-        if (empty($configuration['format'])) {
530
-            return $value;
531
-        }
532
-        $className = $configuration['format'];
533
-
534
-        /** @var \Fab\Vidi\Formatter\FormatterInterface $formatter */
535
-        $formatter = GeneralUtility::makeInstance($className);
536
-        $value = $formatter->format($value);
537
-
538
-        return $value;
539
-    }
540
-
541
-    /**
542
-     * Possible value wrapping.
543
-     *
544
-     * @param string $value
545
-     * @param array $configuration
546
-     * @return string
547
-     */
548
-    protected function wrapValue($value, array $configuration)
549
-    {
550
-        if (!empty($configuration['wrap'])) {
551
-            $parts = explode('|', $configuration['wrap']);
552
-            $value = implode($value, $parts);
553
-        }
554
-        return $value;
555
-    }
556
-
557
-    /**
558
-     * Tell whether the field in the context really exists.
559
-     *
560
-     * @return bool
561
-     */
562
-    protected function fieldExists()
563
-    {
564
-        if (is_null($this->variables['hasField'])) {
565
-            $dataType = $this->getDataType();
566
-            $fieldName = $this->getFieldName();
567
-            $this->variables['hasField'] = Tca::table($dataType)->hasField($fieldName);
568
-        }
569
-        return $this->variables['hasField'];
570
-    }
571
-
572
-    /**
573
-     * @return string
574
-     */
575
-    protected function getDataType()
576
-    {
577
-        return $this->variables['dataType'];
578
-    }
579
-
580
-    /**
581
-     * @return string
582
-     */
583
-    protected function getFieldName()
584
-    {
585
-        return $this->variables['fieldName'];
586
-    }
587
-
588
-    /**
589
-     * @return string
590
-     */
591
-    protected function getFieldNameAndPath()
592
-    {
593
-        return $this->variables['fieldNameAndPath'];
594
-    }
595
-
596
-    /**
597
-     * @return Content
598
-     */
599
-    protected function getObject()
600
-    {
601
-        return $this->variables['object'];
602
-    }
603
-
604
-    /**
605
-     * @return Content
606
-     * @throws \InvalidArgumentException
607
-     */
608
-    protected function getResolvedObject()
609
-    {
610
-        if (empty($this->variables['resolvedObject'])) {
611
-            $object = $this->getObject();
612
-            $fieldNameAndPath = $this->getFieldNameAndPath();
613
-            $this->variables['resolvedObject'] = $this->getContentObjectResolver()->getObject($object, $fieldNameAndPath);
614
-        }
615
-        return $this->variables['resolvedObject'];
616
-    }
617
-
618
-    /**
619
-     * @return FieldPathResolver
620
-     * @throws \InvalidArgumentException
621
-     */
622
-    protected function getFieldPathResolver()
623
-    {
624
-        return GeneralUtility::makeInstance(FieldPathResolver::class);
625
-    }
626
-
627
-    /**
628
-     * @return ContentObjectResolver
629
-     * @throws \InvalidArgumentException
630
-     */
631
-    protected function getContentObjectResolver()
632
-    {
633
-        return GeneralUtility::makeInstance(ContentObjectResolver::class);
634
-    }
635
-
636
-    /**
637
-     * @return \TYPO3\CMS\Lang\LanguageService
638
-     */
639
-    protected function getLabelService()
640
-    {
641
-        return $GLOBALS['LANG'];
642
-    }
643
-
644
-    /**
645
-     * @return LanguageService
646
-     * @throws \InvalidArgumentException
647
-     */
648
-    protected function getLanguageService()
649
-    {
650
-        return GeneralUtility::makeInstance(LanguageService::class);
651
-    }
28
+	/**
29
+	 * @var array
30
+	 */
31
+	protected $columns = [];
32
+
33
+	/**
34
+	 * Registry for storing variable values and speed up the processing.
35
+	 *
36
+	 * @var array
37
+	 */
38
+	protected $variables = [];
39
+
40
+	/**
41
+	 * @param array $columns
42
+	 */
43
+	public function __construct(array $columns = [])
44
+	{
45
+		$this->columns = $columns;
46
+	}
47
+
48
+	/**
49
+	 * Render a row to be displayed in the Grid given an Content Object.
50
+	 *
51
+	 * @param \Fab\Vidi\Domain\Model\Content $object
52
+	 * @param int $rowIndex
53
+	 * @return array
54
+	 * @throws \Exception
55
+	 */
56
+	public function render(Content $object = null, $rowIndex = 0)
57
+	{
58
+
59
+		// Initialize returned array
60
+		$output = [];
61
+
62
+		foreach (Tca::grid()->getFields() as $fieldNameAndPath => $configuration) {
63
+
64
+			$value = ''; // default is empty at first.
65
+
66
+			$this->computeVariables($object, $fieldNameAndPath);
67
+
68
+			// Only compute the value if it is going to be shown in the Grid. Lost of time otherwise!
69
+			if (in_array($fieldNameAndPath, $this->columns)) {
70
+
71
+				// Fetch value
72
+				if (Tca::grid()->hasRenderers($fieldNameAndPath)) {
73
+
74
+					$value = '';
75
+					$renderers = Tca::grid()->getRenderers($fieldNameAndPath);
76
+
77
+					// if is relation has one
78
+					foreach ($renderers as $rendererClassName => $rendererConfiguration) {
79
+
80
+						// @todo when removing ColumnInterface in v2.0 + 2 version, GeneralUtility::makeInstance is not always necessary as it could be an object already
81
+						/** @var $rendererObject \Fab\Vidi\Grid\ColumnRendererInterface */
82
+						$rendererObject = GeneralUtility::makeInstance($rendererClassName);
83
+						$value .= $rendererObject
84
+							->setObject($object)
85
+							->setFieldName($fieldNameAndPath)
86
+							->setRowIndex($rowIndex)
87
+							->setFieldConfiguration($configuration)
88
+							->setGridRendererConfiguration($rendererConfiguration)
89
+							->render();
90
+					}
91
+				} else {
92
+					$value = $this->resolveValue($object, $fieldNameAndPath);
93
+					$value = $this->processValue($value, $object, $fieldNameAndPath); // post resolve processing.
94
+				}
95
+
96
+				// Possible formatting given by configuration. @see TCA['grid']
97
+				$value = $this->formatValue($value, $configuration);
98
+
99
+				// Here, there is the chance to further "decorate" the value for inline editing, localization, ...
100
+				if ($this->willBeEnriched()) {
101
+
102
+					$localizedStructure = $this->initializeLocalizedStructure($value);
103
+
104
+					if ($this->isEditable()) {
105
+						$localizedStructure = $this->addEditableMarkup($localizedStructure);
106
+					}
107
+
108
+					if ($this->isLocalized()) {
109
+						$localizedStructure = $this->addLocalizationMarkup($localizedStructure);
110
+					}
111
+
112
+					if ($this->hasIcon()) {
113
+						$localizedStructure = $this->addSpriteIconMarkup($localizedStructure);
114
+					}
115
+
116
+					$value = $this->flattenStructure($localizedStructure);
117
+				}
118
+
119
+				// Final wrap given by configuration. @see TCA['grid']
120
+				$value = $this->wrapValue($value, $configuration);
121
+			}
122
+
123
+			$output[$this->getFieldName()] = $value;
124
+		}
125
+
126
+		$output['DT_RowId'] = 'row-' . $object->getUid();
127
+		$output['DT_RowClass'] = sprintf('%s_%s', $object->getDataType(), $object->getUid());
128
+
129
+		return $output;
130
+	}
131
+
132
+	/**
133
+	 * Flatten the localized structure to render the final value
134
+	 *
135
+	 * @param array $localizedStructure
136
+	 * @return array
137
+	 */
138
+	protected function flattenStructure(array $localizedStructure)
139
+	{
140
+
141
+		// Flatten the structure.
142
+		$value = '';
143
+		foreach ($localizedStructure as $structure) {
144
+			$value .= sprintf('<div class="%s">%s</div>',
145
+				$structure['status'] !== LocalizationStatus::LOCALIZED ? 'invisible' : '',
146
+				$structure['value']
147
+			);
148
+		}
149
+		return $value;
150
+	}
151
+
152
+	/**
153
+	 * Store some often used variable values and speed up the processing.
154
+	 *
155
+	 * @param \Fab\Vidi\Domain\Model\Content $object
156
+	 * @param string $fieldNameAndPath
157
+	 * @return array
158
+	 */
159
+	protected function computeVariables(Content $object, $fieldNameAndPath)
160
+	{
161
+		$this->variables = [];
162
+		$this->variables['dataType'] = $this->getFieldPathResolver()->getDataType($fieldNameAndPath);
163
+		$this->variables['fieldName'] = $this->getFieldPathResolver()->stripFieldPath($fieldNameAndPath);
164
+		$this->variables['fieldNameAndPath'] = $fieldNameAndPath;
165
+		$this->variables['object'] = $object;
166
+	}
167
+
168
+	/**
169
+	 * Tell whether the object will be decorated / wrapped such as
170
+	 *
171
+	 * @param string $value
172
+	 * @return array
173
+	 */
174
+	protected function initializeLocalizedStructure($value)
175
+	{
176
+
177
+		$localizedStructure[] = [
178
+			'value' => empty($value) && $this->isEditable() ? $this->getEmptyValuePlaceholder() : $value,
179
+			'status' => empty($value) ? LocalizationStatus::EMPTY_VALUE : LocalizationStatus::LOCALIZED,
180
+			'language' => 0,
181
+			'languageFlag' => $defaultLanguage = $this->getLanguageService()->getDefaultFlag(),
182
+		];
183
+
184
+		if ($this->isLocalized()) {
185
+
186
+			foreach ($this->getLanguageService()->getLanguages() as $language) {
187
+
188
+				// Make sure the language is allowed for the current Backend User.
189
+				if ($this->isLanguageAllowedForBackendUser($language)) {
190
+
191
+					$resolvedObject = $this->getResolvedObject();
192
+					$fieldName = $this->getFieldName();
193
+
194
+					if ($this->getLanguageService()->hasLocalization($resolvedObject, $language['uid'])) {
195
+						$localizedValue = $this->getLanguageService()->getLocalizedFieldName($resolvedObject, $language['uid'], $fieldName);
196
+						$status = LocalizationStatus::LOCALIZED;
197
+
198
+						// Replace blank value by something more meaningful for the End User.
199
+						if (empty($localizedValue)) {
200
+							$status = LocalizationStatus::EMPTY_VALUE;
201
+							$localizedValue = $this->isEditable() ? $this->getEmptyValuePlaceholder() : '';
202
+						}
203
+					} else {
204
+						$localizedValue = sprintf('<a href="%s" style="color: black">%s</a>',
205
+							$this->getLocalizedUri($language['uid']),
206
+							$this->getLabelService()->sL('LLL:EXT:vidi/Resources/Private/Language/locallang.xlf:create_translation')
207
+						);
208
+						$status = LocalizationStatus::NOT_YET_LOCALIZED;
209
+					}
210
+
211
+					// Feed structure.
212
+					$localizedStructure[] = [
213
+						'value' => $localizedValue,
214
+						'status' => $status,
215
+						'language' => (int)$language['uid'],
216
+						'languageFlag' => $language['flag'],
217
+					];
218
+				}
219
+			}
220
+		}
221
+
222
+		return $localizedStructure;
223
+	}
224
+
225
+	/**
226
+	 * @param array $language
227
+	 * @return bool
228
+	 */
229
+	protected function isLanguageAllowedForBackendUser(array $language)
230
+	{
231
+		return $this->getBackendUser()->checkLanguageAccess($language['uid']);
232
+	}
233
+
234
+	/**
235
+	 * Returns a placeholder when the value is empty.
236
+	 *
237
+	 * @return string
238
+	 */
239
+	protected function getEmptyValuePlaceholder()
240
+	{
241
+		return sprintf('<i>%s</i>',
242
+			$this->getLabelService()->sL('LLL:EXT:vidi/Resources/Private/Language/locallang.xlf:start_editing')
243
+		);
244
+	}
245
+
246
+	/**
247
+	 * Tell whether the object will be decorated (or wrapped) for inline editing, localization purpose.
248
+	 *
249
+	 * @return bool
250
+	 */
251
+	protected function willBeEnriched()
252
+	{
253
+
254
+		$willBeEnriched = false;
255
+
256
+		if ($this->fieldExists()) {
257
+			$willBeEnriched = $this->isEditable() || $this->hasIcon() || $this->isLocalized();
258
+		}
259
+
260
+		return $willBeEnriched;
261
+	}
262
+
263
+	/**
264
+	 * Tell whether the field in the context will be prepended by an icon.
265
+	 *
266
+	 * @return bool
267
+	 */
268
+	protected function hasIcon()
269
+	{
270
+		$dataType = $this->getDataType();
271
+		return Tca::table($dataType)->getLabelField() === $this->getFieldName();
272
+	}
273
+
274
+	/**
275
+	 * Tell whether the field in the context will be prepended by an icon.
276
+	 *
277
+	 * @return bool
278
+	 */
279
+	protected function isLocalized()
280
+	{
281
+		$object = $this->getObject();
282
+		$fieldName = $this->getFieldName();
283
+		$dataType = $this->getDataType();
284
+		$fieldNameAndPath = $this->getFieldNameAndPath();
285
+
286
+		return $this->getLanguageService()->hasLanguages()
287
+		&& Tca::grid($object)->isLocalized($fieldNameAndPath)
288
+		&& Tca::table($dataType)->field($fieldName)->isLocalized();
289
+	}
290
+
291
+	/**
292
+	 * Add some markup to have the content editable in the Grid.
293
+	 *
294
+	 * @param array $localizedStructure
295
+	 * @return array
296
+	 */
297
+	protected function addEditableMarkup(array $localizedStructure)
298
+	{
299
+
300
+		$dataType = $this->getDataType();
301
+		$fieldName = $this->getFieldName();
302
+
303
+		foreach ($localizedStructure as $index => $structure) {
304
+			if ($structure['status'] !== LocalizationStatus::NOT_YET_LOCALIZED) {
305
+				$localizedStructure[$index]['value'] = sprintf('<span class="%s" data-language="%s">%s</span>',
306
+					Tca::table($dataType)->field($fieldName)->isTextArea() ? 'editable-textarea' : 'editable-textfield',
307
+					$structure['language'],
308
+					$structure['value']
309
+				);
310
+			}
311
+		}
312
+		return $localizedStructure;
313
+	}
314
+
315
+	/**
316
+	 * Add some markup related to the localization.
317
+	 *
318
+	 * @param array $localizedStructure
319
+	 * @return array
320
+	 */
321
+	protected function addLocalizationMarkup(array $localizedStructure)
322
+	{
323
+
324
+		foreach ($localizedStructure as $index => $structure) {
325
+
326
+			$localizedStructure[$index]['value'] = sprintf('<span>%s %s</span>',
327
+				empty($structure['languageFlag']) ? '' : $this->getIconFactory()->getIcon('flags-' . $structure['languageFlag'], Icon::SIZE_SMALL),
328
+				$structure['value']
329
+			);
330
+		}
331
+		return $localizedStructure;
332
+	}
333
+
334
+	/**
335
+	 * Add some markup related to the prepended icon.
336
+	 *
337
+	 * @param array $localizedStructure
338
+	 * @return array
339
+	 */
340
+	protected function addSpriteIconMarkup(array $localizedStructure)
341
+	{
342
+
343
+		$object = $this->getObject();
344
+
345
+		foreach ($localizedStructure as $index => $structure) {
346
+
347
+			$recordData = [];
348
+
349
+			$enablesMethods = array('Hidden', 'Deleted', 'StartTime', 'EndTime');
350
+			foreach ($enablesMethods as $enableMethod) {
351
+
352
+				$methodName = 'get' . $enableMethod . 'Field';
353
+
354
+				// Fetch possible hidden filed.
355
+				$enableField = Tca::table($object)->$methodName();
356
+				if ($enableField) {
357
+					$recordData[$enableField] = $object[$enableField];
358
+				}
359
+			}
360
+
361
+			// Get Enable Fields of the object to render the sprite with overlays.
362
+			$localizedStructure[$index]['value'] = sprintf('%s %s',
363
+				$this->getIconFactory()->getIconForRecord($object->getDataType(), $recordData, Icon::SIZE_SMALL),
364
+				$structure['value']
365
+			);
366
+		}
367
+
368
+		return $localizedStructure;
369
+	}
370
+
371
+	/**
372
+	 * Return whether the field given by the context is editable.
373
+	 *
374
+	 * @return boolean
375
+	 */
376
+	protected function isEditable()
377
+	{
378
+		$fieldNameAndPath = $this->getFieldNameAndPath();
379
+		$dataType = $this->getDataType();
380
+		$fieldName = $this->getFieldName();
381
+
382
+		return Tca::grid()->isEditable($fieldNameAndPath)
383
+		&& Tca::table($dataType)->hasField($fieldName)
384
+		&& Tca::table($dataType)->field($fieldName)->hasNoRelation(); // relation are editable through Renderers only.
385
+	}
386
+
387
+	/**
388
+	 * Return the appropriate URI to create the translation.
389
+	 *
390
+	 * @param int $language
391
+	 * @return string
392
+	 */
393
+	protected function getLocalizedUri($language)
394
+	{
395
+
396
+		// Transmit recursive selection parameter.
397
+		$parameterPrefix = $this->getModuleLoader()->getParameterPrefix();
398
+		$parameters = GeneralUtility::_GP($parameterPrefix);
399
+
400
+		$additionalParameters = array(
401
+			$this->getModuleLoader()->getParameterPrefix() => array(
402
+				'controller' => 'Content',
403
+				'action' => 'localize',
404
+				'format' => 'json',
405
+				'hasRecursiveSelection' => isset($parameters['hasRecursiveSelection']) ? (int)$parameters['hasRecursiveSelection'] : 0,
406
+				'fieldNameAndPath' => $this->getFieldNameAndPath(),
407
+				'language' => $language,
408
+				'matches' => array(
409
+					'uid' => $this->getObject()->getUid(),
410
+				),
411
+			),
412
+		);
413
+
414
+		return $this->getModuleLoader()->getModuleUrl($additionalParameters);
415
+	}
416
+
417
+	/**
418
+	 * Compute the value for the Content object according to a field name.
419
+	 *
420
+	 * @param \Fab\Vidi\Domain\Model\Content $object
421
+	 * @param string $fieldNameAndPath
422
+	 * @return string
423
+	 */
424
+	protected function resolveValue(Content $object, $fieldNameAndPath)
425
+	{
426
+
427
+		// Get the first part of the field name and
428
+		$fieldName = $this->getFieldPathResolver()->stripFieldName($fieldNameAndPath);
429
+
430
+		$value = $object[$fieldName];
431
+
432
+		// Relation but contains no data.
433
+		if (is_array($value) && empty($value)) {
434
+			$value = '';
435
+		} elseif ($value instanceof Content) {
436
+
437
+			$fieldNameOfForeignTable = $this->getFieldPathResolver()->stripFieldPath($fieldNameAndPath);
438
+
439
+			// true means the field name does not contains a path. "title" vs "metadata.title"
440
+			// Fetch the default label
441
+			if ($fieldNameOfForeignTable === $fieldName) {
442
+				$foreignTable = Tca::table($object->getDataType())->field($fieldName)->getForeignTable();
443
+				$fieldNameOfForeignTable = Tca::table($foreignTable)->getLabelField();
444
+			}
445
+
446
+			$value = $object[$fieldName][$fieldNameOfForeignTable];
447
+		}
448
+
449
+		return $value;
450
+	}
451
+
452
+	/**
453
+	 * Check whether a string contains HTML tags.
454
+	 *
455
+	 * @param string $string the content to be analyzed
456
+	 * @return boolean
457
+	 */
458
+	protected function hasHtml($string)
459
+	{
460
+		$result = false;
461
+
462
+		// We compare the length of the string with html tags and without html tags.
463
+		if (strlen($string) != strlen(strip_tags($string))) {
464
+			$result = true;
465
+		}
466
+		return $result;
467
+	}
468
+
469
+	/**
470
+	 * Check whether a string contains potential XSS.
471
+	 *
472
+	 * @param string $string the content to be analyzed
473
+	 * @return boolean
474
+	 */
475
+	protected function isClean($string)
476
+	{
477
+
478
+		// @todo implement me!
479
+		$result = true;
480
+		return $result;
481
+	}
482
+
483
+	/**
484
+	 * Process the value
485
+	 *
486
+	 * @todo implement me as a processor chain to be cleaner implementation wise. Look out at the performance however!
487
+	 *       e.g DefaultValueGridProcessor, TextAreaGridProcessor, ...
488
+	 *
489
+	 * @param string $value
490
+	 * @param \Fab\Vidi\Domain\Model\Content $object
491
+	 * @param string $fieldNameAndPath
492
+	 * @return string
493
+	 * @throws \Fab\Vidi\Exception\InvalidKeyInArrayException
494
+	 */
495
+	protected function processValue($value, Content $object, $fieldNameAndPath)
496
+	{
497
+
498
+		// Set default value if $field name correspond to the label of the table
499
+		$fieldName = $this->getFieldPathResolver()->stripFieldPath($fieldNameAndPath);
500
+		if (Tca::table($object->getDataType())->getLabelField() === $fieldName && empty($value)) {
501
+			$value = sprintf('[%s]', $this->getLabelService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.no_title', 1));
502
+		}
503
+
504
+		// Sanitize the value in case of "select" or "radio button".
505
+		if (is_scalar($value)) {
506
+			$fieldType = Tca::table($object->getDataType())->field($fieldNameAndPath)->getType();
507
+			if ($fieldType !== FieldType::TEXTAREA) {
508
+				$value = htmlspecialchars($value);
509
+			} elseif ($fieldType === FieldType::TEXTAREA && !$this->isClean($value)) {
510
+				$value = htmlspecialchars($value); // Avoid bad surprise, converts characters to HTML.
511
+			} elseif ($fieldType === FieldType::TEXTAREA && !$this->hasHtml($value)) {
512
+				$value = nl2br($value);
513
+			}
514
+		}
515
+
516
+		return $value;
517
+	}
518
+
519
+	/**
520
+	 * Possible value formatting.
521
+	 *
522
+	 * @param string $value
523
+	 * @param array $configuration
524
+	 * @return string
525
+	 * @throws \InvalidArgumentException
526
+	 */
527
+	protected function formatValue($value, array $configuration)
528
+	{
529
+		if (empty($configuration['format'])) {
530
+			return $value;
531
+		}
532
+		$className = $configuration['format'];
533
+
534
+		/** @var \Fab\Vidi\Formatter\FormatterInterface $formatter */
535
+		$formatter = GeneralUtility::makeInstance($className);
536
+		$value = $formatter->format($value);
537
+
538
+		return $value;
539
+	}
540
+
541
+	/**
542
+	 * Possible value wrapping.
543
+	 *
544
+	 * @param string $value
545
+	 * @param array $configuration
546
+	 * @return string
547
+	 */
548
+	protected function wrapValue($value, array $configuration)
549
+	{
550
+		if (!empty($configuration['wrap'])) {
551
+			$parts = explode('|', $configuration['wrap']);
552
+			$value = implode($value, $parts);
553
+		}
554
+		return $value;
555
+	}
556
+
557
+	/**
558
+	 * Tell whether the field in the context really exists.
559
+	 *
560
+	 * @return bool
561
+	 */
562
+	protected function fieldExists()
563
+	{
564
+		if (is_null($this->variables['hasField'])) {
565
+			$dataType = $this->getDataType();
566
+			$fieldName = $this->getFieldName();
567
+			$this->variables['hasField'] = Tca::table($dataType)->hasField($fieldName);
568
+		}
569
+		return $this->variables['hasField'];
570
+	}
571
+
572
+	/**
573
+	 * @return string
574
+	 */
575
+	protected function getDataType()
576
+	{
577
+		return $this->variables['dataType'];
578
+	}
579
+
580
+	/**
581
+	 * @return string
582
+	 */
583
+	protected function getFieldName()
584
+	{
585
+		return $this->variables['fieldName'];
586
+	}
587
+
588
+	/**
589
+	 * @return string
590
+	 */
591
+	protected function getFieldNameAndPath()
592
+	{
593
+		return $this->variables['fieldNameAndPath'];
594
+	}
595
+
596
+	/**
597
+	 * @return Content
598
+	 */
599
+	protected function getObject()
600
+	{
601
+		return $this->variables['object'];
602
+	}
603
+
604
+	/**
605
+	 * @return Content
606
+	 * @throws \InvalidArgumentException
607
+	 */
608
+	protected function getResolvedObject()
609
+	{
610
+		if (empty($this->variables['resolvedObject'])) {
611
+			$object = $this->getObject();
612
+			$fieldNameAndPath = $this->getFieldNameAndPath();
613
+			$this->variables['resolvedObject'] = $this->getContentObjectResolver()->getObject($object, $fieldNameAndPath);
614
+		}
615
+		return $this->variables['resolvedObject'];
616
+	}
617
+
618
+	/**
619
+	 * @return FieldPathResolver
620
+	 * @throws \InvalidArgumentException
621
+	 */
622
+	protected function getFieldPathResolver()
623
+	{
624
+		return GeneralUtility::makeInstance(FieldPathResolver::class);
625
+	}
626
+
627
+	/**
628
+	 * @return ContentObjectResolver
629
+	 * @throws \InvalidArgumentException
630
+	 */
631
+	protected function getContentObjectResolver()
632
+	{
633
+		return GeneralUtility::makeInstance(ContentObjectResolver::class);
634
+	}
635
+
636
+	/**
637
+	 * @return \TYPO3\CMS\Lang\LanguageService
638
+	 */
639
+	protected function getLabelService()
640
+	{
641
+		return $GLOBALS['LANG'];
642
+	}
643
+
644
+	/**
645
+	 * @return LanguageService
646
+	 * @throws \InvalidArgumentException
647
+	 */
648
+	protected function getLanguageService()
649
+	{
650
+		return GeneralUtility::makeInstance(LanguageService::class);
651
+	}
652 652
 
653 653
 }
Please login to merge, or discard this patch.