Completed
Push — master ( 892a3f...068784 )
by Fabien
50:28
created
Classes/ViewHelpers/Content/FindOneViewHelper.php 1 patch
Indentation   +159 added lines, -159 removed lines patch added patch discarded remove patch
@@ -23,164 +23,164 @@
 block discarded – undo
23 23
 class FindOneViewHelper extends AbstractViewHelper
24 24
 {
25 25
 
26
-    /**
27
-     * @return void
28
-     */
29
-    public function initializeArguments()
30
-    {
31
-        parent::initializeArguments();
32
-
33
-        $this->registerArgument('type', 'string', 'The content type', true, '');
34
-        $this->registerArgument('matches', 'array', 'Key / value array to be used as filter. The key corresponds to a field name.', false, []);
35
-        $this->registerArgument('identifier', 'int', 'The identifier of the object to be fetched.', false, 0);
36
-        $this->registerArgument('argumentName', 'string', 'The parameter name where to retrieve the identifier', false, 'tx_vidifrontend_pi1|uid');
37
-        $this->registerArgument('as', 'string', 'The alias object', false, 'object');
38
-    }
39
-
40
-    /**
41
-     * @return string Rendered string
42
-     * @api
43
-     */
44
-    public function render()
45
-    {
46
-        return static::renderStatic(
47
-            $this->arguments,
48
-            $this->buildRenderChildrenClosure(),
49
-            $this->renderingContext
50
-        );
51
-    }
52
-
53
-    /**
54
-     * @param array $arguments
55
-     * @param \Closure $renderChildrenClosure
56
-     * @param RenderingContextInterface $renderingContext
57
-     *
58
-     * @return string
59
-     */
60
-    public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
61
-    {
62
-
63
-        // Fetch the object
64
-        $matches = self::computeMatches($arguments);
65
-        $matcher = self::getMatcher($arguments['type'], $matches);
66
-
67
-        $contentRepository = ContentRepositoryFactory::getInstance($arguments['type']);
68
-        $object = $contentRepository->findOneBy($matcher);
69
-
70
-        $output = '';
71
-        if ($object) {
72
-            // Render children with "as" variable.
73
-            $templateVariableContainer = $renderingContext->getTemplateVariableContainer();
74
-            $templateVariableContainer->add($arguments['as'], $object);
75
-            $output = $renderChildrenClosure();
76
-            $templateVariableContainer->remove($arguments['as']);
77
-        }
78
-
79
-        return $output;
80
-    }
81
-
82
-    /**
83
-     * @param array $arguments
84
-     * @return array
85
-     */
86
-    protected static function computeMatches(array $arguments)
87
-    {
88
-
89
-        $matches = [];
90
-
91
-        $argumentValue = self::getArgumentValue($arguments['argumentName']);
92
-        if ($argumentValue > 0) {
93
-            $matches['uid'] = $argumentValue;
94
-        }
95
-
96
-        if ($arguments['matches']) {
97
-            $matches = $arguments['matches'];
98
-        }
99
-
100
-        if ($arguments['identifier'] > 0) {
101
-            $matches['uid'] = $arguments['identifier'];
102
-        }
103
-
104
-        // We want a default value in any case.
105
-        if (!$matches) {
106
-            $matches['uid'] = 0;
107
-        }
108
-        return $matches;
109
-    }
110
-
111
-    /**
112
-     * Returns a matcher object.
113
-     *
114
-     * @param string $dataType
115
-     * @param array $matches
116
-     * @return Matcher
117
-     */
118
-    protected static function getMatcher($dataType, array $matches = [])
119
-    {
120
-
121
-        /** @var $matcher Matcher */
122
-        $matcher = GeneralUtility::makeInstance(Matcher::class, [], $dataType);
123
-
124
-        foreach ($matches as $fieldNameAndPath => $value) {
125
-
126
-            // CSV values should be considered as "in" operator in Query, otherwise "equals".
127
-            $explodedValues = GeneralUtility::trimExplode(',', $value, true);
128
-
129
-            // The matching value contains a "1,2" as example
130
-            if (count($explodedValues) > 1) {
131
-
132
-                $resolvedDataType = self::getFieldPathResolver()->getDataType($fieldNameAndPath, $dataType);
133
-                $resolvedFieldName = self::getFieldPathResolver()->stripFieldPath($fieldNameAndPath, $dataType);
134
-
135
-                // "equals" if in presence of a relation.
136
-                // "in" if not a relation.
137
-                if (Tca::table($resolvedDataType)->field($resolvedFieldName)->hasRelation()) {
138
-                    foreach ($explodedValues as $explodedValue) {
139
-                        $matcher->equals($fieldNameAndPath, $explodedValue);
140
-                    }
141
-                } else {
142
-                    $matcher->in($fieldNameAndPath, $explodedValues);
143
-                }
144
-            } else {
145
-                $matcher->equals($fieldNameAndPath, $explodedValues[0]);
146
-            }
147
-        }
148
-
149
-        return $matcher;
150
-    }
151
-
152
-    /**
153
-     * @return FieldPathResolver
154
-     */
155
-    protected static function getFieldPathResolver()
156
-    {
157
-        return GeneralUtility::makeInstance(FieldPathResolver::class);
158
-    }
159
-
160
-    /**
161
-     * @param string $argumentName
162
-     * @return int
163
-     */
164
-    protected static function getArgumentValue($argumentName)
165
-    {
166
-
167
-        $value = ''; // default value
168
-
169
-        // Merge parameters
170
-        $parameters = GeneralUtility::_GET();
171
-        $post = GeneralUtility::_POST();
172
-        ArrayUtility::mergeRecursiveWithOverrule($parameters, $post);
173
-
174
-        // Traverse argument parts and retrieve value.
175
-        $argumentParts = GeneralUtility::trimExplode('|', $argumentName);
176
-        foreach ($argumentParts as $argumentPart) {
177
-            if (isset($parameters[$argumentPart])) {
178
-                $value = $parameters[$argumentPart];
179
-                $parameters = $value;
180
-            }
181
-        }
182
-
183
-        return (int)$value;
184
-    }
26
+	/**
27
+	 * @return void
28
+	 */
29
+	public function initializeArguments()
30
+	{
31
+		parent::initializeArguments();
32
+
33
+		$this->registerArgument('type', 'string', 'The content type', true, '');
34
+		$this->registerArgument('matches', 'array', 'Key / value array to be used as filter. The key corresponds to a field name.', false, []);
35
+		$this->registerArgument('identifier', 'int', 'The identifier of the object to be fetched.', false, 0);
36
+		$this->registerArgument('argumentName', 'string', 'The parameter name where to retrieve the identifier', false, 'tx_vidifrontend_pi1|uid');
37
+		$this->registerArgument('as', 'string', 'The alias object', false, 'object');
38
+	}
39
+
40
+	/**
41
+	 * @return string Rendered string
42
+	 * @api
43
+	 */
44
+	public function render()
45
+	{
46
+		return static::renderStatic(
47
+			$this->arguments,
48
+			$this->buildRenderChildrenClosure(),
49
+			$this->renderingContext
50
+		);
51
+	}
52
+
53
+	/**
54
+	 * @param array $arguments
55
+	 * @param \Closure $renderChildrenClosure
56
+	 * @param RenderingContextInterface $renderingContext
57
+	 *
58
+	 * @return string
59
+	 */
60
+	public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
61
+	{
62
+
63
+		// Fetch the object
64
+		$matches = self::computeMatches($arguments);
65
+		$matcher = self::getMatcher($arguments['type'], $matches);
66
+
67
+		$contentRepository = ContentRepositoryFactory::getInstance($arguments['type']);
68
+		$object = $contentRepository->findOneBy($matcher);
69
+
70
+		$output = '';
71
+		if ($object) {
72
+			// Render children with "as" variable.
73
+			$templateVariableContainer = $renderingContext->getTemplateVariableContainer();
74
+			$templateVariableContainer->add($arguments['as'], $object);
75
+			$output = $renderChildrenClosure();
76
+			$templateVariableContainer->remove($arguments['as']);
77
+		}
78
+
79
+		return $output;
80
+	}
81
+
82
+	/**
83
+	 * @param array $arguments
84
+	 * @return array
85
+	 */
86
+	protected static function computeMatches(array $arguments)
87
+	{
88
+
89
+		$matches = [];
90
+
91
+		$argumentValue = self::getArgumentValue($arguments['argumentName']);
92
+		if ($argumentValue > 0) {
93
+			$matches['uid'] = $argumentValue;
94
+		}
95
+
96
+		if ($arguments['matches']) {
97
+			$matches = $arguments['matches'];
98
+		}
99
+
100
+		if ($arguments['identifier'] > 0) {
101
+			$matches['uid'] = $arguments['identifier'];
102
+		}
103
+
104
+		// We want a default value in any case.
105
+		if (!$matches) {
106
+			$matches['uid'] = 0;
107
+		}
108
+		return $matches;
109
+	}
110
+
111
+	/**
112
+	 * Returns a matcher object.
113
+	 *
114
+	 * @param string $dataType
115
+	 * @param array $matches
116
+	 * @return Matcher
117
+	 */
118
+	protected static function getMatcher($dataType, array $matches = [])
119
+	{
120
+
121
+		/** @var $matcher Matcher */
122
+		$matcher = GeneralUtility::makeInstance(Matcher::class, [], $dataType);
123
+
124
+		foreach ($matches as $fieldNameAndPath => $value) {
125
+
126
+			// CSV values should be considered as "in" operator in Query, otherwise "equals".
127
+			$explodedValues = GeneralUtility::trimExplode(',', $value, true);
128
+
129
+			// The matching value contains a "1,2" as example
130
+			if (count($explodedValues) > 1) {
131
+
132
+				$resolvedDataType = self::getFieldPathResolver()->getDataType($fieldNameAndPath, $dataType);
133
+				$resolvedFieldName = self::getFieldPathResolver()->stripFieldPath($fieldNameAndPath, $dataType);
134
+
135
+				// "equals" if in presence of a relation.
136
+				// "in" if not a relation.
137
+				if (Tca::table($resolvedDataType)->field($resolvedFieldName)->hasRelation()) {
138
+					foreach ($explodedValues as $explodedValue) {
139
+						$matcher->equals($fieldNameAndPath, $explodedValue);
140
+					}
141
+				} else {
142
+					$matcher->in($fieldNameAndPath, $explodedValues);
143
+				}
144
+			} else {
145
+				$matcher->equals($fieldNameAndPath, $explodedValues[0]);
146
+			}
147
+		}
148
+
149
+		return $matcher;
150
+	}
151
+
152
+	/**
153
+	 * @return FieldPathResolver
154
+	 */
155
+	protected static function getFieldPathResolver()
156
+	{
157
+		return GeneralUtility::makeInstance(FieldPathResolver::class);
158
+	}
159
+
160
+	/**
161
+	 * @param string $argumentName
162
+	 * @return int
163
+	 */
164
+	protected static function getArgumentValue($argumentName)
165
+	{
166
+
167
+		$value = ''; // default value
168
+
169
+		// Merge parameters
170
+		$parameters = GeneralUtility::_GET();
171
+		$post = GeneralUtility::_POST();
172
+		ArrayUtility::mergeRecursiveWithOverrule($parameters, $post);
173
+
174
+		// Traverse argument parts and retrieve value.
175
+		$argumentParts = GeneralUtility::trimExplode('|', $argumentName);
176
+		foreach ($argumentParts as $argumentPart) {
177
+			if (isset($parameters[$argumentPart])) {
178
+				$value = $parameters[$argumentPart];
179
+				$parameters = $value;
180
+			}
181
+		}
182
+
183
+		return (int)$value;
184
+	}
185 185
 
186 186
 }
