Completed
Push — master ( b0b1c6...4fec92 )
by Fabien
54:17
created
Classes/Tool/ThumbnailGeneratorTool.php 2 patches
Indentation   +116 added lines, -116 removed lines patch added patch discarded remove patch
@@ -19,120 +19,120 @@
 block discarded – undo
19 19
  */
20 20
 class ThumbnailGeneratorTool extends AbstractTool
21 21
 {
22
-    /**
23
-     * Display the title of the tool on the welcome screen.
24
-     *
25
-     * @return string
26
-     */
27
-    public function getTitle()
28
-    {
29
-        return 'Generate thumbnails';
30
-    }
31
-
32
-    /**
33
-     * Display the description of the tool in the welcome screen.
34
-     *
35
-     * @return string
36
-     */
37
-    public function getDescription()
38
-    {
39
-        $templateNameAndPath = 'EXT:media/Resources/Private/Standalone/Tool/ThumbnailGenerator/Launcher.html';
40
-        $view = $this->initializeStandaloneView($templateNameAndPath);
41
-        $view->assign('sitePath', Environment::getPublicPath() . '/');
42
-        return $view->render();
43
-    }
44
-
45
-    /**
46
-     * Do the job: analyse Index.
47
-     *
48
-     * @param array $arguments
49
-     * @return string
50
-     */
51
-    public function work(array $arguments = [])
52
-    {
53
-        $reports = [];
54
-
55
-        $limit = 500; // default value
56
-        $newOffset = 0;
57
-
58
-        // Possible clean up of missing files if the User has clicked so.
59
-        if (isset($arguments['limit']) && isset($arguments['offset'])) {
60
-            $limit = (int)$arguments['limit'];
61
-            $offset = (int)$arguments['offset'];
62
-
63
-            foreach ($this->getStorageRepository()->findAll() as $storage) {
64
-                if ($storage->isOnline()) {
65
-                    $thumbnailGenerator = $this->getThumbnailGenerator();
66
-                    $thumbnailGenerator
67
-                        ->setStorage($storage)
68
-                        ->generate($limit, $offset);
69
-
70
-                    $formattedResultSet = [];
71
-                    $resultSet = $thumbnailGenerator->getResultSet();
72
-                    $processedFileIdentifiers = $thumbnailGenerator->getNewProcessedFileIdentifiers();
73
-
74
-                    foreach ($processedFileIdentifiers as $fileIdentifier => $processedFileIdentifier) {
75
-                        $result = $resultSet[$fileIdentifier];
76
-                        $formattedResultSet[] = sprintf(
77
-                            '* File "%s": %s %s',
78
-                            $result['fileUid'],
79
-                            $result['fileIdentifier'],
80
-                            empty($result['thumbnailUri']) ? '' : ' -> ' . $result['thumbnailUri']
81
-                        );
82
-                    }
83
-
84
-                    $reports[] = array(
85
-                        'storage' => $storage,
86
-                        'isStorageOnline' => true,
87
-                        'resultSet' => $formattedResultSet,
88
-                        'numberOfProcessedFiles' => $thumbnailGenerator->getNumberOfProcessedFiles(),
89
-                        'numberOfTraversedFiles' => $thumbnailGenerator->getNumberOfTraversedFiles(),
90
-                        'numberOfMissingFiles' => $thumbnailGenerator->getNumberOfMissingFiles(),
91
-                        'totalNumberOfFiles' => $thumbnailGenerator->getTotalNumberOfFiles(),
92
-                    );
93
-                } else {
94
-                    $reports[] = array(
95
-                        'storage' => $storage,
96
-                        'isStorageOnline' => false,
97
-                    );
98
-                }
99
-            }
100
-
101
-            $newOffset = $limit + $offset;
102
-        }
103
-
104
-        $templateNameAndPath = 'EXT:media/Resources/Private/Standalone/Tool/ThumbnailGenerator/WorkResult.html';
105
-        $view = $this->initializeStandaloneView($templateNameAndPath);
106
-
107
-        $view->assign('limit', $limit);
108
-        $view->assign('offset', $newOffset);
109
-        $view->assign('reports', $reports);
110
-        return $view->render();
111
-    }
112
-
113
-    /**
114
-     * @return ThumbnailGenerator|object
115
-     */
116
-    protected function getThumbnailGenerator()
117
-    {
118
-        return GeneralUtility::makeInstance(ThumbnailGenerator::class);
119
-    }
120
-
121
-    /**
122
-     * @return StorageRepository|object
123
-     */
124
-    protected function getStorageRepository()
125
-    {
126
-        return GeneralUtility::makeInstance(StorageRepository::class);
127
-    }
128
-
129
-    /**
130
-     * Tell whether the tools should be displayed according to the context.
131
-     *
132
-     * @return bool
133
-     */
134
-    public function isShown()
135
-    {
136
-        return $this->getBackendUser()->isAdmin();
137
-    }
22
+	/**
23
+	 * Display the title of the tool on the welcome screen.
24
+	 *
25
+	 * @return string
26
+	 */
27
+	public function getTitle()
28
+	{
29
+		return 'Generate thumbnails';
30
+	}
31
+
32
+	/**
33
+	 * Display the description of the tool in the welcome screen.
34
+	 *
35
+	 * @return string
36
+	 */
37
+	public function getDescription()
38
+	{
39
+		$templateNameAndPath = 'EXT:media/Resources/Private/Standalone/Tool/ThumbnailGenerator/Launcher.html';
40
+		$view = $this->initializeStandaloneView($templateNameAndPath);
41
+		$view->assign('sitePath', Environment::getPublicPath() . '/');
42
+		return $view->render();
43
+	}
44
+
45
+	/**
46
+	 * Do the job: analyse Index.
47
+	 *
48
+	 * @param array $arguments
49
+	 * @return string
50
+	 */
51
+	public function work(array $arguments = [])
52
+	{
53
+		$reports = [];
54
+
55
+		$limit = 500; // default value
56
+		$newOffset = 0;
57
+
58
+		// Possible clean up of missing files if the User has clicked so.
59
+		if (isset($arguments['limit']) && isset($arguments['offset'])) {
60
+			$limit = (int)$arguments['limit'];
61
+			$offset = (int)$arguments['offset'];
62
+
63
+			foreach ($this->getStorageRepository()->findAll() as $storage) {
64
+				if ($storage->isOnline()) {
65
+					$thumbnailGenerator = $this->getThumbnailGenerator();
66
+					$thumbnailGenerator
67
+						->setStorage($storage)
68
+						->generate($limit, $offset);
69
+
70
+					$formattedResultSet = [];
71
+					$resultSet = $thumbnailGenerator->getResultSet();
72
+					$processedFileIdentifiers = $thumbnailGenerator->getNewProcessedFileIdentifiers();
73
+
74
+					foreach ($processedFileIdentifiers as $fileIdentifier => $processedFileIdentifier) {
75
+						$result = $resultSet[$fileIdentifier];
76
+						$formattedResultSet[] = sprintf(
77
+							'* File "%s": %s %s',
78
+							$result['fileUid'],
79
+							$result['fileIdentifier'],
80
+							empty($result['thumbnailUri']) ? '' : ' -> ' . $result['thumbnailUri']
81
+						);
82
+					}
83
+
84
+					$reports[] = array(
85
+						'storage' => $storage,
86
+						'isStorageOnline' => true,
87
+						'resultSet' => $formattedResultSet,
88
+						'numberOfProcessedFiles' => $thumbnailGenerator->getNumberOfProcessedFiles(),
89
+						'numberOfTraversedFiles' => $thumbnailGenerator->getNumberOfTraversedFiles(),
90
+						'numberOfMissingFiles' => $thumbnailGenerator->getNumberOfMissingFiles(),
91
+						'totalNumberOfFiles' => $thumbnailGenerator->getTotalNumberOfFiles(),
92
+					);
93
+				} else {
94
+					$reports[] = array(
95
+						'storage' => $storage,
96
+						'isStorageOnline' => false,
97
+					);
98
+				}
99
+			}
100
+
101
+			$newOffset = $limit + $offset;
102
+		}
103
+
104
+		$templateNameAndPath = 'EXT:media/Resources/Private/Standalone/Tool/ThumbnailGenerator/WorkResult.html';
105
+		$view = $this->initializeStandaloneView($templateNameAndPath);
106
+
107
+		$view->assign('limit', $limit);
108
+		$view->assign('offset', $newOffset);
109
+		$view->assign('reports', $reports);
110
+		return $view->render();
111
+	}
112
+
113
+	/**
114
+	 * @return ThumbnailGenerator|object
115
+	 */
116
+	protected function getThumbnailGenerator()
117
+	{
118
+		return GeneralUtility::makeInstance(ThumbnailGenerator::class);
119
+	}
120
+
121
+	/**
122
+	 * @return StorageRepository|object
123
+	 */
124
+	protected function getStorageRepository()
125
+	{
126
+		return GeneralUtility::makeInstance(StorageRepository::class);
127
+	}
128
+
129
+	/**
130
+	 * Tell whether the tools should be displayed according to the context.
131
+	 *
132
+	 * @return bool
133
+	 */
134
+	public function isShown()
135
+	{
136
+		return $this->getBackendUser()->isAdmin();
137
+	}
138 138
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
     {
39 39
         $templateNameAndPath = 'EXT:media/Resources/Private/Standalone/Tool/ThumbnailGenerator/Launcher.html';
40 40
         $view = $this->initializeStandaloneView($templateNameAndPath);
41
-        $view->assign('sitePath', Environment::getPublicPath() . '/');
41
+        $view->assign('sitePath', Environment::getPublicPath().'/');
42 42
         return $view->render();
43 43
     }
44 44
 
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
                             '* File "%s": %s %s',
78 78
                             $result['fileUid'],
79 79
                             $result['fileIdentifier'],
80
-                            empty($result['thumbnailUri']) ? '' : ' -> ' . $result['thumbnailUri']
80
+                            empty($result['thumbnailUri']) ? '' : ' -> '.$result['thumbnailUri']
81 81
                         );
