Completed
Push — master ( 080764...892a3f )
by Fabien
52:24
created
Classes/ViewHelpers/Result/ToXlsViewHelper.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -103,7 +103,7 @@
 block discarded – undo
103 103
         $response->withHeader('Expires', '0');
104 104
         $response->withHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0');
105 105
         $response->withHeader('Content-Type', 'application/vnd.ms-excel');
106
-        $response->withHeader('Content-Disposition', 'attachment; filename="' . basename($this->exportFileNameAndPath) . '"');
106
+        $response->withHeader('Content-Disposition', 'attachment; filename="'.basename($this->exportFileNameAndPath).'"');
107 107
         $response->withHeader('Content-Length', filesize($this->exportFileNameAndPath));
108 108
         $response->withHeader('Content-Description', 'File Transfer');
109 109
         $response->withHeader('Content-Transfer-Encoding', 'binary');
Please login to merge, or discard this patch.
Indentation   +91 added lines, -91 removed lines patch added patch discarded remove patch
@@ -18,96 +18,96 @@
 block discarded – undo
18 18
 class ToXlsViewHelper extends AbstractToFormatViewHelper
19 19
 {
20 20
 
21
-    /**
22
-     * Render a XLS export request.
23
-     *
24
-     */
25
-    public function render()
26
-    {
27
-
28
-        $objects = $this->templateVariableContainer->get('objects');
29
-
30
-        // Make sure we have something to process...
31
-        if (!empty($objects)) {
32
-
33
-            // Initialization step.
34
-            $this->initializeEnvironment($objects);
35
-            $this->exportFileNameAndPath .= '.xls'; // add extension to the file.
36
-
37
-            // Write the exported data to a CSV file.
38
-            $this->writeXlsFile($objects);
39
-
40
-            // We must generate a zip archive since there are files included.
41
-            if ($this->hasCollectedFiles()) {
42
-
43
-                $this->writeZipFile();
44
-                $this->sendZipHttpHeaders();
45
-
46
-                readfile($this->zipFileNameAndPath);
47
-            } else {
48
-                $this->sendXlsHttpHeaders();
49
-                readfile($this->exportFileNameAndPath);
50
-            }
51
-
52
-            GeneralUtility::rmdir($this->temporaryDirectory, true);
53
-        }
54
-    }
55
-
56
-    /**
57
-     * Write the CSV file to a temporary location.
58
-     *
59
-     * @param array $objects
60
-     * @return void
61
-     */
62
-    protected function writeXlsFile(array $objects)
63
-    {
64
-
65
-        /** @var SpreadSheetService $spreadSheet */
66
-        $spreadSheet = GeneralUtility::makeInstance(SpreadSheetService::class);
67
-
68
-        // Handle object header, get the first object and get the list of fields.
69
-        /** @var Content $object */
70
-        $object = reset($objects);
71
-        $spreadSheet->addRow($object->toFields());
72
-
73
-        $this->checkWhetherObjectMayIncludeFiles($object);
74
-
75
-        foreach ($objects as $object) {
76
-            if ($this->hasFileFields()) {
77
-                $this->collectFiles($object);
78
-            }
79
-
80
-            // Make sure we have a flat array of values for the CSV purpose.
81
-            $flattenValues = [];
82
-            foreach ($object->toValues() as $fieldName => $value) {
83
-                if (is_array($value)) {
84
-                    $flattenValues[$fieldName] = implode(', ', $value);
85
-                } else {
86
-                    $flattenValues[$fieldName] = $value;
87
-                }
88
-            }
89
-
90
-            $spreadSheet->addRow($flattenValues);
91
-        }
92
-
93
-        file_put_contents($this->exportFileNameAndPath, $spreadSheet->toString());
94
-    }
95
-
96
-    /**
97
-     * @return void
98
-     */
99
-    protected function sendXlsHttpHeaders()
100
-    {
101
-        /** @var Response $response */
102
-        $response = $this->templateVariableContainer->get('response');
103
-        $response->withHeader('Pragma', 'public');
104
-        $response->withHeader('Expires', '0');
105
-        $response->withHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0');
106
-        $response->withHeader('Content-Type', 'application/vnd.ms-excel');
107
-        $response->withHeader('Content-Disposition', 'attachment; filename="' . basename($this->exportFileNameAndPath) . '"');
108
-        $response->withHeader('Content-Length', filesize($this->exportFileNameAndPath));
109
-        $response->withHeader('Content-Description', 'File Transfer');
110
-        $response->withHeader('Content-Transfer-Encoding', 'binary');
111
-    }
21
+	/**
22
+	 * Render a XLS export request.
23
+	 *
24
+	 */
25
+	public function render()
26
+	{
27
+
28
+		$objects = $this->templateVariableContainer->get('objects');
29
+
30
+		// Make sure we have something to process...
31
+		if (!empty($objects)) {
32
+
33
+			// Initialization step.
34
+			$this->initializeEnvironment($objects);
35
+			$this->exportFileNameAndPath .= '.xls'; // add extension to the file.
36
+
37
+			// Write the exported data to a CSV file.
38
+			$this->writeXlsFile($objects);
39
+
40
+			// We must generate a zip archive since there are files included.
41
+			if ($this->hasCollectedFiles()) {
42
+
43
+				$this->writeZipFile();
44
+				$this->sendZipHttpHeaders();
45
+
46
+				readfile($this->zipFileNameAndPath);
47
+			} else {
48
+				$this->sendXlsHttpHeaders();
49
+				readfile($this->exportFileNameAndPath);
50
+			}
51
+
52
+			GeneralUtility::rmdir($this->temporaryDirectory, true);
53
+		}
54
+	}
55
+
56
+	/**
57
+	 * Write the CSV file to a temporary location.
58
+	 *
59
+	 * @param array $objects
60
+	 * @return void
61
+	 */
62
+	protected function writeXlsFile(array $objects)
63
+	{
64
+
65
+		/** @var SpreadSheetService $spreadSheet */
66
+		$spreadSheet = GeneralUtility::makeInstance(SpreadSheetService::class);
67
+
68
+		// Handle object header, get the first object and get the list of fields.
69
+		/** @var Content $object */
70
+		$object = reset($objects);
71
+		$spreadSheet->addRow($object->toFields());
72
+
73
+		$this->checkWhetherObjectMayIncludeFiles($object);
74
+
75
+		foreach ($objects as $object) {
76
+			if ($this->hasFileFields()) {
77
+				$this->collectFiles($object);
78
+			}
79
+
80
+			// Make sure we have a flat array of values for the CSV purpose.
81
+			$flattenValues = [];
82
+			foreach ($object->toValues() as $fieldName => $value) {
83
+				if (is_array($value)) {
84
+					$flattenValues[$fieldName] = implode(', ', $value);
85
+				} else {
86
+					$flattenValues[$fieldName] = $value;
87
+				}
88
+			}
89
+
90
+			$spreadSheet->addRow($flattenValues);
91
+		}
92
+
93
+		file_put_contents($this->exportFileNameAndPath, $spreadSheet->toString());
94
+	}
95
+
96
+	/**
97
+	 * @return void
98
+	 */
99
+	protected function sendXlsHttpHeaders()
100
+	{
101
+		/** @var Response $response */
102
+		$response = $this->templateVariableContainer->get('response');
103
+		$response->withHeader('Pragma', 'public');
104
+		$response->withHeader('Expires', '0');
105
+		$response->withHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0');
106
+		$response->withHeader('Content-Type', 'application/vnd.ms-excel');
107
+		$response->withHeader('Content-Disposition', 'attachment; filename="' . basename($this->exportFileNameAndPath) . '"');
108
+		$response->withHeader('Content-Length', filesize($this->exportFileNameAndPath));
109
+		$response->withHeader('Content-Description', 'File Transfer');
110
+		$response->withHeader('Content-Transfer-Encoding', 'binary');
111
+	}
112 112
 
113 113
 }