Please login to merge, or discard this patch.
Classes/ViewHelpers/Result/ToJsonViewHelper.php 1 patch
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -18,54 +18,54 @@
 block discarded – undo
18 18
 class ToJsonViewHelper extends AbstractViewHelper
19 19
 {
20 20
 
21
-    /**
22
-     * Render a Json response
23
-     *
24
-     */
25
-    public function render()
26
-    {
27
-        $objects = $this->templateVariableContainer->get('objects');
28
-        $columns = $this->templateVariableContainer->get('columns');
29
-        $output = array(
30
-            'sEcho' => $this->getNextTransactionId(),
31
-            'iTotalRecords' => $this->templateVariableContainer->get('numberOfObjects'),
32
-            'iTotalDisplayRecords' => $this->templateVariableContainer->get('numberOfObjects'),
33
-            'iNumberOfRecords' => count($objects),
34
-            'aaData' => $this->getRowsView()->render($objects, $columns),
35
-        );
21
+	/**
22
+	 * Render a Json response
23
+	 *
24
+	 */
25
+	public function render()
26
+	{
27
+		$objects = $this->templateVariableContainer->get('objects');
28
+		$columns = $this->templateVariableContainer->get('columns');
29
+		$output = array(
30
+			'sEcho' => $this->getNextTransactionId(),
31
+			'iTotalRecords' => $this->templateVariableContainer->get('numberOfObjects'),
32
+			'iTotalDisplayRecords' => $this->templateVariableContainer->get('numberOfObjects'),
33
+			'iNumberOfRecords' => count($objects),
34
+			'aaData' => $this->getRowsView()->render($objects, $columns),
35
+		);
36 36
 
37
-        $this->setHttpHeaders();
38
-        print json_encode($output);
39
-    }
37
+		$this->setHttpHeaders();
38
+		print json_encode($output);
39
+	}
40 40
 
41
-    /**
42
-     * @return int
43
-     */
44
-    protected function getNextTransactionId()
45
-    {
46
-        $transaction = 0;
47
-        if (GeneralUtility::_GET('sEcho')) {
48
-            $transaction = (int)GeneralUtility::_GET('sEcho') + 1;
49
-        }
50
-        return $transaction;
51
-    }
41
+	/**
42
+	 * @return int
43
+	 */
44
+	protected function getNextTransactionId()
45
+	{
46
+		$transaction = 0;
47
+		if (GeneralUtility::_GET('sEcho')) {
48
+			$transaction = (int)GeneralUtility::_GET('sEcho') + 1;
49
+		}
50
+		return $transaction;
51
+	}
52 52
 
53
-    /**
54
-     * @return void
55
-     * @throws \InvalidArgumentException
56
-     */
57
-    protected function setHttpHeaders()
58
-    {
59
-        /** @var Response $response */
60
-        $response = $this->templateVariableContainer->get('response');
61
-        $response->withHeader('Content-Type', 'application/json');
62
-    }
53
+	/**
54
+	 * @return void
55
+	 * @throws \InvalidArgumentException
56
+	 */
57
+	protected function setHttpHeaders()
58
+	{
59
+		/** @var Response $response */
60
+		$response = $this->templateVariableContainer->get('response');
61
+		$response->withHeader('Content-Type', 'application/json');
62
+	}
63 63
 
64
-    /**
65
-     * @return Rows|object
66
-     */
67
-    protected function getRowsView()
68
-    {
69
-        return GeneralUtility::makeInstance(Rows::class);
70
-    }
64
+	/**
65
+	 * @return Rows|object
66
+	 */
67
+	protected function getRowsView()
68
+	{
69
+		return GeneralUtility::makeInstance(Rows::class);
70
+	}
71 71
 }