82 82
                     }
83 83
 
Please login to merge, or discard this patch.
Classes/Cache/CacheService.php 2 patches
Indentation   +211 added lines, -211 removed lines patch added patch discarded remove patch
@@ -25,235 +25,235 @@
 block discarded – undo
25 25
  */
26 26
 class CacheService
27 27
 {
28
-    /**
29
-     * Traverse all files and initialize cache values.
30
-     */
31
-    public function warmUp(): int
32
-    {
33
-        /** @var QueryBuilder $queryBuilder */
34
-        $queryBuilder = $this->getQueryBuilder('sys_file');
35
-        $rows = $queryBuilder
36
-            ->select('*')
37
-            ->from('sys_file')
38
-            ->where('storage > 0')
39
-            ->execute()
40
-            ->fetchAllAssociative();
28
+	/**
29
+	 * Traverse all files and initialize cache values.
30
+	 */
31
+	public function warmUp(): int
32
+	{
33
+		/** @var QueryBuilder $queryBuilder */
34
+		$queryBuilder = $this->getQueryBuilder('sys_file');
35
+		$rows = $queryBuilder
36
+			->select('*')
37
+			->from('sys_file')
38
+			->where('storage > 0')
39
+			->execute()
40
+			->fetchAllAssociative();
41 41
 
42
-        $counter = 0;
43
-        foreach ($rows as $row) {
44
-            $fileIdentifier = $row['uid'];
45
-            $totalNumberOfReferences = $this->getFileReferenceService()->countTotalReferences($fileIdentifier);
42
+		$counter = 0;
43
+		foreach ($rows as $row) {
44
+			$fileIdentifier = $row['uid'];
45
+			$totalNumberOfReferences = $this->getFileReferenceService()->countTotalReferences($fileIdentifier);
46 46
 
47
-            $this->getDataService()->update(
48
-                'sys_file',
49
-                [
50
-                    'number_of_references' => $totalNumberOfReferences
51
-                ],
52
-                [
53
-                    'uid' => $fileIdentifier
54
-                ]
55
-            );
56
-            $counter++;
57
-        }
47
+			$this->getDataService()->update(
48
+				'sys_file',
49
+				[
50
+					'number_of_references' => $totalNumberOfReferences
51
+				],
52
+				[
53
+					'uid' => $fileIdentifier
54
+				]
55
+			);
56
+			$counter++;
57
+		}
58 58
 
59
-        return $counter;
60
-    }
59
+		return $counter;
60
+	}
61 61
 
62
-    /**
63
-     * Clear all possible cache related to a file.
64
-     * This method is useful when replacing a file for instance.
65
-     *
66
-     * @param File $file
67
-     * @return void
68
-     */
69
-    public function clearCache(File $file)
70
-    {
71
-        $this->clearCachePages($file);
72
-        $this->flushProcessedFiles($file);
73
-    }
62
+	/**
63
+	 * Clear all possible cache related to a file.
64
+	 * This method is useful when replacing a file for instance.
65
+	 *
66
+	 * @param File $file
67
+	 * @return void
68
+	 */
69
+	public function clearCache(File $file)
70
+	{
71
+		$this->clearCachePages($file);
72
+		$this->flushProcessedFiles($file);
73
+	}
74 74
 
75
-    /**
76
-     * Remove all processed files that belong to the given File object.
77
-     *
78
-     * @param File $file
79
-     * @return void
80
-     */
81
-    protected function flushProcessedFiles(File $file)
82
-    {
83
-        /** @var $processedFile \TYPO3\CMS\Core\Resource\ProcessedFile */
84
-        foreach ($this->getProcessedFileRepository()->findAllByOriginalFile($file) as $processedFile) {
85
-            if ($processedFile->exists()) {
86
-                $processedFile->delete(true);
87
-            }
75
+	/**
76
+	 * Remove all processed files that belong to the given File object.
77
+	 *
78
+	 * @param File $file
79
+	 * @return void
80
+	 */
81
+	protected function flushProcessedFiles(File $file)
82
+	{
83
+		/** @var $processedFile \TYPO3\CMS\Core\Resource\ProcessedFile */
84
+		foreach ($this->getProcessedFileRepository()->findAllByOriginalFile($file) as $processedFile) {
85
+			if ($processedFile->exists()) {
86
+				$processedFile->delete(true);
87
+			}
88 88
 
89
-            $this->getDataService()->delete(
90
-                'sys_file_processedfile',
91
-                [
92
-                    'uid' => (int)$processedFile->getUid()
93
-                ]
94
-            );
95
-        }
96
-    }
89
+			$this->getDataService()->delete(
90
+				'sys_file_processedfile',
91
+				[
92
+					'uid' => (int)$processedFile->getUid()
93
+				]
94
+			);
95
+		}
96
+	}
97 97
 
98
-    /**
99
-     * Return a processed file repository
100
-     *
101
-     * @return ProcessedFileRepository|object
102
-     */
103
-    protected function getProcessedFileRepository()
104
-    {
105
-        return GeneralUtility::makeInstance(ProcessedFileRepository::class);
106
-    }
98
+	/**
99
+	 * Return a processed file repository
100
+	 *
101
+	 * @return ProcessedFileRepository|object
102
+	 */
103
+	protected function getProcessedFileRepository()
104
+	{
105
+		return GeneralUtility::makeInstance(ProcessedFileRepository::class);
106
+	}
107 107
 
108
-    /**
109
-     * Returns the file references.
110
-     *
111
-     * @param File $file
112
-     * @return void
113
-     */
114
-    protected function clearCachePages($file)
115
-    {
116
-        /** @var $tce \TYPO3\CMS\Core\DataHandling\DataHandler */
117
-        $tce = GeneralUtility::makeInstance(DataHandler::class);
118
-        $tce->start([], []);
108
+	/**
109
+	 * Returns the file references.
110
+	 *
111
+	 * @param File $file
112
+	 * @return void
113
+	 */
114
+	protected function clearCachePages($file)
115
+	{
116
+		/** @var $tce \TYPO3\CMS\Core\DataHandling\DataHandler */
117
+		$tce = GeneralUtility::makeInstance(DataHandler::class);
118
+		$tce->start([], []);
119 119
 
120
-        #$pages = array_merge(
121
-        #    $this->findPagesWithFileReferences($file),
122
-        #    $this->findPagesWithSoftReferences($file)
123
-        #);
120
+		#$pages = array_merge(
121
+		#    $this->findPagesWithFileReferences($file),
122
+		#    $this->findPagesWithSoftReferences($file)
123
+		#);
124 124
 
125
-        // Previous code which does not work in TYPO3 CMS 7 LTS.
126
-        // It is adviced to use "registerPageCacheClearing" but how?
127
-        #foreach (array_unique($pages) as $page) {
128
-        #    $tce->clear_cache('pages', $page);
129
-        #}
130
-        $tce->clear_cacheCmd('pages');
131
-    }
125
+		// Previous code which does not work in TYPO3 CMS 7 LTS.
126
+		// It is adviced to use "registerPageCacheClearing" but how?
127
+		#foreach (array_unique($pages) as $page) {
128
+		#    $tce->clear_cache('pages', $page);
129
+		#}
130
+		$tce->clear_cacheCmd('pages');
131
+	}
132 132
 
133
-    /**
134
-     * Find all pages which contains file references to the given $file.
135
-     *
136
-     * @param File $file
137
-     * @return array
138
-     */
139
-    protected function findPagesWithFileReferences($file)
140
-    {
141
-        /** @var QueryBuilder $queryBuilder */
142
-        $queryBuilder = $this->getQueryBuilder('sys_file_reference');
143
-        $rows = $queryBuilder
144
-            ->select('pid')
145
-            ->from('sys_file_reference')
146
-            ->groupBy('pid') // no support for distinct
147
-            ->andWhere(
148
-                'pid > 0',
149
-                'uid_local = ' . $file->getUid()
150
-            )
151
-            ->execute()
152
-            ->fetchAllAssociative();
133
+	/**
134
+	 * Find all pages which contains file references to the given $file.
135
+	 *
136
+	 * @param File $file
137
+	 * @return array
138
+	 */
139
+	protected function findPagesWithFileReferences($file)
140
+	{
141
+		/** @var QueryBuilder $queryBuilder */
142
+		$queryBuilder = $this->getQueryBuilder('sys_file_reference');
143
+		$rows = $queryBuilder
144
+			->select('pid')
145
+			->from('sys_file_reference')
146
+			->groupBy('pid') // no support for distinct
147
+			->andWhere(
148
+				'pid > 0',
149
+				'uid_local = ' . $file->getUid()
150
+			)
151
+			->execute()
152
+			->fetchAllAssociative();
153 153
 
154
-        foreach ($rows as $row) {
155
-            $pages[] = $row['pid'];
156
-        }
154
+		foreach ($rows as $row) {
155
+			$pages[] = $row['pid'];
156
+		}
157 157
 
158
-        return $pages;
159
-    }
158
+		return $pages;
159
+	}
160 160
 
161
-    /**
162
-     * Find all pages which have soft references to the given $file.
163
-     *
164
-     * @param File $file
165
-     * @return array
166
-     */
167
-    #protected function findPagesWithSoftReferences(File $file)
168
-    #{
169
-    #    $subClauseParts = array(
170
-    #        'deleted = 0',
171
-    #        '(softref_key = "rtehtmlarea_images" OR softref_key = "typolink_tag")',
172
-    #        'ref_table = "sys_file"',
173
-    #        'tablename = "tt_content"',
174
-    #        'ref_uid = ' . $file->getUid(),
175
-    #    );
176
-    #
177
-    #    $rows = $this->getDatabaseConnection()->exec_SELECTquery(
178
-    #        'DISTINCT pid',
179
-    #        'tt_content',
180
-    #        sprintf('uid IN (SELECT recuid FROM sys_refindex WHERE %s) %s',
181
-    #            implode(' AND ', $subClauseParts),
182
-    #            $this->getWhereClauseForEnabledFields('tt_content')
183
-    #        )
184
-    #    );
185
-    #
186
-    #    // Compute result
187
-    #    $pages = [];
188
-    #    while ($affectedPage = $this->getDatabaseConnection()->sql_fetch_assoc($rows)) {
189
-    #        $pages[] = $affectedPage['pid'];
190
-    #    }
191
-    #
192
-    #    return $pages;
193
-    #}
161
+	/**
162
+	 * Find all pages which have soft references to the given $file.
163
+	 *
164
+	 * @param File $file
165
+	 * @return array
166
+	 */
167
+	#protected function findPagesWithSoftReferences(File $file)
168
+	#{
169
+	#    $subClauseParts = array(
170
+	#        'deleted = 0',
171
+	#        '(softref_key = "rtehtmlarea_images" OR softref_key = "typolink_tag")',
172
+	#        'ref_table = "sys_file"',
173
+	#        'tablename = "tt_content"',
174
+	#        'ref_uid = ' . $file->getUid(),
175
+	#    );
176
+	#
177
+	#    $rows = $this->getDatabaseConnection()->exec_SELECTquery(
178
+	#        'DISTINCT pid',
179
+	#        'tt_content',
180
+	#        sprintf('uid IN (SELECT recuid FROM sys_refindex WHERE %s) %s',
181
+	#            implode(' AND ', $subClauseParts),
182
+	#            $this->getWhereClauseForEnabledFields('tt_content')
183
+	#        )
184
+	#    );
185
+	#
186
+	#    // Compute result
187
+	#    $pages = [];
188
+	#    while ($affectedPage = $this->getDatabaseConnection()->sql_fetch_assoc($rows)) {
189
+	#        $pages[] = $affectedPage['pid'];
190
+	#    }
191
+	#
192
+	#    return $pages;
193
+	#}
194 194
 
195
-    /**
196
-     * Get the WHERE clause for the enabled fields given a $tableName.
197
-     *
198
-     * @param string $tableName
199
-     * @return string
200
-     */
201
-    protected function getWhereClauseForEnabledFields($tableName)
202
-    {
203
-        if ($this->isFrontendMode()) {
204
-            // frontend context
205
-            $whereClause = $this->getPageRepository()->deleteClause($tableName);
206
-        } else {
207
-            // backend context
208
-            $whereClause = BackendUtility::deleteClause($tableName);
209
-        }
210
-        return $whereClause;
211
-    }
195
+	/**
196
+	 * Get the WHERE clause for the enabled fields given a $tableName.
197
+	 *
198
+	 * @param string $tableName
199
+	 * @return string
200
+	 */
201
+	protected function getWhereClauseForEnabledFields($tableName)
202
+	{
203
+		if ($this->isFrontendMode()) {
204
+			// frontend context
205
+			$whereClause = $this->getPageRepository()->deleteClause($tableName);
206
+		} else {
207
+			// backend context
208
+			$whereClause = BackendUtility::deleteClause($tableName);
209
+		}
210
+		return $whereClause;
211
+	}
212 212
 
213
-    /**
214
-     * Returns whether the current mode is Frontend
215
-     *
216
-     * @return string
217
-     */
218
-    protected function isFrontendMode()
219
-    {
220
-        return ApplicationType::fromRequest($GLOBALS['TYPO3_REQUEST'])->isFrontend();
221
-    }
213
+	/**
214
+	 * Returns whether the current mode is Frontend
215
+	 *
216
+	 * @return string
217
+	 */
218
+	protected function isFrontendMode()
219
+	{
220
+		return ApplicationType::fromRequest($GLOBALS['TYPO3_REQUEST'])->isFrontend();
221
+	}
222 222
 
223
-    /**
224
-     * Returns an instance of the page repository.
225
-     *
226
-     * @return PageRepository
227
-     */
228
-    protected function getPageRepository()
229
-    {
230
-        return $GLOBALS['TSFE']->sys_page;
231
-    }
223
+	/**
224
+	 * Returns an instance of the page repository.
225
+	 *
226
+	 * @return PageRepository
227
+	 */
228
+	protected function getPageRepository()
229
+	{
230
+		return $GLOBALS['TSFE']->sys_page;
231
+	}
232 232
 
233
-    /**
234
-     * @param string $tableName
235
-     * @return object|QueryBuilder
236
-     */
237
-    protected function getQueryBuilder($tableName): QueryBuilder
238
-    {
239
-        /** @var ConnectionPool $connectionPool */
240
-        $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
241
-        return $connectionPool->getQueryBuilderForTable($tableName);
242
-    }
233
+	/**
234
+	 * @param string $tableName
235
+	 * @return object|QueryBuilder
236
+	 */
237
+	protected function getQueryBuilder($tableName): QueryBuilder
238
+	{
239
+		/** @var ConnectionPool $connectionPool */
240
+		$connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
241
+		return $connectionPool->getQueryBuilderForTable($tableName);
242
+	}
243 243
 
244
-    /**
245
-     * @return object|DataService
246
-     */
247
-    protected function getDataService(): DataService
248
-    {
249
-        return GeneralUtility::makeInstance(DataService::class);
250
-    }
244
+	/**
245
+	 * @return object|DataService
246
+	 */
247
+	protected function getDataService(): DataService
248
+	{
249
+		return GeneralUtility::makeInstance(DataService::class);
250
+	}
251 251
 
252
-    /**
253
-     * @return FileReferenceService|object
254
-     */
255
-    protected function getFileReferenceService()
256
-    {
257
-        return GeneralUtility::makeInstance(FileReferenceService::class);
258
-    }
252
+	/**
253
+	 * @return FileReferenceService|object
254
+	 */
255
+	protected function getFileReferenceService()
256
+	{
257
+		return GeneralUtility::makeInstance(FileReferenceService::class);
258
+	}
259 259
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -146,7 +146,7 @@
 block discarded – undo
146 146
             ->groupBy('pid') // no support for distinct
147 147
             ->andWhere(
148 148
                 'pid > 0',
149
-                'uid_local = ' . $file->getUid()
149
+                'uid_local = '.$file->getUid()
150 150
             )
151 151
             ->execute()
152 152
             ->fetchAllAssociative();
Please login to merge, or discard this patch.
Classes/Utility/PermissionUtility.php 1 patch
Indentation   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -20,75 +20,75 @@
 block discarded – undo
20 20
  */
21 21
 class PermissionUtility implements SingletonInterface
22 22
 {
23
-    /**
24
-     * Returns a class instance.
25
-     *
26
-     * @return PermissionUtility
27
-     * @throws \InvalidArgumentException
28
-     */
29
-    public static function getInstance()
30
-    {
31
-        return GeneralUtility::makeInstance(PermissionUtility::class);
32
-    }
23
+	/**
24
+	 * Returns a class instance.
25
+	 *
26
+	 * @return PermissionUtility
27
+	 * @throws \InvalidArgumentException
28
+	 */
29
+	public static function getInstance()
30
+	{
31
+		return GeneralUtility::makeInstance(PermissionUtility::class);
32
+	}
33 33
 
34
-    /**
35
-     * Returns allowed extensions given a possible storage.
36
-     *
37
-     * @param null|int|ResourceStorage $storage
38
-     * @return array
39
-     * @throws \InvalidArgumentException
40
-     */
41
-    public function getAllowedExtensions($storage = null)
42
-    {
43
-        $fieldNames = array(
44
-            'extension_allowed_file_type_1',
45
-            'extension_allowed_file_type_2',
46
-            'extension_allowed_file_type_3',
47
-            'extension_allowed_file_type_4',
48
-            'extension_allowed_file_type_5',
49
-        );
34
+	/**
35
+	 * Returns allowed extensions given a possible storage.
36
+	 *
37
+	 * @param null|int|ResourceStorage $storage
38
+	 * @return array
39
+	 * @throws \InvalidArgumentException
40
+	 */
41
+	public function getAllowedExtensions($storage = null)
42
+	{
43
+		$fieldNames = array(
44
+			'extension_allowed_file_type_1',
45
+			'extension_allowed_file_type_2',
46
+			'extension_allowed_file_type_3',
47
+			'extension_allowed_file_type_4',
48
+			'extension_allowed_file_type_5',
49
+		);
50 50
 
51
-        if (!is_null($storage)) {
52
-            if (!$storage instanceof ResourceStorage) {
53
-                $storage = $this->getResourceFactory()->getStorageObject((int)$storage);
54
-            }
55
-        } else {
56
-            $storage = $this->getMediaModule()->getCurrentStorage();
57
-        }
51
+		if (!is_null($storage)) {
52
+			if (!$storage instanceof ResourceStorage) {
53
+				$storage = $this->getResourceFactory()->getStorageObject((int)$storage);
54
+			}
55
+		} else {
56
+			$storage = $this->getMediaModule()->getCurrentStorage();
57
+		}
58 58
 
59
-        $storageRecord = $storage->getStorageRecord();
60
-        $allowedExtensions = [];
61
-        foreach ($fieldNames as $fieldName) {
62
-            $_allowedExtensions = GeneralUtility::trimExplode(',', $storageRecord[$fieldName], true);
63
-            $allowedExtensions = array_merge($allowedExtensions, $_allowedExtensions);
64
-        }
59
+		$storageRecord = $storage->getStorageRecord();
60
+		$allowedExtensions = [];
61
+		foreach ($fieldNames as $fieldName) {
62
+			$_allowedExtensions = GeneralUtility::trimExplode(',', $storageRecord[$fieldName], true);
63
+			$allowedExtensions = array_merge($allowedExtensions, $_allowedExtensions);
64
+		}
65 65
 
66
-        $uniqueAllowedExtensions = array_unique($allowedExtensions);
67
-        return array_filter($uniqueAllowedExtensions, 'strlen');
68
-    }
66
+		$uniqueAllowedExtensions = array_unique($allowedExtensions);
67
+		return array_filter($uniqueAllowedExtensions, 'strlen');
68
+	}
69 69
 
70
-    /**
71
-     * Returns allowed extensions list.
72
-     *
73
-     * @return string
74
-     * @throws \InvalidArgumentException
75
-     */
76
-    public function getAllowedExtensionList()
77
-    {
78
-        return implode(',', $this->getAllowedExtensions());
79
-    }
70
+	/**
71
+	 * Returns allowed extensions list.
72
+	 *
73
+	 * @return string
74
+	 * @throws \InvalidArgumentException
75
+	 */
76
+	public function getAllowedExtensionList()
77
+	{
78
+		return implode(',', $this->getAllowedExtensions());
79
+	}
80 80
 
81
-    /**
82
-     * @return MediaModule|object
83
-     * @throws \InvalidArgumentException
84
-     */
85
-    protected function getMediaModule()
86
-    {
87
-        return GeneralUtility::makeInstance(MediaModule::class);
88
-    }
81
+	/**
82
+	 * @return MediaModule|object
83
+	 * @throws \InvalidArgumentException
84
+	 */
85
+	protected function getMediaModule()
86
+	{
87
+		return GeneralUtility::makeInstance(MediaModule::class);
88
+	}
89 89
 
90
-    protected function getResourceFactory(): ResourceFactory
91
-    {
92
-        return GeneralUtility::makeInstance(ResourceFactory::class);
93
-    }
90
+	protected function getResourceFactory(): ResourceFactory
91
+	{
92
+		return GeneralUtility::makeInstance(ResourceFactory::class);
93
+	}
94 94
 }
Please login to merge, or discard this patch.
Classes/Utility/SessionUtility.php 1 patch
Indentation   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -17,61 +17,61 @@
 block discarded – undo
17 17
  */
18 18
 class SessionUtility implements SingletonInterface
19 19
 {
20
-    /**
21
-     * @var string
22
-     */
23
-    protected $moduleKey = 'media';
20
+	/**
21
+	 * @var string
22
+	 */
23
+	protected $moduleKey = 'media';
24 24
 
25
-    /**
26
-     * Returns a class instance.
27
-     *
28
-     * @return \Fab\Media\Utility\SessionUtility|object
29
-     */
30
-    public static function getInstance()
31
-    {
32
-        return GeneralUtility::makeInstance(\Fab\Media\Utility\SessionUtility::class);
33
-    }
25
+	/**
26
+	 * Returns a class instance.
27
+	 *
28
+	 * @return \Fab\Media\Utility\SessionUtility|object
29
+	 */
30
+	public static function getInstance()
31
+	{
32
+		return GeneralUtility::makeInstance(\Fab\Media\Utility\SessionUtility::class);
33
+	}
34 34
 
35
-    public function __construct()
36
-    {
37
-        // Initialize storage from the current
38
-        if (!is_array($this->getBackendUser()->uc['moduleData'][$this->moduleKey])) {
39
-            $this->getBackendUser()->uc['moduleData'][$this->moduleKey] = [];
40
-            $this->getBackendUser()->writeUC();
41
-        }
42
-    }
35
+	public function __construct()
36
+	{
37
+		// Initialize storage from the current
38
+		if (!is_array($this->getBackendUser()->uc['moduleData'][$this->moduleKey])) {
39
+			$this->getBackendUser()->uc['moduleData'][$this->moduleKey] = [];
40
+			$this->getBackendUser()->writeUC();
41
+		}
42
+	}
43 43
 
44
-    /**
45
-     * Return a value from the Session according to the key
46
-     *
47
-     * @param string $key
48
-     * @return mixed
49
-     */
50
-    public function get($key)
51
-    {
52
-        return $this->getBackendUser()->uc['moduleData'][$this->moduleKey][$key];
53
-    }
44
+	/**
45
+	 * Return a value from the Session according to the key
46
+	 *
47
+	 * @param string $key
48
+	 * @return mixed
49
+	 */
50
+	public function get($key)
51
+	{
52
+		return $this->getBackendUser()->uc['moduleData'][$this->moduleKey][$key];
53
+	}
54 54
 
55
-    /**
56
-     * Set a key to the Session.
57
-     *
58
-     * @param string $key
59
-     * @param mixed $value
60
-     * @return void
61
-     */
62
-    public function set($key, $value)
63
-    {
64
-        $this->getBackendUser()->uc['moduleData'][$this->moduleKey][$key] = $value;
65
-        $this->getBackendUser()->writeUC();
66
-    }
55
+	/**
56
+	 * Set a key to the Session.
57
+	 *
58
+	 * @param string $key
59
+	 * @param mixed $value
60
+	 * @return void
61
+	 */
62
+	public function set($key, $value)
63
+	{
64
+		$this->getBackendUser()->uc['moduleData'][$this->moduleKey][$key] = $value;
65
+		$this->getBackendUser()->writeUC();
66
+	}
67 67
 
68
-    /**
69
-     * Returns an instance of the current Backend User.
70
-     *
71
-     * @return BackendUserAuthentication
72
-     */
73
-    protected function getBackendUser()
74
-    {
75
-        return $GLOBALS['BE_USER'];
76
-    }
68
+	/**
69
+	 * Returns an instance of the current Backend User.
70
+	 *
71
+	 * @return BackendUserAuthentication
72
+	 */
73
+	protected function getBackendUser()
74
+	{
75
+		return $GLOBALS['BE_USER'];
76
+	}
77 77
 }
Please login to merge, or discard this patch.
Classes/Utility/ClientValidation.php 1 patch
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -16,28 +16,28 @@
 block discarded – undo
16 16
  */
17 17
 class ClientValidation implements SingletonInterface
18 18
 {
19
-    /**
20
-     * Returns a class instance
21
-     *
22
-     * @return \Fab\Media\Utility\ClientValidation|object
23
-     */
24
-    public static function getInstance()
25
-    {
26
-        return GeneralUtility::makeInstance(\Fab\Media\Utility\ClientValidation::class);
27
-    }
19
+	/**
20
+	 * Returns a class instance
21
+	 *
22
+	 * @return \Fab\Media\Utility\ClientValidation|object
23
+	 */
24
+	public static function getInstance()
25
+	{
26
+		return GeneralUtility::makeInstance(\Fab\Media\Utility\ClientValidation::class);
27
+	}
28 28
 
29
-    /**
30
-     * Get the validation class name given a field.
31
-     *
32
-     * @param string $fieldName
33
-     * @return string
34
-     */
35
-    public function get($fieldName)
36
-    {
37
-        $result = '';
38
-        if (TcaField::getService()->isRequired($fieldName)) {
39
-            $result = ' validate[required]';
40
-        }
41
-        return $result;
42
-    }
29
+	/**
30
+	 * Get the validation class name given a field.
31
+	 *
32
+	 * @param string $fieldName
33
+	 * @return string
34
+	 */
35
+	public function get($fieldName)
36
+	{
37
+		$result = '';
38
+		if (TcaField::getService()->isRequired($fieldName)) {
39
+			$result = ' validate[required]';
40
+		}
41
+		return $result;
42
+	}
43 43
 }
Please login to merge, or discard this patch.
Classes/Utility/ImagePresetUtility.php 2 patches
Indentation   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -18,92 +18,92 @@
 block discarded – undo
18 18
  */
19 19
 class ImagePresetUtility implements SingletonInterface
20 20
 {
21
-    /**
22
-     * @var array
23
-     */
24
-    protected $store = [];
21
+	/**
22
+	 * @var array
23
+	 */
24
+	protected $store = [];
25 25
 
26
-    /**
27
-     * @var string
28
-     */
29
-    protected $currentPreset = '';
26
+	/**
27
+	 * @var string
28
+	 */
29
+	protected $currentPreset = '';
30 30
 
31
-    /**
32
-     * Returns a class instance
33
-     *
34
-     * @return \Fab\Media\Utility\ImagePresetUtility|object
35
-     */
36
-    public static function getInstance()
37
-    {
38
-        return GeneralUtility::makeInstance(\Fab\Media\Utility\ImagePresetUtility::class);
39
-    }
31
+	/**
32
+	 * Returns a class instance
33
+	 *
34
+	 * @return \Fab\Media\Utility\ImagePresetUtility|object
35
+	 */
36
+	public static function getInstance()
37
+	{
38
+		return GeneralUtility::makeInstance(\Fab\Media\Utility\ImagePresetUtility::class);
39
+	}
40 40
 
41
-    /**
42
-     * Set the current preset value. Preset values come from the settings and can be:
43
-     * image_thumbnail, image_mini, image_small, image_medium, image_large
44
-     *
45
-     * @throws EmptyValueException
46
-     * @param string $preset image_thumbnail, image_mini, ...
47
-     * @return \Fab\Media\Utility\ImagePresetUtility
48
-     */
49
-    public function preset($preset)
50
-    {
51
-        $size = ConfigurationUtility::getInstance()->get($preset);
52
-        if (is_null($size)) {
53
-            throw new EmptyValueException('No value for preset: ' . $preset, 1362501066);
54
-        }
41
+	/**
42
+	 * Set the current preset value. Preset values come from the settings and can be:
43
+	 * image_thumbnail, image_mini, image_small, image_medium, image_large
44
+	 *
45
+	 * @throws EmptyValueException
46
+	 * @param string $preset image_thumbnail, image_mini, ...
47
+	 * @return \Fab\Media\Utility\ImagePresetUtility
48
+	 */
49
+	public function preset($preset)
50
+	{
51
+		$size = ConfigurationUtility::getInstance()->get($preset);
52
+		if (is_null($size)) {
53
+			throw new EmptyValueException('No value for preset: ' . $preset, 1362501066);
54
+		}
55 55
 
56
-        $this->currentPreset = $preset;
57
-        if (!isset($this->store[$this->currentPreset])) {
58
-            // @todo use object Dimension instead
59
-            $dimensions = GeneralUtility::trimExplode('x', $size);
60
-            $this->store[$this->currentPreset]['width'] = empty($dimensions[0]) ? 0 : $dimensions[0];
61
-            $this->store[$this->currentPreset]['height'] = empty($dimensions[1]) ? 0 : $dimensions[1];
62
-        }
63
-        return $this;
64
-    }
56
+		$this->currentPreset = $preset;
57
+		if (!isset($this->store[$this->currentPreset])) {
58
+			// @todo use object Dimension instead
59
+			$dimensions = GeneralUtility::trimExplode('x', $size);
60
+			$this->store[$this->currentPreset]['width'] = empty($dimensions[0]) ? 0 : $dimensions[0];
61
+			$this->store[$this->currentPreset]['height'] = empty($dimensions[1]) ? 0 : $dimensions[1];
62
+		}
63
+		return $this;
64
+	}
65 65
 
66
-    /**
67
-     * @return array
68
-     */
69
-    public function getStore()
70
-    {
71
-        return $this->store;
72
-    }
66
+	/**
67
+	 * @return array
68
+	 */
69
+	public function getStore()
70
+	{
71
+		return $this->store;
72
+	}
73 73
 
74
-    /**
75
-     * @param array $store
76
-     */
77
-    public function setStore($store)
78
-    {
79
-        $this->store = $store;
80
-    }
74
+	/**
75
+	 * @param array $store
76
+	 */
77
+	public function setStore($store)
78
+	{
79
+		$this->store = $store;
80
+	}
81 81
 
82
-    /**
83
-     * Returns width of the current preset.
84
-     *
85
-     * @throws InvalidKeyInArrayException
86
-     * @return int
87
-     */
88
-    public function getWidth()
89
-    {
90
-        if (empty($this->store[$this->currentPreset])) {
91
-            throw new InvalidKeyInArrayException('No existing values for current preset. Have you set a preset?', 1362501853);
92
-        }
93
-        return (int)$this->store[$this->currentPreset]['width'];
94
-    }
82
+	/**
83
+	 * Returns width of the current preset.
84
+	 *
85
+	 * @throws InvalidKeyInArrayException
86
+	 * @return int
87
+	 */
88
+	public function getWidth()
89
+	{
90
+		if (empty($this->store[$this->currentPreset])) {
91
+			throw new InvalidKeyInArrayException('No existing values for current preset. Have you set a preset?', 1362501853);
92
+		}
93
+		return (int)$this->store[$this->currentPreset]['width'];
94
+	}
95 95
 
96
-    /**
97
-     * Returns height of the current preset.
98
-     *
99
-     * @throws InvalidKeyInArrayException
100
-     * @return int
101
-     */
102
-    public function getHeight()
103
-    {
104
-        if (empty($this->store[$this->currentPreset])) {
105
-            throw new InvalidKeyInArrayException('No existing values for current preset. Have you set a preset?', 1362501853);
106
-        }
107
-        return (int)$this->store[$this->currentPreset]['height'];
108
-    }
96
+	/**
97
+	 * Returns height of the current preset.
98
+	 *
99
+	 * @throws InvalidKeyInArrayException
100
+	 * @return int
101
+	 */
102
+	public function getHeight()
103
+	{
104
+		if (empty($this->store[$this->currentPreset])) {
105
+			throw new InvalidKeyInArrayException('No existing values for current preset. Have you set a preset?', 1362501853);
106
+		}
107
+		return (int)$this->store[$this->currentPreset]['height'];
108
+	}
109 109
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@
 block discarded – undo
50 50
     {
51 51
         $size = ConfigurationUtility::getInstance()->get($preset);
52 52
         if (is_null($size)) {
53
-            throw new EmptyValueException('No value for preset: ' . $preset, 1362501066);
53
+            throw new EmptyValueException('No value for preset: '.$preset, 1362501066);
54 54
         }
55 55
 
56 56
         $this->currentPreset = $preset;
Please login to merge, or discard this patch.
Classes/Utility/ConfigurationUtility.php 1 patch
Indentation   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -17,67 +17,67 @@
 block discarded – undo
17 17
  */
18 18
 class ConfigurationUtility implements SingletonInterface
19 19
 {
20
-    /**
21
-     * @var string
22
-     */
23
-    protected $extensionKey = 'media';
20
+	/**
21
+	 * @var string
22
+	 */
23
+	protected $extensionKey = 'media';
24 24
 
25
-    /**
26
-     * @var array
27
-     */
28
-    protected $configuration = [];
25
+	/**
26
+	 * @var array
27
+	 */
28
+	protected $configuration = [];
29 29
 
30
-    /**
31
-     * Returns a class instance.
32
-     *
33
-     * @return \Fab\Media\Utility\ConfigurationUtility|object
34
-     */
35
-    public static function getInstance()
36
-    {
37
-        return GeneralUtility::makeInstance(\Fab\Media\Utility\ConfigurationUtility::class);
38
-    }
30
+	/**
31
+	 * Returns a class instance.
32
+	 *
33
+	 * @return \Fab\Media\Utility\ConfigurationUtility|object
34
+	 */
35
+	public static function getInstance()
36
+	{
37
+		return GeneralUtility::makeInstance(\Fab\Media\Utility\ConfigurationUtility::class);
38
+	}
39 39
 
40
-    /**
41
-     * Constructor
42
-     */
43
-    public function __construct()
44
-    {
45
-        $configuration = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get('media');
40
+	/**
41
+	 * Constructor
42
+	 */
43
+	public function __construct()
44
+	{
45
+		$configuration = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get('media');
46 46
 
47
-        // Fill up configuration array with relevant values.
48
-        foreach ($configuration as $key => $value) {
49
-            $this->configuration[$key] = $value;
50
-        }
51
-    }
47
+		// Fill up configuration array with relevant values.
48
+		foreach ($configuration as $key => $value) {
49
+			$this->configuration[$key] = $value;
50
+		}
51
+	}
52 52
 
53
-    /**
54
-     * Returns a setting key.
55
-     *
56
-     * @param string $key
57
-     * @return array
58
-     */
59
-    public function get($key)
60
-    {
61
-        return isset($this->configuration[$key]) ? trim($this->configuration[$key]) : null;
62
-    }
53
+	/**
54
+	 * Returns a setting key.
55
+	 *
56
+	 * @param string $key
57
+	 * @return array
58
+	 */
59
+	public function get($key)
60
+	{
61
+		return isset($this->configuration[$key]) ? trim($this->configuration[$key]) : null;
62
+	}
63 63
 
64
-    /**
65
-     * Set a setting key.
66
-     *
67
-     * @param string $key
68
-     * @param mixed $value
69
-     * @return void
70
-     */
71
-    public function set($key, $value)
72
-    {
73
-        $this->configuration[$key] = $value;
74
-    }
64
+	/**
65
+	 * Set a setting key.
66
+	 *
67
+	 * @param string $key
68
+	 * @param mixed $value
69
+	 * @return void
70
+	 */
71
+	public function set($key, $value)
72
+	{
73
+		$this->configuration[$key] = $value;
74
+	}
75 75
 
76
-    /**
77
-     * @return array
78
-     */
79
-    public function getConfiguration()
80
-    {
81
-        return $this->configuration;
82
-    }
76
+	/**
77
+	 * @return array
78
+	 */
79
+	public function getConfiguration()
80
+	{
81
+		return $this->configuration;
82
+	}
83 83
 }
Please login to merge, or discard this patch.
Classes/Utility/Logger.php 1 patch
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -17,18 +17,18 @@
 block discarded – undo
17 17
  */
18 18
 class Logger implements SingletonInterface
19 19
 {
20
-    /**
21
-     * Returns a logger class instance.
22
-     *
23
-     * @param mixed $instance
24
-     * @return \TYPO3\CMS\Core\Log\Logger
25
-     */
26
-    public static function getInstance($instance)
27
-    {
28
-        /** @var $loggerManager \TYPO3\CMS\Core\Log\LogManager */
29
-        $loggerManager = GeneralUtility::makeInstance(LogManager::class);
20
+	/**
21
+	 * Returns a logger class instance.
22
+	 *
23
+	 * @param mixed $instance
24
+	 * @return \TYPO3\CMS\Core\Log\Logger
25
+	 */
26
+	public static function getInstance($instance)
27
+	{
28
+		/** @var $loggerManager \TYPO3\CMS\Core\Log\LogManager */
29
+		$loggerManager = GeneralUtility::makeInstance(LogManager::class);
30 30
 
31
-        /** @var $logger \TYPO3\CMS\Core\Log\Logger */
32
-        return $loggerManager->getLogger(get_class($instance));
33
-    }
31
+		/** @var $logger \TYPO3\CMS\Core\Log\Logger */
32
+		return $loggerManager->getLogger(get_class($instance));
33
+	}
34 34
 }
Please login to merge, or discard this patch.
Classes/Utility/Path.php 2 patches
Indentation   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -18,77 +18,77 @@
 block discarded – undo
18 18
  */
19 19
 class Path
20 20
 {
21
-    /**
22
-     * @var string
23
-     */
24
-    protected static $extensionName = 'media';
21
+	/**
22
+	 * @var string
23
+	 */
24
+	protected static $extensionName = 'media';
25 25
 
26
-    /**
27
-     * Return a public path pointing to a resource.
28
-     *
29
-     * @param string $resource
30
-     * @return string
31
-     */
32
-    public static function getRelativePath($resource)
33
-    {
34
-        // If file is not found, resolve the path
35
-        if (!is_file(Environment::getPublicPath() . '/' . $resource)) {
36
-            $resource = substr(self::resolvePath($resource), strlen(Environment::getPublicPath() . '/'));
37
-        }
26
+	/**
27
+	 * Return a public path pointing to a resource.
28
+	 *
29
+	 * @param string $resource
30
+	 * @return string
31
+	 */
32
+	public static function getRelativePath($resource)
33
+	{
34
+		// If file is not found, resolve the path
35
+		if (!is_file(Environment::getPublicPath() . '/' . $resource)) {
36
+			$resource = substr(self::resolvePath($resource), strlen(Environment::getPublicPath() . '/'));
37
+		}
38 38
 
39
-        return PathUtility::getRelativePathTo(PathUtility::dirname(Environment::getPublicPath() . '/' . $resource)) . PathUtility::basename($resource);
40
-    }
39
+		return PathUtility::getRelativePathTo(PathUtility::dirname(Environment::getPublicPath() . '/' . $resource)) . PathUtility::basename($resource);
40
+	}
41 41
 
42
-    /**
43
-     * Resolves path e.g. EXT:media/Resources/Public/foo.png or ../../foo and returns an absolute path to the given resource.
44
-     *
45
-     * @param string $resource
46
-     * @return string
47
-     */
48
-    public static function resolvePath($resource)
49
-    {
50
-        $resource = self::canonicalPath($resource);
51
-        if (!is_file(Environment::getPublicPath() . '/' . $resource)) {
52
-            $resource = 'EXT:' . GeneralUtility::camelCaseToLowerCaseUnderscored(self::$extensionName) . '/Resources/Public/' . $resource;
53
-        }
54
-        return GeneralUtility::getFileAbsFileName($resource);
55
-    }
42
+	/**
43
+	 * Resolves path e.g. EXT:media/Resources/Public/foo.png or ../../foo and returns an absolute path to the given resource.
44
+	 *
45
+	 * @param string $resource
46
+	 * @return string
47
+	 */
48
+	public static function resolvePath($resource)
49
+	{
50
+		$resource = self::canonicalPath($resource);
51
+		if (!is_file(Environment::getPublicPath() . '/' . $resource)) {
52
+			$resource = 'EXT:' . GeneralUtility::camelCaseToLowerCaseUnderscored(self::$extensionName) . '/Resources/Public/' . $resource;
53
+		}
54
+		return GeneralUtility::getFileAbsFileName($resource);
55
+	}
56 56
 
57
-    /**
58
-     * Tell whether a resource exist.
59
-     *
60
-     * @param string $resource
61
-     * @return string
62
-     */
63
-    public static function exists($resource)
64
-    {
65
-        return is_file(self::resolvePath($resource));
66
-    }
57
+	/**
58
+	 * Tell whether a resource exist.
59
+	 *
60
+	 * @param string $resource
61
+	 * @return string
62
+	 */
63
+	public static function exists($resource)
64
+	{
65
+		return is_file(self::resolvePath($resource));
66
+	}
67 67
 
68
-    /**
69
-     * Tell whether a resource does not exist.
70
-     *
71
-     * @param string $resource
72
-     * @return string
73
-     */
74
-    public static function notExists($resource)
75
-    {
76
-        return !self::exists($resource);
77
-    }
68
+	/**
69
+	 * Tell whether a resource does not exist.
70
+	 *
71
+	 * @param string $resource
72
+	 * @return string
73
+	 */
74
+	public static function notExists($resource)
75
+	{
76
+		return !self::exists($resource);
77
+	}
78 78
 
79
-    /**
80
-     * Returns a canonical path by stripping relative segment ../foo/../bar will become foo/bar
81
-     *
82
-     * @param $resource
83
-     * @return string
84
-     */
85
-    public static function canonicalPath($resource)
86
-    {
87
-        $segments = explode('/', $resource);
88
-        $keys = array_keys($segments, '..');
89
-        foreach ($keys as $key) {
90
-            unset($segments[$key]);
91
-        }
92
-        return implode('/', $segments);
93
-    }
79
+	/**
80
+	 * Returns a canonical path by stripping relative segment ../foo/../bar will become foo/bar
81
+	 *
82
+	 * @param $resource
83
+	 * @return string
84
+	 */
85
+	public static function canonicalPath($resource)
86
+	{
87
+		$segments = explode('/', $resource);
88
+		$keys = array_keys($segments, '..');
89
+		foreach ($keys as $key) {
90
+			unset($segments[$key]);
91
+		}
92
+		return implode('/', $segments);
93
+	}
94 94
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -32,11 +32,11 @@  discard block
 block discarded – undo
32 32
     public static function getRelativePath($resource)
33 33
     {
34 34
         // If file is not found, resolve the path
35
-        if (!is_file(Environment::getPublicPath() . '/' . $resource)) {
36
-            $resource = substr(self::resolvePath($resource), strlen(Environment::getPublicPath() . '/'));
35
+        if (!is_file(Environment::getPublicPath().'/'.$resource)) {
36
+            $resource = substr(self::resolvePath($resource), strlen(Environment::getPublicPath().'/'));
37 37
         }
38 38
 
39
-        return PathUtility::getRelativePathTo(PathUtility::dirname(Environment::getPublicPath() . '/' . $resource)) . PathUtility::basename($resource);
39
+        return PathUtility::getRelativePathTo(PathUtility::dirname(Environment::getPublicPath().'/'.$resource)).PathUtility::basename($resource);
40 40
     }
41 41
 
42 42
     /**
@@ -48,8 +48,8 @@  discard block
 block discarded – undo
48 48
     public static function resolvePath($resource)
49 49
     {
50 50
         $resource = self::canonicalPath($resource);
51
-        if (!is_file(Environment::getPublicPath() . '/' . $resource)) {
52
-            $resource = 'EXT:' . GeneralUtility::camelCaseToLowerCaseUnderscored(self::$extensionName) . '/Resources/Public/' . $resource;
51
+        if (!is_file(Environment::getPublicPath().'/'.$resource)) {
52
+            $resource = 'EXT:'.GeneralUtility::camelCaseToLowerCaseUnderscored(self::$extensionName).'/Resources/Public/'.$resource;
53 53
         }
54 54
         return GeneralUtility::getFileAbsFileName($resource);
55 55
     }
Please login to merge, or discard this patch.