Please login to merge, or discard this patch.
Classes/ViewHelpers/Render/ComponentsViewHelper.php 2 patches
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -19,59 +19,59 @@
 block discarded – undo
19 19
  */
20 20
 class ComponentsViewHelper extends AbstractViewHelper
21 21
 {
22
-    /**
23
-     * @return void
24
-     */
25
-    public function initializeArguments()
26
-    {
27
-        $this->registerArgument('part', 'string', 'Template part', true);
28
-    }
22
+	/**
23
+	 * @return void
24
+	 */
25
+	public function initializeArguments()
26
+	{
27
+		$this->registerArgument('part', 'string', 'Template part', true);
28
+	}
29 29
 
30
-    /**
31
-     * Escapes special characters with their escaped counterparts as needed using PHPs strip_tags() function.
32
-     *
33
-     * @return mixed
34
-     */
35
-    public function render()
36
-    {
37
-        return static::renderStatic(
38
-            $this->arguments,
39
-            $this->buildRenderChildrenClosure(),
40
-            $this->renderingContext
41
-        );
42
-    }
30
+	/**
31
+	 * Escapes special characters with their escaped counterparts as needed using PHPs strip_tags() function.
32
+	 *
33
+	 * @return mixed
34
+	 */
35
+	public function render()
36
+	{
37
+		return static::renderStatic(
38
+			$this->arguments,
39
+			$this->buildRenderChildrenClosure(),
40
+			$this->renderingContext
41
+		);
42
+	}
43 43
 
44
-    /**
45
-     * Applies strip_tags() on the specified value.
46
-     *
47
-     * @param array $arguments
48
-     * @param \Closure $renderChildrenClosure
49
-     * @param RenderingContextInterface $renderingContext
50
-     * @return string
51
-     */
52
-    public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
53
-    {
54
-        /** @var ModuleLoader $moduleLoader */
55
-        $moduleLoader = GeneralUtility::makeInstance(ModuleLoader::class);
44
+	/**
45
+	 * Applies strip_tags() on the specified value.
46
+	 *
47
+	 * @param array $arguments
48
+	 * @param \Closure $renderChildrenClosure
49
+	 * @param RenderingContextInterface $renderingContext
50
+	 * @return string
51
+	 */
52
+	public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
53
+	{
54
+		/** @var ModuleLoader $moduleLoader */
55
+		$moduleLoader = GeneralUtility::makeInstance(ModuleLoader::class);
56 56
 
57
-        $part = $arguments['part'];
57
+		$part = $arguments['part'];
58 58
 
59
-        $getComponents = 'get' . ucfirst($part) . 'Components';
60
-        $components = $moduleLoader->$getComponents();
59
+		$getComponents = 'get' . ucfirst($part) . 'Components';
60
+		$components = $moduleLoader->$getComponents();
61 61
 
62
-        $objectManager = GeneralUtility::makeInstance(ObjectManager::class);
62
+		$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
63 63
 
64
-        $result = '';
65
-        foreach ($components as $component) {
66
-            $viewHelper = $objectManager->get($component);
64
+		$result = '';
65
+		foreach ($components as $component) {
66
+			$viewHelper = $objectManager->get($component);
67 67
 
68
-            // Get possible arguments but remove first one.
69
-            $arguments = func_get_args();
70
-            array_shift($arguments);
71
-            $result .= call_user_func_array(array($viewHelper, 'render'), $arguments);
72
-        }
68
+			// Get possible arguments but remove first one.
69
+			$arguments = func_get_args();
70
+			array_shift($arguments);
71
+			$result .= call_user_func_array(array($viewHelper, 'render'), $arguments);
72
+		}
73 73
 
74
-        return $result;
75
-    }
74
+		return $result;
75
+	}
76 76
 
77 77
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@
 block discarded – undo
56 56
 
57 57
         $part = $arguments['part'];
58 58
 
59
-        $getComponents = 'get' . ucfirst($part) . 'Components';
59
+        $getComponents = 'get'.ucfirst($part).'Components';
60 60
         $components = $moduleLoader->$getComponents();
61 61
 
62 62
         $objectManager = GeneralUtility::makeInstance(ObjectManager::class);
Please login to merge, or discard this patch.
Classes/Grid/RelationCountRenderer.php 1 patch
Indentation   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -20,68 +20,68 @@
 block discarded – undo
20 20
 class RelationCountRenderer extends ColumnRendererAbstract
21 21
 {
22 22
 
23
-    /**
24
-     * Render a representation of the relation on the GUI.
25
-     *
26
-     * @return string
27
-     */
28
-    public function render()
29
-    {
23
+	/**
24
+	 * Render a representation of the relation on the GUI.
25
+	 *
26
+	 * @return string
27
+	 */
28
+	public function render()
29
+	{
30 30
 
31
-        $output = '';
32
-        if ($this->isBackendMode()) {
33
-            $output = $this->renderForBackend();
34
-        }
31
+		$output = '';
32
+		if ($this->isBackendMode()) {
33
+			$output = $this->renderForBackend();
34
+		}
35 35
 
36
-        return $output;
37
-    }
36
+		return $output;
37
+	}
38 38
 
39
-    /**
40
-     * @return string
41
-     */
42
-    protected function renderForBackend()
43
-    {
39
+	/**
40
+	 * @return string
41
+	 */
42
+	protected function renderForBackend()
43
+	{
44 44
 
45
-        $numberOfObjects = count($this->object[$this->fieldName]);
45
+		$numberOfObjects = count($this->object[$this->fieldName]);
46 46
 
47
-        if ($numberOfObjects > 1) {
48
-            $label = 'LLL:EXT:vidi/Resources/Private/Language/locallang.xlf:items';
49
-            if (isset($this->gridRendererConfiguration['labelPlural'])) {
50
-                $label = $this->gridRendererConfiguration['labelPlural'];
51
-            }
52
-        } else {
53
-            $label = 'LLL:EXT:vidi/Resources/Private/Language/locallang.xlf:item';
54
-            if (isset($this->gridRendererConfiguration['labelSingular'])) {
55
-                $label = $this->gridRendererConfiguration['labelSingular'];
56
-            }
57
-        }
47
+		if ($numberOfObjects > 1) {
48
+			$label = 'LLL:EXT:vidi/Resources/Private/Language/locallang.xlf:items';
49
+			if (isset($this->gridRendererConfiguration['labelPlural'])) {
50
+				$label = $this->gridRendererConfiguration['labelPlural'];
51
+			}
52
+		} else {
53
+			$label = 'LLL:EXT:vidi/Resources/Private/Language/locallang.xlf:item';
54
+			if (isset($this->gridRendererConfiguration['labelSingular'])) {
55
+				$label = $this->gridRendererConfiguration['labelSingular'];
56
+			}
57
+		}
58 58
 
59
-        $template = '<a href="%s&returnUrl=%s&search=%s&query=%s:%s">%s %s<span class="invisible" style="padding-left: 5px">%s</span></a>';
59
+		$template = '<a href="%s&returnUrl=%s&search=%s&query=%s:%s">%s %s<span class="invisible" style="padding-left: 5px">%s</span></a>';
60 60
 
61
-        $foreignField = Tca::table($this->object)->field($this->fieldName)->getForeignField();
62
-        $search = json_encode(array(array($foreignField => $this->object->getUid())));
61
+		$foreignField = Tca::table($this->object)->field($this->fieldName)->getForeignField();
62
+		$search = json_encode(array(array($foreignField => $this->object->getUid())));
63 63
 
64
-        $moduleTarget = empty($this->gridRendererConfiguration['targetModule']) ? '' : $this->gridRendererConfiguration['targetModule'];
65
-        return sprintf($template,
66
-            BackendUtility::getModuleUrl($moduleTarget),
67
-            rawurlencode(BackendUtility::getModuleUrl($this->gridRendererConfiguration['sourceModule'])),
68
-            rawurlencode($search),
69
-            rawurlencode($foreignField),
70
-            rawurlencode($this->object->getUid()),
71
-            htmlspecialchars($numberOfObjects),
72
-            htmlspecialchars(LocalizationUtility::translate($label, '')),
73
-            $this->getIconFactory()->getIcon('extensions-vidi-go', Icon::SIZE_SMALL)
74
-        );
75
-    }
64
+		$moduleTarget = empty($this->gridRendererConfiguration['targetModule']) ? '' : $this->gridRendererConfiguration['targetModule'];
65
+		return sprintf($template,
66
+			BackendUtility::getModuleUrl($moduleTarget),
67
+			rawurlencode(BackendUtility::getModuleUrl($this->gridRendererConfiguration['sourceModule'])),
68
+			rawurlencode($search),
69
+			rawurlencode($foreignField),
70
+			rawurlencode($this->object->getUid()),
71
+			htmlspecialchars($numberOfObjects),
72
+			htmlspecialchars(LocalizationUtility::translate($label, '')),
73
+			$this->getIconFactory()->getIcon('extensions-vidi-go', Icon::SIZE_SMALL)
74
+		);
75
+	}
76 76
 
77
-    /**
78
-     * Returns whether the current mode is Frontend
79
-     *
80
-     * @return bool
81
-     */
82
-    protected function isBackendMode()
83
-    {
84
-        return ApplicationType::fromRequest($GLOBALS['TYPO3_REQUEST'])->isBackend();
85
-    }
77
+	/**
78
+	 * Returns whether the current mode is Frontend
79
+	 *
80
+	 * @return bool
81
+	 */
82
+	protected function isBackendMode()
83
+	{
84
+		return ApplicationType::fromRequest($GLOBALS['TYPO3_REQUEST'])->isBackend();
85
+	}
86 86
 
87 87
 }
Please login to merge, or discard this patch.
Classes/Grid/RelationRenderer.php 1 patch
Indentation   +155 added lines, -155 removed lines patch added patch discarded remove patch
@@ -20,160 +20,160 @@
 block discarded – undo
20 20
 class RelationRenderer extends ColumnRendererAbstract
21 21
 {
22 22
 
23
-    /**
24
-     * Render a representation of the relation on the GUI.
25
-     *
26
-     * @return string
27
-     */
28
-    public function render()
29
-    {
30
-        if ($this->isBackendMode()) {
31
-            $output = $this->renderForBackend();
32
-        } else {
33
-            $output = $this->renderForFrontend();
34
-        }
35
-
36
-        return $output;
37
-    }
38
-
39
-    /**
40
-     * @return string
41
-     */
42
-    protected function renderForBackend()
43
-    {
44
-
45
-        $output = '';
46
-
47
-        // Get label of the foreign table.
48
-        $foreignLabelField = $this->getForeignTableLabelField($this->fieldName);
49
-
50
-        if (Tca::table($this->object)->field($this->fieldName)->hasOne()) {
51
-
52
-            $foreignObject = $this->object[$this->fieldName];
53
-
54
-            if ($foreignObject) {
55
-                $output = sprintf(
56
-                    '<a href="%s" data-uid="%s" class="btn-edit invisible">%s</a> <span>%s</span>',
57
-                    $this->getEditUri($foreignObject),
58
-                    $this->object->getUid(),
59
-                    $this->getIconFactory()->getIcon('actions-document-open', Icon::SIZE_SMALL),
60
-                    $foreignObject[$foreignLabelField]
61
-                );
62
-            }
63
-        } elseif (Tca::table($this->object)->field($this->fieldName)->hasMany()) {
64
-
65
-            if (!empty($this->object[$this->fieldName])) {
66
-
67
-                /** @var $foreignObject \Fab\Vidi\Domain\Model\Content */
68
-                foreach ($this->object[$this->fieldName] as $foreignObject) {
69
-                    $output .= sprintf(
70
-                        '<li><a href="%s" data-uid="%s" class="btn-edit invisible">%s</a> <span>%s</span></li>',
71
-                        $this->getEditUri($foreignObject),
72
-                        $this->object->getUid(),
73
-                        $this->getIconFactory()->getIcon('actions-document-open', Icon::SIZE_SMALL),
74
-                        $foreignObject[$foreignLabelField]
75
-                    );
76
-                }
77
-                $output = sprintf('<ul class="list-unstyled">%s</ul>', $output);
78
-            }
79
-        }
80
-        return $output;
81
-    }
82
-
83
-    /**
84
-     * @return string
85
-     */
86
-    protected function renderForFrontend()
87
-    {
88
-
89
-        $output = '';
90
-
91
-        // Get label of the foreign table.
92
-        $foreignLabelField = $this->getForeignTableLabelField($this->fieldName);
93
-
94
-        if (Tca::table($this->object)->field($this->fieldName)->hasOne()) {
95
-
96
-            $foreignObject = $this->object[$this->fieldName];
97
-
98
-            if ($foreignObject) {
99
-                $output = sprintf(
100
-                    '%s',
101
-                    $foreignObject[$foreignLabelField]
102
-                );
103
-            }
104
-        } elseif (Tca::table($this->object)->field($this->fieldName)->hasMany()) {
105
-
106
-            if (!empty($this->object[$this->fieldName])) {
107
-
108
-                /** @var $foreignObject \Fab\Vidi\Domain\Model\Content */
109
-                foreach ($this->object[$this->fieldName] as $foreignObject) {
110
-                    $output .= sprintf(
111
-                        '<li>%s</li>',
112
-                        $foreignObject[$foreignLabelField]
113
-                    );
114
-                }
115
-                $output = sprintf('<ul class="list-unstyled">%s</ul>', $output);
116
-            }
117
-        }
118
-        return $output;
119
-    }
120
-
121
-    /**
122
-     * Render an edit URI given an object.
123
-     *
124
-     * @param Content $object
125
-     * @return string
126
-     */
127
-    protected function getEditUri(Content $object)
128
-    {
129
-        $uri = BackendUtility::getModuleUrl(
130
-            'record_edit',
131
-            array(
132
-                $this->getEditParameterName($object) => 'edit',
133
-                'returnUrl' => $this->getModuleLoader()->getModuleUrl()
134
-            )
135
-        );
136
-        return $uri;
137
-    }
138
-
139
-    /**
140
-     * @param Content $object
141
-     * @return string
142
-     */
143
-    protected function getEditParameterName(Content $object)
144
-    {
145
-        return sprintf(
146
-            'edit[%s][%s]',
147
-            $object->getDataType(),
148
-            $object->getUid()
149
-        );
150
-    }
151
-
152
-    /**
153
-     * Return the label field of the foreign table.
154
-     *
155
-     * @param string $fieldName
156
-     * @return string
157
-     */
158
-    protected function getForeignTableLabelField($fieldName)
159
-    {
160
-
161
-        // Get TCA table service.
162
-        $table = Tca::table($this->object);
163
-
164
-        // Compute the label of the foreign table.
165
-        $relationDataType = $table->field($fieldName)->relationDataType();
166
-        return Tca::table($relationDataType)->getLabelField();
167
-    }
168
-
169
-    /**
170
-     * Returns whether the current mode is Frontend
171
-     *
172
-     * @return bool
173
-     */
174
-    protected function isBackendMode()
175
-    {
176
-        return ApplicationType::fromRequest($GLOBALS['TYPO3_REQUEST'])->isBackend();
177
-    }
23
+	/**
24
+	 * Render a representation of the relation on the GUI.
25
+	 *
26
+	 * @return string
27
+	 */
28
+	public function render()
29
+	{
30
+		if ($this->isBackendMode()) {
31
+			$output = $this->renderForBackend();
32
+		} else {
33
+			$output = $this->renderForFrontend();
34
+		}
35
+
36
+		return $output;
37
+	}
38
+
39
+	/**
40
+	 * @return string
41
+	 */
42
+	protected function renderForBackend()
43
+	{
44
+
45
+		$output = '';
46
+
47
+		// Get label of the foreign table.
48
+		$foreignLabelField = $this->getForeignTableLabelField($this->fieldName);
49
+
50
+		if (Tca::table($this->object)->field($this->fieldName)->hasOne()) {
51
+
52
+			$foreignObject = $this->object[$this->fieldName];
53
+
54
+			if ($foreignObject) {
55
+				$output = sprintf(
56
+					'<a href="%s" data-uid="%s" class="btn-edit invisible">%s</a> <span>%s</span>',
57
+					$this->getEditUri($foreignObject),
58
+					$this->object->getUid(),
59
+					$this->getIconFactory()->getIcon('actions-document-open', Icon::SIZE_SMALL),
60
+					$foreignObject[$foreignLabelField]
61
+				);
62
+			}
63
+		} elseif (Tca::table($this->object)->field($this->fieldName)->hasMany()) {
64
+
65
+			if (!empty($this->object[$this->fieldName])) {
66
+
67
+				/** @var $foreignObject \Fab\Vidi\Domain\Model\Content */
68
+				foreach ($this->object[$this->fieldName] as $foreignObject) {
69
+					$output .= sprintf(
70
+						'<li><a href="%s" data-uid="%s" class="btn-edit invisible">%s</a> <span>%s</span></li>',
71
+						$this->getEditUri($foreignObject),
72
+						$this->object->getUid(),
73
+						$this->getIconFactory()->getIcon('actions-document-open', Icon::SIZE_SMALL),
74
+						$foreignObject[$foreignLabelField]
75
+					);
76
+				}
77
+				$output = sprintf('<ul class="list-unstyled">%s</ul>', $output);
78
+			}
79
+		}
80
+		return $output;
81
+	}
82
+
83
+	/**
84
+	 * @return string
85
+	 */
86
+	protected function renderForFrontend()
87
+	{
88
+
89
+		$output = '';
90
+
91
+		// Get label of the foreign table.
92
+		$foreignLabelField = $this->getForeignTableLabelField($this->fieldName);
93
+
94
+		if (Tca::table($this->object)->field($this->fieldName)->hasOne()) {
95
+
96
+			$foreignObject = $this->object[$this->fieldName];
97
+
98
+			if ($foreignObject) {
99
+				$output = sprintf(
100
+					'%s',
101
+					$foreignObject[$foreignLabelField]
102
+				);
103
+			}
104
+		} elseif (Tca::table($this->object)->field($this->fieldName)->hasMany()) {
105
+
106
+			if (!empty($this->object[$this->fieldName])) {
107
+
108
+				/** @var $foreignObject \Fab\Vidi\Domain\Model\Content */
109
+				foreach ($this->object[$this->fieldName] as $foreignObject) {
110
+					$output .= sprintf(
111
+						'<li>%s</li>',
112
+						$foreignObject[$foreignLabelField]
113
+					);
114
+				}
115
+				$output = sprintf('<ul class="list-unstyled">%s</ul>', $output);
116
+			}
117
+		}
118
+		return $output;
119
+	}
120
+
121
+	/**
122
+	 * Render an edit URI given an object.
123
+	 *
124
+	 * @param Content $object
125
+	 * @return string
126
+	 */
127
+	protected function getEditUri(Content $object)
128
+	{
129
+		$uri = BackendUtility::getModuleUrl(
130
+			'record_edit',
131
+			array(
132
+				$this->getEditParameterName($object) => 'edit',
133
+				'returnUrl' => $this->getModuleLoader()->getModuleUrl()
134
+			)
135
+		);
136
+		return $uri;
137
+	}
138
+
139
+	/**
140
+	 * @param Content $object
141
+	 * @return string
142
+	 */
143
+	protected function getEditParameterName(Content $object)
144
+	{
145
+		return sprintf(
146
+			'edit[%s][%s]',
147
+			$object->getDataType(),
148
+			$object->getUid()
149
+		);
150
+	}
151
+
152
+	/**
153
+	 * Return the label field of the foreign table.
154
+	 *
155
+	 * @param string $fieldName
156
+	 * @return string
157
+	 */
158
+	protected function getForeignTableLabelField($fieldName)
159
+	{
160
+
161
+		// Get TCA table service.
162
+		$table = Tca::table($this->object);
163
+
164
+		// Compute the label of the foreign table.
165
+		$relationDataType = $table->field($fieldName)->relationDataType();
166
+		return Tca::table($relationDataType)->getLabelField();
167
+	}
168
+
169
+	/**
170
+	 * Returns whether the current mode is Frontend
171
+	 *
172
+	 * @return bool
173
+	 */
174
+	protected function isBackendMode()
175
+	{
176
+		return ApplicationType::fromRequest($GLOBALS['TYPO3_REQUEST'])->isBackend();
177
+	}
178 178
 
179 179
 }
Please login to merge, or discard this patch.
Classes/Grid/RelationEditRenderer.php 2 patches
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -18,56 +18,56 @@
 block discarded – undo
18 18
 class RelationEditRenderer extends ColumnRendererAbstract
19 19
 {
20 20
 
21
-    /**
22
-     * @return string
23
-     */
24
-    public function render()
25
-    {
26
-        $output = '';
27
-        if ($this->isBackendMode()) {
28
-            $output = $this->renderForBackend();
29
-        }
21
+	/**
22
+	 * @return string
23
+	 */
24
+	public function render()
25
+	{
26
+		$output = '';
27
+		if ($this->isBackendMode()) {
28
+			$output = $this->renderForBackend();
29
+		}
30 30
 
31
-        return $output;
32
-    }
31
+		return $output;
32
+	}
33 33
 
34
-    /**
35
-     * @return string
36
-     */
37
-    protected function renderForBackend()
38
-    {
34
+	/**
35
+	 * @return string
36
+	 */
37
+	protected function renderForBackend()
38
+	{
39 39
 
40
-        // Initialize url parameters array.
41
-        $urlParameters = array(
42
-            $this->getModuleLoader()->getParameterPrefix() => array(
43
-                'controller' => 'Content',
44
-                'action' => 'edit',
45
-                'matches' => array('uid' => $this->object->getUid()),
46
-                'fieldNameAndPath' => $this->getFieldName(),
47
-            ),
48
-        );
40
+		// Initialize url parameters array.
41
+		$urlParameters = array(
42
+			$this->getModuleLoader()->getParameterPrefix() => array(
43
+				'controller' => 'Content',
44
+				'action' => 'edit',
45
+				'matches' => array('uid' => $this->object->getUid()),
46
+				'fieldNameAndPath' => $this->getFieldName(),
47
+			),
48
+		);
49 49
 
50
-        $fieldLabel = Tca::table()->field($this->getFieldName())->getLabel();
51
-        if ($fieldLabel) {
52
-            $fieldLabel = str_replace(':', '', $fieldLabel); // sanitize label
53
-        }
50
+		$fieldLabel = Tca::table()->field($this->getFieldName())->getLabel();
51
+		if ($fieldLabel) {
52
+			$fieldLabel = str_replace(':', '', $fieldLabel); // sanitize label
53
+		}
54 54
 
55
-        return sprintf(
56
-            '<div style="text-align: right" class="pull-right invisible"><a href="%s" class="btn-edit-relation" data-field-label="%s">%s</a></div>',
57
-            $this->getModuleLoader()->getModuleUrl($urlParameters),
58
-            $fieldLabel,
59
-            $this->getIconFactory()->getIcon('actions-add', Icon::SIZE_SMALL)
60
-        );
61
-    }
55
+		return sprintf(
56
+			'<div style="text-align: right" class="pull-right invisible"><a href="%s" class="btn-edit-relation" data-field-label="%s">%s</a></div>',
57
+			$this->getModuleLoader()->getModuleUrl($urlParameters),
58
+			$fieldLabel,
59
+			$this->getIconFactory()->getIcon('actions-add', Icon::SIZE_SMALL)
60
+		);
61
+	}
62 62
 
63
-    /**
64
-     * Returns whether the current mode is Frontend
65
-     *
66
-     * @return bool
67
-     */
68
-    protected function isBackendMode()
69
-    {
70
-        return ApplicationType::fromRequest($GLOBALS['TYPO3_REQUEST'])->isBackend();;
71
-    }
63
+	/**
64
+	 * Returns whether the current mode is Frontend
65
+	 *
66
+	 * @return bool
67
+	 */
68
+	protected function isBackendMode()
69
+	{
70
+		return ApplicationType::fromRequest($GLOBALS['TYPO3_REQUEST'])->isBackend();;
71
+	}
72 72
 
73 73
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@
 block discarded – undo
67 67
      */
68 68
     protected function isBackendMode()
69 69
     {
70
-        return ApplicationType::fromRequest($GLOBALS['TYPO3_REQUEST'])->isBackend();;
70
+        return ApplicationType::fromRequest($GLOBALS['TYPO3_REQUEST'])->isBackend(); ;
71 71
     }
72 72
 
73 73
 }
Please login to merge, or discard this patch.
Classes/Service/FileReferenceService.php 1 patch
Indentation   +81 added lines, -81 removed lines patch added patch discarded remove patch
@@ -22,86 +22,86 @@
 block discarded – undo
22 22
 class FileReferenceService implements SingletonInterface
23 23
 {
24 24
 
25
-    /**
26
-     * @var array
27
-     */
28
-    static protected $instances = [];
29
-
30
-    /**
31
-     * Returns a class instance
32
-     *
33
-     * @return \Fab\Vidi\Service\FileReferenceService|object
34
-     */
35
-    static public function getInstance()
36
-    {
37
-        return GeneralUtility::makeInstance(\Fab\Vidi\Service\FileReferenceService::class);
38
-    }
39
-
40
-    /**
41
-     * @param Content $object
42
-     * @param string $propertyName
43
-     * @return File[]
44
-     */
45
-    public function findReferencedBy($propertyName, Content $object)
46
-    {
47
-
48
-        if (!isset(self::$instances[$object->getUid()][$propertyName])) {
49
-
50
-            // Initialize instances value
51
-            if (!isset(self::$instances[$object->getUid()])) {
52
-                self::$instances[$object->getUid()] = [];
53
-            }
54
-
55
-            $fieldName = GeneralUtility::camelCaseToLowerCaseUnderscored($propertyName);
56
-            $field = Tca::table($object->getDataType())->field($fieldName);
57
-            if ($field->getForeignTable() === 'sys_file_reference') {
58
-                $files = $this->findByFileReference($propertyName, $object);
59
-                self::$instances[$object->getUid()][$propertyName] = $files;
60
-            } else {
61
-                // @todo the standard way of handling file references is by "sys_file_reference". Let see if there is other use cases...
62
-            }
63
-        }
64
-
65
-        return self::$instances[$object->getUid()][$propertyName];
66
-    }
67
-
68
-    /**
69
-     * Fetch the files given an object assuming
70
-     *
71
-     * @param $propertyName
72
-     * @param Content $object
73
-     * @return File[]
74
-     */
75
-    protected function findByFileReference($propertyName, Content $object)
76
-    {
77
-
78
-        $fileField = 'uid_local';
79
-        $tableName = 'sys_file_reference';
80
-
81
-        $rows = $this->getDataService()->getRecords(
82
-            $tableName,
83
-            [
84
-                'tablenames' => $object->getDataType(),
85
-                'fieldname'=> GeneralUtility::camelCaseToLowerCaseUnderscored($propertyName),
86
-                'uid_foreign'=> $object->getUid(),
87
-            ]
88
-        );
89
-
90
-        // Build array of Files
91
-        $files = [];
92
-        foreach ($rows as $row) {
93
-            $files[] = GeneralUtility::makeInstance(ResourceFactory::class)->getFileObject($row[$fileField]);
94
-        }
95
-
96
-        return $files;
97
-    }
98
-
99
-    /**
100
-     * @return object|DataService
101
-     */
102
-    protected function getDataService(): DataService
103
-    {
104
-        return GeneralUtility::makeInstance(DataService::class);
105
-    }
25
+	/**
26
+	 * @var array
27
+	 */
28
+	static protected $instances = [];
29
+
30
+	/**
31
+	 * Returns a class instance
32
+	 *
33
+	 * @return \Fab\Vidi\Service\FileReferenceService|object
34
+	 */
35
+	static public function getInstance()
36
+	{
37
+		return GeneralUtility::makeInstance(\Fab\Vidi\Service\FileReferenceService::class);
38
+	}
39
+
40
+	/**
41
+	 * @param Content $object
42
+	 * @param string $propertyName
43
+	 * @return File[]
44
+	 */
45
+	public function findReferencedBy($propertyName, Content $object)
46
+	{
47
+
48
+		if (!isset(self::$instances[$object->getUid()][$propertyName])) {
49
+
50
+			// Initialize instances value
51
+			if (!isset(self::$instances[$object->getUid()])) {
52
+				self::$instances[$object->getUid()] = [];
53
+			}
54
+
55
+			$fieldName = GeneralUtility::camelCaseToLowerCaseUnderscored($propertyName);
56
+			$field = Tca::table($object->getDataType())->field($fieldName);
57
+			if ($field->getForeignTable() === 'sys_file_reference') {
58
+				$files = $this->findByFileReference($propertyName, $object);
59
+				self::$instances[$object->getUid()][$propertyName] = $files;
60
+			} else {
61
+				// @todo the standard way of handling file references is by "sys_file_reference". Let see if there is other use cases...
62
+			}
63
+		}
64
+
65
+		return self::$instances[$object->getUid()][$propertyName];
66
+	}
67
+
68
+	/**
69
+	 * Fetch the files given an object assuming
70
+	 *
71
+	 * @param $propertyName
72
+	 * @param Content $object
73
+	 * @return File[]
74
+	 */
75
+	protected function findByFileReference($propertyName, Content $object)
76
+	{
77
+
78
+		$fileField = 'uid_local';
79
+		$tableName = 'sys_file_reference';
80
+
81
+		$rows = $this->getDataService()->getRecords(
82
+			$tableName,
83
+			[
84
+				'tablenames' => $object->getDataType(),
85
+				'fieldname'=> GeneralUtility::camelCaseToLowerCaseUnderscored($propertyName),
86
+				'uid_foreign'=> $object->getUid(),
87
+			]
88
+		);
89
+
90
+		// Build array of Files
91
+		$files = [];
92
+		foreach ($rows as $row) {
93
+			$files[] = GeneralUtility::makeInstance(ResourceFactory::class)->getFileObject($row[$fileField]);
94
+		}
95
+
96
+		return $files;
97
+	}
98
+
99
+	/**
100
+	 * @return object|DataService
101
+	 */
102
+	protected function getDataService(): DataService
103
+	{
104
+		return GeneralUtility::makeInstance(DataService::class);
105
+	}
106 106
 
107 107
 }
Please login to merge, or discard this patch.
Tests/Functional/Grid/RelationRendererTest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@
 block discarded – undo
17 17
 use Fab\Vidi\Domain\Model\Content;
18 18
 use Fab\Vidi\Tests\Functional\AbstractFunctionalTestCase;
19 19
 
20
-require_once dirname(dirname(__FILE__)) . '/AbstractFunctionalTestCase.php';
20
+require_once dirname(dirname(__FILE__)).'/AbstractFunctionalTestCase.php';
21 21
 
22 22
 /**
23 23
  * Test case for class \Fab\Vidi\Grid\CategoryRenderer.
Please login to merge, or discard this patch.
Tests/Functional/Module/ModuleLoaderTest.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 use Fab\Vidi\Module\ModuleLoader;
17 17
 use Fab\Vidi\Tests\Functional\AbstractFunctionalTestCase;
18 18
 
19
-require_once dirname(dirname(__FILE__)) . '/AbstractFunctionalTestCase.php';
19
+require_once dirname(dirname(__FILE__)).'/AbstractFunctionalTestCase.php';
20 20
 
21 21
 /**
22 22
  * Test case for class \Fab\Vidi\Module\ModuleLoader.
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 	 * @dataProvider attributeValueProvider
55 55
 	 */
56 56
 	public function attributeCanBeSet($attribute, $value) {
57
-		$setter = 'set' . ucfirst($attribute);
57
+		$setter = 'set'.ucfirst($attribute);
58 58
 		$this->fixture->$setter($value);
59 59
 		$this->assertAttributeEquals($value, $attribute, $this->fixture);
60 60
 	}
Please login to merge, or discard this patch.
Configuration/Extbase/Persistence/Classes.php 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@
 block discarded – undo
4 4
 use Fab\Vidi\Domain\Model\Selection;
5 5
 
6 6
 return [
7
-    Selection::class => [
8
-        'tableName' => 'tx_vidi_selection',
9
-    ],
7
+	Selection::class => [
8
+		'tableName' => 'tx_vidi_selection',
9
+	],
10 10
 ];
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@
 block discarded – undo
1 1
 <?php
2
-declare(strict_types = 1);
2
+declare(strict_types=1);
3 3
 
4 4
 use Fab\Vidi\Domain\Model\Selection;
5 5
 
Please login to merge, or discard this patch.