Please login to merge, or discard this patch.
Classes/ViewHelpers/Result/ToXmlViewHelper.php 2 patches
Indentation   +101 added lines, -101 removed lines patch added patch discarded remove patch
@@ -17,115 +17,115 @@
 block discarded – undo
17 17
 class ToXmlViewHelper extends AbstractToFormatViewHelper
18 18
 {
19 19
 
20
-    /**
21
-     * Render an XML export.
22
-     *
23
-     */
24
-    public function render()
25
-    {
26
-
27
-        $objects = $this->templateVariableContainer->get('objects');
28
-
29
-        // Make sure we have something to process...
30
-        if (!empty($objects)) {
31
-
32
-            // Initialization step.
33
-            $this->initializeEnvironment($objects);
34
-            $this->exportFileNameAndPath .= '.xml'; // add extension to the file.
35
-
36
-            // Write the exported data to a XML file.
37
-            $this->writeXmlFile($objects);
38
-
39
-            // We must generate a zip archive since there are files included.
40
-            if ($this->hasCollectedFiles()) {
41
-
42
-                $this->writeZipFile();
43
-                $this->sendZipHttpHeaders();
44
-
45
-                readfile($this->zipFileNameAndPath);
46
-            } else {
47
-                $this->sendXmlHttpHeaders();
48
-                readfile($this->exportFileNameAndPath);
49
-            }
50
-
51
-            GeneralUtility::rmdir($this->temporaryDirectory, true);
52
-        }
53
-    }
54
-
55
-    /**
56
-     * Write the XML file to a temporary location.
57
-     *
58
-     * @param array $objects
59
-     * @return void
60
-     */
61
-    protected function writeXmlFile(array $objects)
62
-    {
63
-
64
-        // Get first object of $objects to check whether it contains possible files to include.
65
-        /** @var Content $object */
66
-        $object = reset($objects);
67
-        $this->checkWhetherObjectMayIncludeFiles($object);
68
-
69
-        $items = [];
70
-        foreach ($objects as $object) {
71
-            if ($this->hasFileFields()) {
72
-                $this->collectFiles($object);
73
-            }
74
-            $items[] = $object->toValues();
75
-        }
76
-
77
-        $xml = new \SimpleXMLElement('<items/>');
78
-        $xml = $this->arrayToXml($items, $xml);
79
-        file_put_contents($this->exportFileNameAndPath, $this->formatXml($xml->asXML()));
80
-    }
81
-
82
-    /*
20
+	/**
21
+	 * Render an XML export.
22
+	 *
23
+	 */
24
+	public function render()
25
+	{
26
+
27
+		$objects = $this->templateVariableContainer->get('objects');
28
+
29
+		// Make sure we have something to process...
30
+		if (!empty($objects)) {
31
+
32
+			// Initialization step.
33
+			$this->initializeEnvironment($objects);
34
+			$this->exportFileNameAndPath .= '.xml'; // add extension to the file.
35
+
36
+			// Write the exported data to a XML file.
37
+			$this->writeXmlFile($objects);
38
+
39
+			// We must generate a zip archive since there are files included.
40
+			if ($this->hasCollectedFiles()) {
41
+
42
+				$this->writeZipFile();
43
+				$this->sendZipHttpHeaders();
44
+
45
+				readfile($this->zipFileNameAndPath);
46
+			} else {
47
+				$this->sendXmlHttpHeaders();
48
+				readfile($this->exportFileNameAndPath);
49
+			}
50
+
51
+			GeneralUtility::rmdir($this->temporaryDirectory, true);
52
+		}
53
+	}
54
+
55
+	/**
56
+	 * Write the XML file to a temporary location.
57
+	 *
58
+	 * @param array $objects
59
+	 * @return void
60
+	 */
61
+	protected function writeXmlFile(array $objects)
62
+	{
63
+
64
+		// Get first object of $objects to check whether it contains possible files to include.
65
+		/** @var Content $object */
66
+		$object = reset($objects);
67
+		$this->checkWhetherObjectMayIncludeFiles($object);
68
+
69
+		$items = [];
70
+		foreach ($objects as $object) {
71
+			if ($this->hasFileFields()) {
72
+				$this->collectFiles($object);
73
+			}
74
+			$items[] = $object->toValues();
75
+		}
76
+
77
+		$xml = new \SimpleXMLElement('<items/>');
78
+		$xml = $this->arrayToXml($items, $xml);
79
+		file_put_contents($this->exportFileNameAndPath, $this->formatXml($xml->asXML()));
80
+	}
81
+
82
+	/*
83 83
      * Convert an array to xml
84 84
      *
85 85
      * @return \SimpleXMLElement
86 86
      */
87
-    protected function arrayToXml($array, \SimpleXMLElement $xml)
88
-    {
89
-        foreach ($array as $key => $value) {
90
-            if (is_array($value)) {
91
-                $key = is_numeric($key) ? 'item' : $key;
92
-                $subNode = $xml->addChild($key);
93
-                $this->arrayToXml($value, $subNode);
94
-            } else {
95
-                $key = is_numeric($key) ? 'item' : $key;
96
-                $xml->addChild($key, "$value");
97
-            }
98
-        }
99
-        return $xml;
100
-    }
101
-
102
-    /*
87
+	protected function arrayToXml($array, \SimpleXMLElement $xml)
88
+	{
89
+		foreach ($array as $key => $value) {
90
+			if (is_array($value)) {
91
+				$key = is_numeric($key) ? 'item' : $key;
92
+				$subNode = $xml->addChild($key);
93
+				$this->arrayToXml($value, $subNode);
94
+			} else {
95
+				$key = is_numeric($key) ? 'item' : $key;
96
+				$xml->addChild($key, "$value");
97
+			}
98
+		}
99
+		return $xml;
100
+	}
101
+
102
+	/*
103 103
      * Format the XML so that is looks human friendly.
104 104
      *
105 105
      * @param string $xml
106 106
      * @return string
107 107
      */
108
-    protected function formatXml($xml)
109
-    {
110
-        $dom = new \DOMDocument("1.0");
111
-        $dom->preserveWhiteSpace = false;
112
-        $dom->formatOutput = true;
113
-        $dom->loadXML($xml);
114
-        return $dom->saveXML();
115
-    }
116
-
117
-    /**
118
-     * @return void
119
-     */
120
-    protected function sendXmlHttpHeaders()
121
-    {
122
-
123
-        /** @var Response $response */
124
-        $response = $this->templateVariableContainer->get('response');
125
-        $response->withHeader('Content-Type', 'application/xml');
126
-        $response->withHeader('Content-Disposition', 'attachment; filename="' . basename($this->exportFileNameAndPath) . '"');
127
-        $response->withHeader('Content-Length', filesize($this->exportFileNameAndPath));
128
-        $response->withHeader('Content-Description', 'File Transfer');
129
-    }
108
+	protected function formatXml($xml)
109
+	{
110
+		$dom = new \DOMDocument("1.0");
111
+		$dom->preserveWhiteSpace = false;
112
+		$dom->formatOutput = true;
113
+		$dom->loadXML($xml);
114
+		return $dom->saveXML();
115
+	}
116
+
117
+	/**
118
+	 * @return void
119
+	 */
120
+	protected function sendXmlHttpHeaders()
121
+	{
122
+
123
+		/** @var Response $response */
124
+		$response = $this->templateVariableContainer->get('response');
125
+		$response->withHeader('Content-Type', 'application/xml');
126
+		$response->withHeader('Content-Disposition', 'attachment; filename="' . basename($this->exportFileNameAndPath) . '"');
127
+		$response->withHeader('Content-Length', filesize($this->exportFileNameAndPath));
128
+		$response->withHeader('Content-Description', 'File Transfer');
129
+	}
130 130
 
131 131
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -123,7 +123,7 @@
 block discarded – undo
123 123
         /** @var Response $response */
124 124
         $response = $this->templateVariableContainer->get('response');
125 125
         $response->withHeader('Content-Type', 'application/xml');
126
-        $response->withHeader('Content-Disposition', 'attachment; filename="' . basename($this->exportFileNameAndPath) . '"');
126
+        $response->withHeader('Content-Disposition', 'attachment; filename="'.basename($this->exportFileNameAndPath).'"');
127 127
         $response->withHeader('Content-Length', filesize($this->exportFileNameAndPath));
128 128
         $response->withHeader('Content-Description', 'File Transfer');
129 129
     }
Please login to merge, or discard this patch.
Classes/ViewHelpers/Result/AbstractToFormatViewHelper.php 2 patches
Indentation   +152 added lines, -152 removed lines patch added patch discarded remove patch
@@ -24,157 +24,157 @@
 block discarded – undo
24 24
 abstract class AbstractToFormatViewHelper extends AbstractViewHelper
25 25
 {
26 26
 
27
-    /**
28
-     * Store fields of type "file".
29
-     *
30
-     * @var array
31
-     */
32
-    protected $fileTypeProperties = [];
33
-
34
-    /**
35
-     * @var File[]
36
-     */
37
-    protected $collectedFiles = [];
38
-
39
-    /**
40
-     * @var string
41
-     */
42
-    protected $exportFileNameAndPath;
43
-
44
-    /**
45
-     * @var string
46
-     */
47
-    protected $zipFileNameAndPath;
48
-
49
-    /**
50
-     * @var string
51
-     */
52
-    protected $temporaryDirectory;
53
-
54
-
55
-    /**
56
-     * Write the zip file to a temporary location.
57
-     *
58
-     * @return void
59
-     * @throws \RuntimeException
60
-     */
61
-    protected function writeZipFile()
62
-    {
63
-
64
-        $zip = new \ZipArchive();
65
-        $zip->open($this->zipFileNameAndPath, \ZipArchive::CREATE);
66
-
67
-        // Add the CSV content into the zipball.
68
-        $zip->addFile($this->exportFileNameAndPath, basename($this->exportFileNameAndPath));
69
-
70
-        // Add the files into the zipball.
71
-        foreach ($this->collectedFiles as $file) {
72
-            $zip->addFile($file->getForLocalProcessing(false), $file->getIdentifier());
73
-        }
74
-
75
-        $zip->close();
76
-    }
77
-
78
-    /**
79
-     * Initialize some properties
80
-     *
81
-     * @param array $objects
82
-     * @return void
83
-     */
84
-    protected function initializeEnvironment(array $objects)
85
-    {
86
-
87
-        /** @var Content $object */
88
-        $object = reset($objects);
89
-
90
-        $this->temporaryDirectory = Environment::getPublicPath() . '/typo3temp/' . uniqid() . '/';
91
-        GeneralUtility::mkdir($this->temporaryDirectory);
92
-
93
-        // Compute file name and path variable
94
-        $this->exportFileNameAndPath = $this->temporaryDirectory . $object->getDataType() . '-' . date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy']);
95
-
96
-        // Compute file name and path variable for zip
97
-        $zipFileName = $object->getDataType() . '-' . date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy']) . '.zip';
98
-        $this->zipFileNameAndPath = $this->temporaryDirectory . $zipFileName;
99
-    }
100
-
101
-    /**
102
-     * Fetch the files given an object.
103
-     *
104
-     * @param Content $object
105
-     * @return void
106
-     */
107
-    protected function collectFiles(Content $object)
108
-    {
109
-        foreach ($this->fileTypeProperties as $property) {
110
-            $files = FileReferenceService::getInstance()->findReferencedBy($property, $object);
111
-            foreach ($files as $file) {
112
-                $this->collectedFiles[$file->getUid()] = $file;
113
-            }
114
-        }
115
-    }
116
-
117
-    /**
118
-     * Tells whether the object has fields containing files.
119
-     *
120
-     * @return boolean
121
-     */
122
-    protected function hasCollectedFiles()
123
-    {
124
-        return !empty($this->collectedFiles);
125
-    }
126
-
127
-    /**
128
-     * Tells whether the object has fields containing files.
129
-     *
130
-     * @return boolean
131
-     */
132
-    protected function hasFileFields()
133
-    {
134
-        return !empty($this->fileTypeProperties);
135
-    }
136
-
137
-    /**
138
-     * Check whether the given object is meant to include files in some fields.
139
-     *
140
-     * @param Content $object
141
-     */
142
-    protected function checkWhetherObjectMayIncludeFiles(Content $object)
143
-    {
144
-        if (Tca::grid($object->getDataType())->areFilesIncludedInExport()) {
145
-            foreach ($object->toFields() as $fieldName) {
146
-                $fieldType = Tca::table($object->getDataType())->field($fieldName)->getType();
147
-
148
-                if ($fieldType === FieldType::FILE) {
149
-                    $this->fileTypeProperties[] = GeneralUtility::camelCaseToLowerCaseUnderscored($fieldName);
150
-                }
151
-            }
152
-        }
153
-    }
154
-
155
-    /**
156
-     * @return void
157
-     */
158
-    protected function sendZipHttpHeaders()
159
-    {
160
-        /** @var Response $response */
161
-        $response = $this->templateVariableContainer->get('response');
162
-        $response->withHeader('Pragma', 'public');
163
-        $response->withHeader('Expires', '0');
164
-        $response->withHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0');
165
-        $response->withHeader('Content-Type', 'application/zip');
166
-        $response->withHeader('Content-Disposition', 'attachment; filename="' . basename($this->zipFileNameAndPath) . '"');
167
-        $response->withHeader('Content-Length', filesize($this->zipFileNameAndPath));
168
-        $response->withHeader('Content-Description', 'File Transfer');
169
-        $response->withHeader('Content-Transfer-Encoding', 'binary');
170
-    }
171
-
172
-    /**
173
-     * @return Rows|object
174
-     */
175
-    protected function getRowsView()
176
-    {
177
-        return GeneralUtility::makeInstance(Rows::class);
178
-    }
27
+	/**
28
+	 * Store fields of type "file".
29
+	 *
30
+	 * @var array
31
+	 */
32
+	protected $fileTypeProperties = [];
33
+
34
+	/**
35
+	 * @var File[]
36
+	 */
37
+	protected $collectedFiles = [];
38
+
39
+	/**
40
+	 * @var string
41
+	 */
42
+	protected $exportFileNameAndPath;
43
+
44
+	/**
45
+	 * @var string
46
+	 */
47
+	protected $zipFileNameAndPath;
48
+
49
+	/**
50
+	 * @var string
51
+	 */
52
+	protected $temporaryDirectory;
53
+
54
+
55
+	/**
56
+	 * Write the zip file to a temporary location.
57
+	 *
58
+	 * @return void
59
+	 * @throws \RuntimeException
60
+	 */
61
+	protected function writeZipFile()
62
+	{
63
+
64
+		$zip = new \ZipArchive();
65
+		$zip->open($this->zipFileNameAndPath, \ZipArchive::CREATE);
66
+
67
+		// Add the CSV content into the zipball.
68
+		$zip->addFile($this->exportFileNameAndPath, basename($this->exportFileNameAndPath));
69
+
70
+		// Add the files into the zipball.
71
+		foreach ($this->collectedFiles as $file) {
72
+			$zip->addFile($file->getForLocalProcessing(false), $file->getIdentifier());
73
+		}
74
+
75
+		$zip->close();
76
+	}
77
+
78
+	/**
79
+	 * Initialize some properties
80
+	 *
81
+	 * @param array $objects
82
+	 * @return void
83
+	 */
84
+	protected function initializeEnvironment(array $objects)
85
+	{
86
+
87
+		/** @var Content $object */
88
+		$object = reset($objects);
89
+
90
+		$this->temporaryDirectory = Environment::getPublicPath() . '/typo3temp/' . uniqid() . '/';
91
+		GeneralUtility::mkdir($this->temporaryDirectory);
92
+
93
+		// Compute file name and path variable
94
+		$this->exportFileNameAndPath = $this->temporaryDirectory . $object->getDataType() . '-' . date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy']);
95
+
96
+		// Compute file name and path variable for zip
97
+		$zipFileName = $object->getDataType() . '-' . date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy']) . '.zip';
98
+		$this->zipFileNameAndPath = $this->temporaryDirectory . $zipFileName;
99
+	}
100
+
101
+	/**
102
+	 * Fetch the files given an object.
103
+	 *
104
+	 * @param Content $object
105
+	 * @return void
106
+	 */
107
+	protected function collectFiles(Content $object)
108
+	{
109
+		foreach ($this->fileTypeProperties as $property) {
110
+			$files = FileReferenceService::getInstance()->findReferencedBy($property, $object);
111
+			foreach ($files as $file) {
112
+				$this->collectedFiles[$file->getUid()] = $file;
113
+			}
114
+		}
115
+	}
116
+
117
+	/**
118
+	 * Tells whether the object has fields containing files.
119
+	 *
120
+	 * @return boolean
121
+	 */
122
+	protected function hasCollectedFiles()
123
+	{
124
+		return !empty($this->collectedFiles);
125
+	}
126
+
127
+	/**
128
+	 * Tells whether the object has fields containing files.
129
+	 *
130
+	 * @return boolean
131
+	 */
132
+	protected function hasFileFields()
133
+	{
134
+		return !empty($this->fileTypeProperties);
135
+	}
136
+
137
+	/**
138
+	 * Check whether the given object is meant to include files in some fields.
139
+	 *
140
+	 * @param Content $object
141
+	 */
142
+	protected function checkWhetherObjectMayIncludeFiles(Content $object)
143
+	{
144
+		if (Tca::grid($object->getDataType())->areFilesIncludedInExport()) {
145
+			foreach ($object->toFields() as $fieldName) {
146
+				$fieldType = Tca::table($object->getDataType())->field($fieldName)->getType();
147
+
148
+				if ($fieldType === FieldType::FILE) {
149
+					$this->fileTypeProperties[] = GeneralUtility::camelCaseToLowerCaseUnderscored($fieldName);
150
+				}
151
+			}
152
+		}
153
+	}
154
+
155
+	/**
156
+	 * @return void
157
+	 */
158
+	protected function sendZipHttpHeaders()
159
+	{
160
+		/** @var Response $response */
161
+		$response = $this->templateVariableContainer->get('response');
162
+		$response->withHeader('Pragma', 'public');
163
+		$response->withHeader('Expires', '0');
164
+		$response->withHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0');
165
+		$response->withHeader('Content-Type', 'application/zip');
166
+		$response->withHeader('Content-Disposition', 'attachment; filename="' . basename($this->zipFileNameAndPath) . '"');
167
+		$response->withHeader('Content-Length', filesize($this->zipFileNameAndPath));
168
+		$response->withHeader('Content-Description', 'File Transfer');
169
+		$response->withHeader('Content-Transfer-Encoding', 'binary');
170
+	}
171
+
172
+	/**
173
+	 * @return Rows|object
174
+	 */
175
+	protected function getRowsView()
176
+	{
177
+		return GeneralUtility::makeInstance(Rows::class);
178
+	}
179 179
 
180 180
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -87,15 +87,15 @@  discard block
 block discarded – undo
87 87
         /** @var Content $object */
88 88
         $object = reset($objects);
89 89
 
90
-        $this->temporaryDirectory = Environment::getPublicPath() . '/typo3temp/' . uniqid() . '/';
90
+        $this->temporaryDirectory = Environment::getPublicPath().'/typo3temp/'.uniqid().'/';
91 91
         GeneralUtility::mkdir($this->temporaryDirectory);
92 92
 
93 93
         // Compute file name and path variable
94
-        $this->exportFileNameAndPath = $this->temporaryDirectory . $object->getDataType() . '-' . date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy']);
94
+        $this->exportFileNameAndPath = $this->temporaryDirectory.$object->getDataType().'-'.date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy']);
95 95
 
96 96
         // Compute file name and path variable for zip
97
-        $zipFileName = $object->getDataType() . '-' . date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy']) . '.zip';
98
-        $this->zipFileNameAndPath = $this->temporaryDirectory . $zipFileName;
97
+        $zipFileName = $object->getDataType().'-'.date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy']).'.zip';
98
+        $this->zipFileNameAndPath = $this->temporaryDirectory.$zipFileName;
99 99
     }
100 100
 
101 101
     /**
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
         $response->withHeader('Expires', '0');
164 164
         $response->withHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0');
165 165
         $response->withHeader('Content-Type', 'application/zip');
166
-        $response->withHeader('Content-Disposition', 'attachment; filename="' . basename($this->zipFileNameAndPath) . '"');
166
+        $response->withHeader('Content-Disposition', 'attachment; filename="'.basename($this->zipFileNameAndPath).'"');
167 167
         $response->withHeader('Content-Length', filesize($this->zipFileNameAndPath));
168 168
         $response->withHeader('Content-Description', 'File Transfer');
169 169
         $response->withHeader('Content-Transfer-Encoding', 'binary');
Please login to merge, or discard this patch.
Classes/ViewHelpers/Result/ToCsvViewHelper.php 2 patches
Indentation   +84 added lines, -84 removed lines patch added patch discarded remove patch
@@ -17,89 +17,89 @@
 block discarded – undo
17 17
 class ToCsvViewHelper extends AbstractToFormatViewHelper
18 18
 {
19 19
 
20
-    /**
21
-     * Render a CSV export request.
22
-     *
23
-     */
24
-    public function render()
25
-    {
26
-        $objects = $this->templateVariableContainer->get('objects');
27
-
28
-        // Make sure we have something to process...
29
-        if (!empty($objects)) {
30
-
31
-            // Initialization step.
32
-            $this->initializeEnvironment($objects);
33
-            $this->exportFileNameAndPath .= '.csv'; // add extension to the file.
34
-
35
-            // Write the exported data to a CSV file.
36
-            $this->writeCsvFile($objects);
37
-
38
-            // We must generate a zip archive since there are files included.
39
-            if ($this->hasCollectedFiles()) {
40
-
41
-                $this->writeZipFile();
42
-                $this->sendZipHttpHeaders();
43
-
44
-                readfile($this->zipFileNameAndPath);
45
-            } else {
46
-                $this->sendCsvHttpHeaders();
47
-                readfile($this->exportFileNameAndPath);
48
-            }
49
-
50
-            GeneralUtility::rmdir($this->temporaryDirectory, true);
51
-        }
52
-    }
53
-
54
-    /**
55
-     * Write the CSV file to a temporary location.
56
-     *
57
-     * @param array $objects
58
-     */
59
-    protected function writeCsvFile(array $objects)
60
-    {
61
-        // Create a file pointer
62
-        $output = fopen($this->exportFileNameAndPath, 'w');
63
-
64
-        // Handle CSV header, get the first object and get the list of fields.
65
-        /** @var Content $object */
66
-        $object = reset($objects);
67
-        fputcsv($output, $object->toFields());
68
-        $this->checkWhetherObjectMayIncludeFiles($object);
69
-
70
-        foreach ($objects as $object) {
71
-            if ($this->hasFileFields()) {
72
-                $this->collectFiles($object);
73
-            }
74
-
75
-            // Make sure we have a flat array of values for the CSV purpose.
76
-            $flattenValues = [];
77
-            foreach ($object->toValues() as $fieldName => $value) {
78
-                if (is_array($value)) {
79
-                    $flattenValues[$fieldName] = implode(', ', $value);
80
-                } else {
81
-                    $flattenValues[$fieldName] = str_replace("\n", "\r", $value); // for Excel purpose.
82
-                }
83
-            }
84
-
85
-            fputcsv($output, $flattenValues);
86
-        }
87
-
88
-        // close file handler
89
-        fclose($output);
90
-    }
91
-
92
-    /**
93
-     * @return void
94
-     */
95
-    protected function sendCsvHttpHeaders()
96
-    {
97
-        /** @var Response $response */
98
-        $response = $this->templateVariableContainer->get('response');
99
-        $response->withHeader('Content-Type', 'application/csv');
100
-        $response->withHeader('Content-Disposition', 'attachment; filename="' . basename($this->exportFileNameAndPath) . '"');
101
-        $response->withHeader('Content-Length', filesize($this->exportFileNameAndPath));
102
-        $response->withHeader('Content-Description', 'File Transfer');
103
-    }
20
+	/**
21
+	 * Render a CSV export request.
22
+	 *
23
+	 */
24
+	public function render()
25
+	{
26
+		$objects = $this->templateVariableContainer->get('objects');
27
+
28
+		// Make sure we have something to process...
29
+		if (!empty($objects)) {
30
+
31
+			// Initialization step.
32
+			$this->initializeEnvironment($objects);
33
+			$this->exportFileNameAndPath .= '.csv'; // add extension to the file.
34
+
35
+			// Write the exported data to a CSV file.
36
+			$this->writeCsvFile($objects);
37
+
38
+			// We must generate a zip archive since there are files included.
39
+			if ($this->hasCollectedFiles()) {
40
+
41
+				$this->writeZipFile();
42
+				$this->sendZipHttpHeaders();
43
+
44
+				readfile($this->zipFileNameAndPath);
45
+			} else {
46
+				$this->sendCsvHttpHeaders();
47
+				readfile($this->exportFileNameAndPath);
48
+			}
49
+
50
+			GeneralUtility::rmdir($this->temporaryDirectory, true);
51
+		}
52
+	}
53
+
54
+	/**
55
+	 * Write the CSV file to a temporary location.
56
+	 *
57
+	 * @param array $objects
58
+	 */
59
+	protected function writeCsvFile(array $objects)
60
+	{
61
+		// Create a file pointer
62
+		$output = fopen($this->exportFileNameAndPath, 'w');
63
+
64
+		// Handle CSV header, get the first object and get the list of fields.
65
+		/** @var Content $object */
66
+		$object = reset($objects);
67
+		fputcsv($output, $object->toFields());
68
+		$this->checkWhetherObjectMayIncludeFiles($object);
69
+
70
+		foreach ($objects as $object) {
71
+			if ($this->hasFileFields()) {
72
+				$this->collectFiles($object);
73
+			}
74
+
75
+			// Make sure we have a flat array of values for the CSV purpose.
76
+			$flattenValues = [];
77
+			foreach ($object->toValues() as $fieldName => $value) {
78
+				if (is_array($value)) {
79
+					$flattenValues[$fieldName] = implode(', ', $value);
80
+				} else {
81
+					$flattenValues[$fieldName] = str_replace("\n", "\r", $value); // for Excel purpose.
82
+				}
83
+			}
84
+
85
+			fputcsv($output, $flattenValues);
86
+		}
87
+
88
+		// close file handler
89
+		fclose($output);
90
+	}
91
+
92
+	/**
93
+	 * @return void
94
+	 */
95
+	protected function sendCsvHttpHeaders()
96
+	{
97
+		/** @var Response $response */
98
+		$response = $this->templateVariableContainer->get('response');
99
+		$response->withHeader('Content-Type', 'application/csv');
100
+		$response->withHeader('Content-Disposition', 'attachment; filename="' . basename($this->exportFileNameAndPath) . '"');
101
+		$response->withHeader('Content-Length', filesize($this->exportFileNameAndPath));
102
+		$response->withHeader('Content-Description', 'File Transfer');
103
+	}
104 104
 
105 105
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -97,7 +97,7 @@
 block discarded – undo
97 97
         /** @var Response $response */
98 98
         $response = $this->templateVariableContainer->get('response');
99 99
         $response->withHeader('Content-Type', 'application/csv');
100
-        $response->withHeader('Content-Disposition', 'attachment; filename="' . basename($this->exportFileNameAndPath) . '"');
100
+        $response->withHeader('Content-Disposition', 'attachment; filename="'.basename($this->exportFileNameAndPath).'"');
101 101
         $response->withHeader('Content-Length', filesize($this->exportFileNameAndPath));
102 102
         $response->withHeader('Content-Description', 'File Transfer');
103 103
     }
Please login to merge, or discard this patch.
Classes/ViewHelpers/PublicPathViewHelper.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -16,13 +16,13 @@
 block discarded – undo
16 16
 class PublicPathViewHelper extends AbstractViewHelper
17 17
 {
18 18
 
19
-    /**
20
-     * Returns the public path to Vidi extension.
21
-     *
22
-     * @return string
23
-     */
24
-    public function render()
25
-    {
26
-        return ExtensionManagementUtility::siteRelPath('vidi');
27
-    }
19
+	/**
20
+	 * Returns the public path to Vidi extension.
21
+	 *
22
+	 * @return string
23
+	 */
24
+	public function render()
25
+	{
26
+		return ExtensionManagementUtility::siteRelPath('vidi');
27
+	}
28 28
 }
Please login to merge, or discard this patch.
Classes/ViewHelpers/Grid/Column/HasRelationViewHelper.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -18,25 +18,25 @@
 block discarded – undo
18 18
 class HasRelationViewHelper extends AbstractViewHelper
19 19
 {
20 20
 
21
-    /**
22
-     * Return whether the current field name has a relation to the main content.
23
-     *
24
-     * @return boolean
25
-     */
26
-    public function render()
27
-    {
28
-        $fieldNameAndPath = $this->templateVariableContainer->get('columnName');
29
-        $dataType = $this->getFieldPathResolver()->getDataType($fieldNameAndPath);
30
-        $fieldName = $this->getFieldPathResolver()->stripFieldPath($fieldNameAndPath);
31
-        $hasRelation = Tca::table($dataType)->field($fieldName)->hasRelation();
32
-        return $hasRelation;
33
-    }
21
+	/**
22
+	 * Return whether the current field name has a relation to the main content.
23
+	 *
24
+	 * @return boolean
25
+	 */
26
+	public function render()
27
+	{
28
+		$fieldNameAndPath = $this->templateVariableContainer->get('columnName');
29
+		$dataType = $this->getFieldPathResolver()->getDataType($fieldNameAndPath);
30
+		$fieldName = $this->getFieldPathResolver()->stripFieldPath($fieldNameAndPath);
31
+		$hasRelation = Tca::table($dataType)->field($fieldName)->hasRelation();
32
+		return $hasRelation;
33
+	}
34 34
 
35
-    /**
36
-     * @return FieldPathResolver|object
37
-     */
38
-    protected function getFieldPathResolver()
39
-    {
40
-        return GeneralUtility::makeInstance(FieldPathResolver::class);
41
-    }
35
+	/**
36
+	 * @return FieldPathResolver|object
37
+	 */
38
+	protected function getFieldPathResolver()
39
+	{
40
+		return GeneralUtility::makeInstance(FieldPathResolver::class);
41
+	}
42 42
 }
Please login to merge, or discard this patch.
Classes/Tca/AbstractTca.php 1 patch
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -16,34 +16,34 @@
 block discarded – undo
16 16
 abstract class AbstractTca implements TcaServiceInterface
17 17
 {
18 18
 
19
-    /**
20
-     * Returns an instance of the current Backend User.
21
-     *
22
-     * @return BackendUserAuthentication
23
-     */
24
-    protected function getBackendUser()
25
-    {
26
-        return $GLOBALS['BE_USER'];
27
-    }
19
+	/**
20
+	 * Returns an instance of the current Backend User.
21
+	 *
22
+	 * @return BackendUserAuthentication
23
+	 */
24
+	protected function getBackendUser()
25
+	{
26
+		return $GLOBALS['BE_USER'];
27
+	}
28 28
 
29
-    /**
30
-     * Returns whether the current mode is Backend.
31
-     *
32
-     * @return bool
33
-     */
34
-    protected function isBackendMode()
35
-    {
36
-        return ApplicationType::fromRequest($GLOBALS['TYPO3_REQUEST'])->isBackend();
37
-    }
29
+	/**
30
+	 * Returns whether the current mode is Backend.
31
+	 *
32
+	 * @return bool
33
+	 */
34
+	protected function isBackendMode()
35
+	{
36
+		return ApplicationType::fromRequest($GLOBALS['TYPO3_REQUEST'])->isBackend();
37
+	}
38 38
 
39
-    /**
40
-     * Returns whether the current mode is Frontend.
41
-     *
42
-     * @return bool
43
-     */
44
-    protected function isFrontendMode()
45
-    {
46
-        return ApplicationType::fromRequest($GLOBALS['TYPO3_REQUEST'])->isFrontend();
47
-    }
39
+	/**
40
+	 * Returns whether the current mode is Frontend.
41
+	 *
42
+	 * @return bool
43
+	 */
44
+	protected function isFrontendMode()
45
+	{
46
+		return ApplicationType::fromRequest($GLOBALS['TYPO3_REQUEST'])->isFrontend();
47
+	}
48 48
 
49 49
 }
Please login to merge, or discard this patch.
Classes/Command/VidiCommandController.php 1 patch
Indentation   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -23,59 +23,59 @@
 block discarded – undo
23 23
 class VidiCommandController extends Command
24 24
 {
25 25
 
26
-    /**
27
-     * Configure the command by defining the name, options and arguments
28
-     */
29
-    protected function configure()
30
-    {
31
-        $this->setDescription('Check TCA configuration for relations used in grid.')
32
-        ->addOption(
33
-        'table',
34
-        'c',
35
-        InputOption::VALUE_NONE,
36
-        'The table name. If not defined check for every table.'
37
-    );
38
-    }
26
+	/**
27
+	 * Configure the command by defining the name, options and arguments
28
+	 */
29
+	protected function configure()
30
+	{
31
+		$this->setDescription('Check TCA configuration for relations used in grid.')
32
+		->addOption(
33
+		'table',
34
+		'c',
35
+		InputOption::VALUE_NONE,
36
+		'The table name. If not defined check for every table.'
37
+	);
38
+	}
39 39
 
40
-    /**
41
-     * Executes the command for removing the lock file
42
-     *
43
-     * @param InputInterface $input
44
-     * @param OutputInterface $output
45
-     */
46
-    protected function execute(InputInterface $input, OutputInterface $output)
47
-    {
48
-        $io = new SymfonyStyle($input, $output);
49
-        foreach ($GLOBALS['TCA'] as $tableName => $TCA) {
50
-            $table = $input->getOption('table');
51
-            if ($table !== '' && $table !== $tableName) {
52
-                continue;
53
-            }
40
+	/**
41
+	 * Executes the command for removing the lock file
42
+	 *
43
+	 * @param InputInterface $input
44
+	 * @param OutputInterface $output
45
+	 */
46
+	protected function execute(InputInterface $input, OutputInterface $output)
47
+	{
48
+		$io = new SymfonyStyle($input, $output);
49
+		foreach ($GLOBALS['TCA'] as $tableName => $TCA) {
50
+			$table = $input->getOption('table');
51
+			if ($table !== '' && $table !== $tableName) {
52
+				continue;
53
+			}
54 54
 
55
-            $fields = Tca::grid($tableName)->getFields();
56
-            if (!empty($fields)) {
55
+			$fields = Tca::grid($tableName)->getFields();
56
+			if (!empty($fields)) {
57 57
 
58
-                $relations = $this->getGridAnalyserService()->checkRelationForTable($tableName);
59
-                if (!empty($relations)) {
58
+				$relations = $this->getGridAnalyserService()->checkRelationForTable($tableName);
59
+				if (!empty($relations)) {
60 60
 
61
-                    $io->text('');
62
-                    $io->text('--------------------------------------------------------------------');
63
-                    $io->text('');
64
-                    $io->text(sprintf('Relations for "%s"', $tableName));
65
-                    $io->text('');
66
-                    $io->text(implode("\n", $relations));
67
-                }
68
-            }
69
-        }
70
-    }
61
+					$io->text('');
62
+					$io->text('--------------------------------------------------------------------');
63
+					$io->text('');
64
+					$io->text(sprintf('Relations for "%s"', $tableName));
65
+					$io->text('');
66
+					$io->text(implode("\n", $relations));
67
+				}
68
+			}
69
+		}
70
+	}
71 71
 
72
-    /**
73
-     * Get the Vidi Module Loader.
74
-     *
75
-     * @return GridAnalyserService|object
76
-     */
77
-    protected function getGridAnalyserService()
78
-    {
79
-        return GeneralUtility::makeInstance(GridAnalyserService::class);
80
-    }
72
+	/**
73
+	 * Get the Vidi Module Loader.
74
+	 *
75
+	 * @return GridAnalyserService|object
76
+	 */
77
+	protected function getGridAnalyserService()
78
+	{
79
+		return GeneralUtility::makeInstance(GridAnalyserService::class);
80
+	}
81 81
 }
Please login to merge, or discard this patch.