Completed
Push — master ( b0b1c6...4fec92 )
by Fabien
54:17
created
Classes/TypeConverter/ContentToFileConverter.php 1 patch
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -20,33 +20,33 @@
 block discarded – undo
20 20
  */
21 21
 class ContentToFileConverter implements SingletonInterface
22 22
 {
23
-    /**
24
-     * Convert a file representation to File Resource.
25
-     *
26
-     * @param Content|int $fileRepresentation
27
-     * @throws \RuntimeException
28
-     * @return File
29
-     */
30
-    public function convert($fileRepresentation)
31
-    {
32
-        if ($fileRepresentation instanceof Content) {
33
-            $fileData = $fileRepresentation->toArray();
34
-            $fileData['modification_date'] = $fileData['tstamp'];
23
+	/**
24
+	 * Convert a file representation to File Resource.
25
+	 *
26
+	 * @param Content|int $fileRepresentation
27
+	 * @throws \RuntimeException
28
+	 * @return File
29
+	 */
30
+	public function convert($fileRepresentation)
31
+	{
32
+		if ($fileRepresentation instanceof Content) {
33
+			$fileData = $fileRepresentation->toArray();
34
+			$fileData['modification_date'] = $fileData['tstamp'];
35 35
 
36
-            if (!isset($fileData['storage']) && $fileData['storage'] === null) {
37
-                throw new \RuntimeException('Storage identifier can not be null.', 1379946981);
38
-            }
36
+			if (!isset($fileData['storage']) && $fileData['storage'] === null) {
37
+				throw new \RuntimeException('Storage identifier can not be null.', 1379946981);
38
+			}
39 39
 
40
-            $fileUid = $fileData['uid'];
41
-        } else {
42
-            $fileData = [];
43
-            $fileUid = (int)$fileRepresentation;
44
-        }
45
-        return $this->getResourceFactory()->getFileObject($fileUid, $fileData);
46
-    }
40
+			$fileUid = $fileData['uid'];
41
+		} else {
42
+			$fileData = [];
43
+			$fileUid = (int)$fileRepresentation;
44
+		}
45
+		return $this->getResourceFactory()->getFileObject($fileUid, $fileData);
46
+	}
47 47
 
48
-    protected function getResourceFactory(): ResourceFactory
49
-    {
50
-        return GeneralUtility::makeInstance(ResourceFactory::class);
51
-    }
48
+	protected function getResourceFactory(): ResourceFactory
49
+	{
50
+		return GeneralUtility::makeInstance(ResourceFactory::class);
51
+	}
52 52
 }
Please login to merge, or discard this patch.
Classes/Tool/DuplicateFilesFinderTool.php 2 patches
Indentation   +195 added lines, -195 removed lines patch added patch discarded remove patch
@@ -24,199 +24,199 @@
 block discarded – undo
24 24
  */
25 25
 class DuplicateFilesFinderTool extends AbstractTool
26 26
 {
27
-    /**
28
-     * Display the title of the tool on the welcome screen.
29
-     *
30
-     * @return string
31
-     */
32
-    public function getTitle()
33
-    {
34
-        return 'Find duplicate Files';
35
-    }
36
-
37
-    /**
38
-     * Display the description of the tool in the welcome screen.
39
-     *
40
-     * @return string
41
-     */
42
-    public function getDescription()
43
-    {
44
-        $templateNameAndPath = 'EXT:media/Resources/Private/Standalone/Tool/DuplicateFilesFinder/Launcher.html';
45
-        $view = $this->initializeStandaloneView($templateNameAndPath);
46
-        $view->assign('isAdmin', $this->getBackendUser()->isAdmin());
47
-        $view->assign('sitePath', Environment::getPublicPath() . '/');
48
-        return $view->render();
49
-    }
50
-
51
-    /**
52
-     * Do the job: analyse Index.
53
-     *
54
-     * @param array $arguments
55
-     * @return string
56
-     */
57
-    public function work(array $arguments = [])
58
-    {
59
-        // Possible clean up of missing files if the User has clicked so.
60
-        if (!empty($arguments['deleteDuplicateFiles'])) {
61
-            $this->deleteMissingFilesAction($arguments['files']);
62
-        }
63
-
64
-        $templateNameAndPath = 'EXT:media/Resources/Private/Standalone/Tool/DuplicateFilesFinder/WorkResult.html';
65
-        $view = $this->initializeStandaloneView($templateNameAndPath);
66
-
67
-        $duplicateFilesReports = [];
68
-
69
-        if ($this->getBackendUser()->isAdmin()) {
70
-            foreach ($this->getStorageRepository()->findAll() as $storage) {
71
-                if ($storage->isOnline()) {
72
-                    $duplicateFiles = $this->getIndexAnalyser()->searchForDuplicateSha1($storage);
73
-                    $duplicateFilesReports[] = array(
74
-                        'storage' => $storage,
75
-                        'duplicateFiles' => $duplicateFiles,
76
-                        'numberOfDuplicateFiles' => count($duplicateFiles),
77
-                    );
78
-                }
79
-            }
80
-        } else {
81
-            $fileMounts = $this->getBackendUser()->getFileMountRecords();
82
-
83
-            $allowedStorages = [];
84
-            foreach ($fileMounts as $fileMount) {
85
-                if ((bool)$fileMount['read_only']) {
86
-                    continue;
87
-                }
88
-
89
-                if (!isset($allowedStorages[$fileMount['base']])) {
90
-                    $allowedStorages[$fileMount['base']] = [];
91
-                }
92
-                if (!in_array($fileMount['base'], $allowedStorages)) {
93
-                    $allowedStorages[$fileMount['base']][] = $fileMount['path'];
94
-                }
95
-            }
96
-
97
-            foreach ($allowedStorages as $storageIdentifier => $allowedMountPoints) {
98
-                $storage = $this->getResourceFactory()->getStorageObject($storageIdentifier);
99
-
100
-                if ($storage->isOnline()) {
101
-                    $duplicateFiles = $this->getIndexAnalyser()->searchForDuplicateSha1($storage);
102
-
103
-                    // Filter duplicates files
104
-                    foreach ($duplicateFiles as $key => $files) {
105
-                        $filteredFiles = [];
106
-                        foreach ($files as $file) {
107
-                            foreach ($allowedMountPoints as $allowedMountPoint) {
108
-                                $pattern = '%^' . $allowedMountPoint . '%isU';
109
-                                if (preg_match($pattern, $file['identifier'])) {
110
-                                    $filteredFiles[] = $file;
111
-                                    break; // no need to further loop around, stop the loop.
112
-                                }
113
-                            }
114
-                        }
115
-
116
-                        // We need more than 1 files to be shown as duplicate.
117
-                        if (count($filteredFiles) > 1) {
118
-                            $duplicateFiles[$key] = $filteredFiles;
119
-                        } else {
120
-                            unset($duplicateFiles[$key]);
121
-                        }
122
-                    }
123
-                    $duplicateFilesReports[] = array(
124
-                        'storage' => $storage,
125
-                        'duplicateFiles' => $duplicateFiles,
126
-                        'numberOfDuplicateFiles' => count($duplicateFiles),
127
-                    );
128
-                }
129
-            }
130
-        }
131
-
132
-        $view->assign('duplicateFilesReports', $duplicateFilesReports);
133
-
134
-        return $view->render();
135
-    }
136
-
137
-    /**
138
-     * Delete files given as parameter.
139
-     * This is a special case as we have a missing file in the file system
140
-     * As a result, we can't use $fileObject->delete(); which will
141
-     * raise exception "Error while fetching permissions".
142
-     *
143
-     * @param array $files
144
-     * @return void
145
-     */
146
-    protected function deleteMissingFilesAction(array $files = [])
147
-    {
148
-        foreach ($files as $fileUid) {
149
-            /** @var File $file */
150
-            try {
151
-                $file = $this->getResourceFactory()->getFileObject($fileUid);
152
-                if ($file->exists()) {
153
-                    $numberOfReferences = $this->getFileReferenceService()->countTotalReferences($file);
154
-                    if ($numberOfReferences === 0) {
155
-                        $file->delete();
156
-                    }
157
-                } else {
158
-                    $this->getDataService()->delete('sys_file', ['uid' => $file->getUid()]);
159
-                }
160
-            } catch (\Exception $e) {
161
-                continue;
162
-            }
163
-        }
164
-    }
165
-
166
-    /**
167
-     * Return a pointer to the database.
168
-     *
169
-     * @return IndexAnalyser|object
170
-     */
171
-    protected function getIndexAnalyser()
172
-    {
173
-        return GeneralUtility::makeInstance(IndexAnalyser::class);
174
-    }
175
-
176
-    /**
177
-     * @return ThumbnailGenerator|object
178
-     */
179
-    protected function getThumbnailGenerator()
180
-    {
181
-        return GeneralUtility::makeInstance(ThumbnailGenerator::class);
182
-    }
183
-
184
-    /**
185
-     * @return StorageRepository|object
186
-     */
187
-    protected function getStorageRepository()
188
-    {
189
-        return GeneralUtility::makeInstance(StorageRepository::class);
190
-    }
191
-
192
-    /**
193
-     * Tell whether the tools should be displayed according to the context.
194
-     *
195
-     * @return bool
196
-     */
197
-    public function isShown()
198
-    {
199
-        return true;
200
-    }
201
-
202
-    /**
203
-     * @return FileReferenceService|object
204
-     */
205
-    protected function getFileReferenceService()
206
-    {
207
-        return GeneralUtility::makeInstance(FileReferenceService::class);
208
-    }
209
-
210
-    /**
211
-     * @return object|DataService
212
-     */
213
-    protected function getDataService(): DataService
214
-    {
215
-        return GeneralUtility::makeInstance(DataService::class);
216
-    }
217
-
218
-    protected function getResourceFactory(): ResourceFactory
219
-    {
220
-        return GeneralUtility::makeInstance(ResourceFactory::class);
221
-    }
27
+	/**
28
+	 * Display the title of the tool on the welcome screen.
29
+	 *
30
+	 * @return string
31
+	 */
32
+	public function getTitle()
33
+	{
34
+		return 'Find duplicate Files';
35
+	}
36
+
37
+	/**
38
+	 * Display the description of the tool in the welcome screen.
39
+	 *
40
+	 * @return string
41
+	 */
42
+	public function getDescription()
43
+	{
44
+		$templateNameAndPath = 'EXT:media/Resources/Private/Standalone/Tool/DuplicateFilesFinder/Launcher.html';
45
+		$view = $this->initializeStandaloneView($templateNameAndPath);
46
+		$view->assign('isAdmin', $this->getBackendUser()->isAdmin());
47
+		$view->assign('sitePath', Environment::getPublicPath() . '/');
48
+		return $view->render();
49
+	}
50
+
51
+	/**
52
+	 * Do the job: analyse Index.
53
+	 *
54
+	 * @param array $arguments
55
+	 * @return string
56
+	 */
57
+	public function work(array $arguments = [])
58
+	{
59
+		// Possible clean up of missing files if the User has clicked so.
60
+		if (!empty($arguments['deleteDuplicateFiles'])) {
61
+			$this->deleteMissingFilesAction($arguments['files']);
62
+		}
63
+
64
+		$templateNameAndPath = 'EXT:media/Resources/Private/Standalone/Tool/DuplicateFilesFinder/WorkResult.html';
65
+		$view = $this->initializeStandaloneView($templateNameAndPath);
66
+
67
+		$duplicateFilesReports = [];
68
+
69
+		if ($this->getBackendUser()->isAdmin()) {
70
+			foreach ($this->getStorageRepository()->findAll() as $storage) {
71
+				if ($storage->isOnline()) {
72
+					$duplicateFiles = $this->getIndexAnalyser()->searchForDuplicateSha1($storage);
73
+					$duplicateFilesReports[] = array(
74
+						'storage' => $storage,
75
+						'duplicateFiles' => $duplicateFiles,
76
+						'numberOfDuplicateFiles' => count($duplicateFiles),
77
+					);
78
+				}
79
+			}
80
+		} else {
81
+			$fileMounts = $this->getBackendUser()->getFileMountRecords();
82
+
83
+			$allowedStorages = [];
84
+			foreach ($fileMounts as $fileMount) {
85
+				if ((bool)$fileMount['read_only']) {
86
+					continue;
87
+				}
88
+
89
+				if (!isset($allowedStorages[$fileMount['base']])) {
90
+					$allowedStorages[$fileMount['base']] = [];
91
+				}
92
+				if (!in_array($fileMount['base'], $allowedStorages)) {
93
+					$allowedStorages[$fileMount['base']][] = $fileMount['path'];
94
+				}
95
+			}
96
+
97
+			foreach ($allowedStorages as $storageIdentifier => $allowedMountPoints) {
98
+				$storage = $this->getResourceFactory()->getStorageObject($storageIdentifier);
99
+
100
+				if ($storage->isOnline()) {
101
+					$duplicateFiles = $this->getIndexAnalyser()->searchForDuplicateSha1($storage);
102
+
103
+					// Filter duplicates files
104
+					foreach ($duplicateFiles as $key => $files) {
105
+						$filteredFiles = [];
106
+						foreach ($files as $file) {
107
+							foreach ($allowedMountPoints as $allowedMountPoint) {
108
+								$pattern = '%^' . $allowedMountPoint . '%isU';
109
+								if (preg_match($pattern, $file['identifier'])) {
110
+									$filteredFiles[] = $file;
111
+									break; // no need to further loop around, stop the loop.
112
+								}
113
+							}
114
+						}
115
+
116
+						// We need more than 1 files to be shown as duplicate.
117
+						if (count($filteredFiles) > 1) {
118
+							$duplicateFiles[$key] = $filteredFiles;
119
+						} else {
120
+							unset($duplicateFiles[$key]);
121
+						}
122
+					}
123
+					$duplicateFilesReports[] = array(
124
+						'storage' => $storage,
125
+						'duplicateFiles' => $duplicateFiles,
126
+						'numberOfDuplicateFiles' => count($duplicateFiles),
127
+					);
128
+				}
129
+			}
130
+		}
131
+
132
+		$view->assign('duplicateFilesReports', $duplicateFilesReports);
133
+
134
+		return $view->render();
135
+	}
136
+
137
+	/**
138
+	 * Delete files given as parameter.
139
+	 * This is a special case as we have a missing file in the file system
140
+	 * As a result, we can't use $fileObject->delete(); which will
141
+	 * raise exception "Error while fetching permissions".
142
+	 *
143
+	 * @param array $files
144
+	 * @return void
145
+	 */
146
+	protected function deleteMissingFilesAction(array $files = [])
147
+	{
148
+		foreach ($files as $fileUid) {
149
+			/** @var File $file */
150
+			try {
151
+				$file = $this->getResourceFactory()->getFileObject($fileUid);
152
+				if ($file->exists()) {
153
+					$numberOfReferences = $this->getFileReferenceService()->countTotalReferences($file);
154
+					if ($numberOfReferences === 0) {
155
+						$file->delete();
156
+					}
157
+				} else {
158
+					$this->getDataService()->delete('sys_file', ['uid' => $file->getUid()]);
159
+				}
160
+			} catch (\Exception $e) {
161
+				continue;
162
+			}
163
+		}
164
+	}
165
+
166
+	/**
167
+	 * Return a pointer to the database.
168
+	 *
169
+	 * @return IndexAnalyser|object
170
+	 */
171
+	protected function getIndexAnalyser()
172
+	{
173
+		return GeneralUtility::makeInstance(IndexAnalyser::class);
174
+	}
175
+
176
+	/**
177
+	 * @return ThumbnailGenerator|object
178
+	 */
179
+	protected function getThumbnailGenerator()
180
+	{
181
+		return GeneralUtility::makeInstance(ThumbnailGenerator::class);
182
+	}
183
+
184
+	/**
185
+	 * @return StorageRepository|object
186
+	 */
187
+	protected function getStorageRepository()
188
+	{
189
+		return GeneralUtility::makeInstance(StorageRepository::class);
190
+	}
191
+
192
+	/**
193
+	 * Tell whether the tools should be displayed according to the context.
194
+	 *
195
+	 * @return bool
196
+	 */
197
+	public function isShown()
198
+	{
199
+		return true;
200
+	}
201
+
202
+	/**
203
+	 * @return FileReferenceService|object
204
+	 */
205
+	protected function getFileReferenceService()
206
+	{
207
+		return GeneralUtility::makeInstance(FileReferenceService::class);
208
+	}
209
+
210
+	/**
211
+	 * @return object|DataService
212
+	 */
213
+	protected function getDataService(): DataService
214
+	{
215
+		return GeneralUtility::makeInstance(DataService::class);
216
+	}
217
+
218
+	protected function getResourceFactory(): ResourceFactory
219
+	{
220
+		return GeneralUtility::makeInstance(ResourceFactory::class);
221
+	}
222 222
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
         $templateNameAndPath = 'EXT:media/Resources/Private/Standalone/Tool/DuplicateFilesFinder/Launcher.html';
45 45
         $view = $this->initializeStandaloneView($templateNameAndPath);
46 46
         $view->assign('isAdmin', $this->getBackendUser()->isAdmin());
47
-        $view->assign('sitePath', Environment::getPublicPath() . '/');
47
+        $view->assign('sitePath', Environment::getPublicPath().'/');
48 48
         return $view->render();
49 49
     }
50 50
 
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
                         $filteredFiles = [];
106 106
                         foreach ($files as $file) {
107 107
                             foreach ($allowedMountPoints as $allowedMountPoint) {
108
-                                $pattern = '%^' . $allowedMountPoint . '%isU';
108
+                                $pattern = '%^'.$allowedMountPoint.'%isU';
109 109
                                 if (preg_match($pattern, $file['identifier'])) {
110 110
                                     $filteredFiles[] = $file;
111 111
                                     break; // no need to further loop around, stop the loop.
Please login to merge, or discard this patch.
Classes/Tool/CacheWarmUpTool.php 1 patch
Indentation   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -18,70 +18,70 @@
 block discarded – undo
18 18
  */
19 19
 class CacheWarmUpTool extends AbstractTool
20 20
 {
21
-    /**
22
-     * Display the title of the tool on the welcome screen.
23
-     *
24
-     * @return string
25
-     */
26
-    public function getTitle()
27
-    {
28
-        return 'Cache warm up';
29
-    }
21
+	/**
22
+	 * Display the title of the tool on the welcome screen.
23
+	 *
24
+	 * @return string
25
+	 */
26
+	public function getTitle()
27
+	{
28
+		return 'Cache warm up';
29
+	}
30 30
 
31
-    /**
32
-     * Display the description of the tool in the welcome screen.
33
-     *
34
-     * @return string
35
-     */
36
-    public function getDescription()
37
-    {
38
-        $templateNameAndPath = 'EXT:media/Resources/Private/Standalone/Tool/CacheWarmUp/Launcher.html';
39
-        $view = $this->initializeStandaloneView($templateNameAndPath);
40
-        $view->assign('sitePath', Environment::getPublicPath() . '/');
41
-        return $view->render();
42
-    }
31
+	/**
32
+	 * Display the description of the tool in the welcome screen.
33
+	 *
34
+	 * @return string
35
+	 */
36
+	public function getDescription()
37
+	{
38
+		$templateNameAndPath = 'EXT:media/Resources/Private/Standalone/Tool/CacheWarmUp/Launcher.html';
39
+		$view = $this->initializeStandaloneView($templateNameAndPath);
40
+		$view->assign('sitePath', Environment::getPublicPath() . '/');
41
+		return $view->render();
42
+	}
43 43
 
44
-    /**
45
-     * Do the job: warm up the cache.
46
-     *
47
-     * @param array $arguments
48
-     * @return string
49
-     */
50
-    public function work(array $arguments = [])
51
-    {
52
-        $templateNameAndPath = 'EXT:media/Resources/Private/Standalone/Tool/CacheWarmUp/WorkResult.html';
53
-        $view = $this->initializeStandaloneView($templateNameAndPath);
44
+	/**
45
+	 * Do the job: warm up the cache.
46
+	 *
47
+	 * @param array $arguments
48
+	 * @return string
49
+	 */
50
+	public function work(array $arguments = [])
51
+	{
52
+		$templateNameAndPath = 'EXT:media/Resources/Private/Standalone/Tool/CacheWarmUp/WorkResult.html';
53
+		$view = $this->initializeStandaloneView($templateNameAndPath);
54 54
 
55
-        $numberOfEntries = $this->getCacheService()->warmUp();
56
-        $view->assign('numberOfEntries', $numberOfEntries);
57
-        touch($this->getWarmUpSemaphorFile());
55
+		$numberOfEntries = $this->getCacheService()->warmUp();
56
+		$view->assign('numberOfEntries', $numberOfEntries);
57
+		touch($this->getWarmUpSemaphorFile());
58 58
 
59
-        return $view->render();
60
-    }
59
+		return $view->render();
60
+	}
61 61
 
62
-    /**
63
-     * Tell whether the tools should be displayed according to the context.
64
-     *
65
-     * @return bool
66
-     */
67
-    public function isShown()
68
-    {
69
-        return $this->getBackendUser()->isAdmin();
70
-    }
62
+	/**
63
+	 * Tell whether the tools should be displayed according to the context.
64
+	 *
65
+	 * @return bool
66
+	 */
67
+	public function isShown()
68
+	{
69
+		return $this->getBackendUser()->isAdmin();
70
+	}
71 71
 
72
-    /**
73
-     * @return string
74
-     */
75
-    protected function getWarmUpSemaphorFile()
76
-    {
77
-        return Environment::getPublicPath() . '/typo3temp/.media_cache_warmed_up';
78
-    }
72
+	/**
73
+	 * @return string
74
+	 */
75
+	protected function getWarmUpSemaphorFile()
76
+	{
77
+		return Environment::getPublicPath() . '/typo3temp/.media_cache_warmed_up';
78
+	}
79 79
 
80
-    /**
81
-     * @return CacheService|object
82
-     */
83
-    protected function getCacheService()
84
-    {
85
-        return GeneralUtility::makeInstance(CacheService::class);
86
-    }
80
+	/**
81
+	 * @return CacheService|object
82
+	 */
83
+	protected function getCacheService()
84
+	{
85
+		return GeneralUtility::makeInstance(CacheService::class);
86
+	}
87 87
 }
Please login to merge, or discard this patch.
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/Tool/DuplicateRecordsFinderTool.php 1 patch
Indentation   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -19,82 +19,82 @@
 block discarded – undo
19 19
  */
20 20
 class DuplicateRecordsFinderTool 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 'Find duplicate Records';
30
-    }
22
+	/**
23
+	 * Display the title of the tool on the welcome screen.
24
+	 *
25
+	 * @return string
26
+	 */
27
+	public function getTitle()
28
+	{
29
+		return 'Find duplicate Records';
30
+	}
31 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/DuplicateRecordsFinder/Launcher.html';
40
-        $view = $this->initializeStandaloneView($templateNameAndPath);
41
-        $view->assign('sitePath', Environment::getPublicPath() . '/');
42
-        return $view->render();
43
-    }
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/DuplicateRecordsFinder/Launcher.html';
40
+		$view = $this->initializeStandaloneView($templateNameAndPath);
41
+		$view->assign('sitePath', Environment::getPublicPath() . '/');
42
+		return $view->render();
43
+	}
44 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
-        $templateNameAndPath = 'EXT:media/Resources/Private/Standalone/Tool/DuplicateRecordsFinder/WorkResult.html';
54
-        $view = $this->initializeStandaloneView($templateNameAndPath);
45
+	/**
46
+	 * Do the job: analyse Index.
47
+	 *
48
+	 * @param array $arguments
49
+	 * @return string
50
+	 */
51
+	public function work(array $arguments = [])
52
+	{
53
+		$templateNameAndPath = 'EXT:media/Resources/Private/Standalone/Tool/DuplicateRecordsFinder/WorkResult.html';
54
+		$view = $this->initializeStandaloneView($templateNameAndPath);
55 55
 
56
-        $duplicateRecordsReports = [];
57
-        foreach ($this->getStorageRepository()->findAll() as $storage) {
58
-            if ($storage->isOnline()) {
59
-                $duplicateFiles = $this->getIndexAnalyser()->searchForDuplicateIdentifiers($storage);
60
-                $duplicateRecordsReports[] = array(
61
-                    'storage' => $storage,
62
-                    'duplicateFiles' => $duplicateFiles,
63
-                    'numberOfDuplicateFiles' => count($duplicateFiles),
64
-                );
65
-            }
66
-        }
56
+		$duplicateRecordsReports = [];
57
+		foreach ($this->getStorageRepository()->findAll() as $storage) {
58
+			if ($storage->isOnline()) {
59
+				$duplicateFiles = $this->getIndexAnalyser()->searchForDuplicateIdentifiers($storage);
60
+				$duplicateRecordsReports[] = array(
61
+					'storage' => $storage,
62
+					'duplicateFiles' => $duplicateFiles,
63
+					'numberOfDuplicateFiles' => count($duplicateFiles),
64
+				);
65
+			}
66
+		}
67 67
 
68
-        $view->assign('duplicateRecordsReports', $duplicateRecordsReports);
68
+		$view->assign('duplicateRecordsReports', $duplicateRecordsReports);
69 69
 
70
-        return $view->render();
71
-    }
70
+		return $view->render();
71
+	}
72 72
 
73
-    /**
74
-     * Return a pointer to the database.
75
-     *
76
-     * @return IndexAnalyser|object
77
-     */
78
-    protected function getIndexAnalyser()
79
-    {
80
-        return GeneralUtility::makeInstance(IndexAnalyser::class);
81
-    }
73
+	/**
74
+	 * Return a pointer to the database.
75
+	 *
76
+	 * @return IndexAnalyser|object
77
+	 */
78
+	protected function getIndexAnalyser()
79
+	{
80
+		return GeneralUtility::makeInstance(IndexAnalyser::class);
81
+	}
82 82
 
83
-    /**
84
-     * @return StorageRepository|object
85
-     */
86
-    protected function getStorageRepository()
87
-    {
88
-        return GeneralUtility::makeInstance(StorageRepository::class);
89
-    }
83
+	/**
84
+	 * @return StorageRepository|object
85
+	 */
86
+	protected function getStorageRepository()
87
+	{
88
+		return GeneralUtility::makeInstance(StorageRepository::class);
89
+	}
90 90
 
91
-    /**
92
-     * Tell whether the tools should be displayed according to the context.
93
-     *
94
-     * @return bool
95
-     */
96
-    public function isShown()
97
-    {
98
-        return $this->getBackendUser()->isAdmin();
99
-    }
91
+	/**
92
+	 * Tell whether the tools should be displayed according to the context.
93
+	 *
94
+	 * @return bool
95
+	 */
96
+	public function isShown()
97
+	{
98
+		return $this->getBackendUser()->isAdmin();
99
+	}
100 100
 }
Please login to merge, or discard this patch.
Classes/Tool/MissingFilesFinderTool.php 1 patch
Indentation   +124 added lines, -124 removed lines patch added patch discarded remove patch
@@ -22,128 +22,128 @@
 block discarded – undo
22 22
  */
23 23
 class MissingFilesFinderTool extends AbstractTool
24 24
 {
25
-    /**
26
-     * Display the title of the tool on the welcome screen.
27
-     *
28
-     * @return string
29
-     */
30
-    public function getTitle()
31
-    {
32
-        return 'Find missing files';
33
-    }
34
-
35
-    /**
36
-     * Display the description of the tool in the welcome screen.
37
-     *
38
-     * @return string
39
-     */
40
-    public function getDescription()
41
-    {
42
-        $templateNameAndPath = 'EXT:media/Resources/Private/Standalone/Tool/MissingFilesFinder/Launcher.html';
43
-        $view = $this->initializeStandaloneView($templateNameAndPath);
44
-        $view->assign('sitePath', Environment::getPublicPath() . '/');
45
-        return $view->render();
46
-    }
47
-
48
-    /**
49
-     * Do the job: analyse Index.
50
-     *
51
-     * @param array $arguments
52
-     * @return string
53
-     */
54
-    public function work(array $arguments = [])
55
-    {
56
-        // Possible clean up of missing files if the User has clicked so.
57
-        if (!empty($arguments['deleteMissingFiles'])) {
58
-            $this->deleteMissingFilesAction($arguments['files']);
59
-        }
60
-
61
-        $templateNameAndPath = 'EXT:media/Resources/Private/Standalone/Tool/MissingFilesFinder/WorkResult.html';
62
-        $view = $this->initializeStandaloneView($templateNameAndPath);
63
-
64
-        $missingReports = [];
65
-        foreach ($this->getStorageRepository()->findAll() as $storage) {
66
-            if ($storage->isOnline()) {
67
-                $missingFiles = $this->getIndexAnalyser()->searchForMissingFiles($storage);
68
-
69
-                $missingReports[] = array(
70
-                    'storage' => $storage,
71
-                    'missingFiles' => $missingFiles,
72
-                    'numberOfMissingFiles' => count($missingFiles),
73
-                );
74
-            }
75
-        }
76
-
77
-        $view->assign('missingReports', $missingReports);
78
-
79
-        return $view->render();
80
-    }
81
-
82
-    /**
83
-     * Delete files given as parameter.
84
-     * This is a special case as we have a missing file in the file system
85
-     * As a result, we can't use $fileObject->delete(); which will
86
-     * raise exception "Error while fetching permissions".
87
-     *
88
-     * @param array $files
89
-     * @return void
90
-     */
91
-    protected function deleteMissingFilesAction(array $files = [])
92
-    {
93
-        foreach ($files as $fileUid) {
94
-            /** @var File $file */
95
-            try {
96
-                $file = $this->getResourceFactory()->getFileObject($fileUid);
97
-                if ($file) {
98
-                    // The case is special as we have a missing file in the file system
99
-                    // As a result, we can't use $fileObject->delete(); which will
100
-                    // raise exception "Error while fetching permissions"
101
-                    $this->getDataService()->delete('sys_file', ['uid' => $file->getUid()]);
102
-                }
103
-            } catch (\Exception $e) {
104
-                continue;
105
-            }
106
-        }
107
-    }
108
-
109
-    /**
110
-     * Return a pointer to the database.
111
-     *
112
-     * @return IndexAnalyser|object
113
-     */
114
-    protected function getIndexAnalyser()
115
-    {
116
-        return GeneralUtility::makeInstance(IndexAnalyser::class);
117
-    }
118
-
119
-    /**
120
-     * @return StorageRepository|object
121
-     */
122
-    protected function getStorageRepository()
123
-    {
124
-        return GeneralUtility::makeInstance(StorageRepository::class);
125
-    }
126
-
127
-    /**
128
-     * Tell whether the tools should be displayed according to the context.
129
-     *
130
-     * @return bool
131
-     */
132
-    public function isShown()
133
-    {
134
-        return $this->getBackendUser()->isAdmin();
135
-    }
136
-
137
-    /**
138
-     * @return object|DataService
139
-     */
140
-    protected function getDataService(): DataService
141
-    {
142
-        return GeneralUtility::makeInstance(DataService::class);
143
-    }
144
-
145
-    protected function getResourceFactory(): ResourceFactory
146
-    {
147
-        return GeneralUtility::makeInstance(ResourceFactory::class);
148
-    }
25
+	/**
26
+	 * Display the title of the tool on the welcome screen.
27
+	 *
28
+	 * @return string
29
+	 */
30
+	public function getTitle()
31
+	{
32
+		return 'Find missing files';
33
+	}
34
+
35
+	/**
36
+	 * Display the description of the tool in the welcome screen.
37
+	 *
38
+	 * @return string
39
+	 */
40
+	public function getDescription()
41
+	{
42
+		$templateNameAndPath = 'EXT:media/Resources/Private/Standalone/Tool/MissingFilesFinder/Launcher.html';
43
+		$view = $this->initializeStandaloneView($templateNameAndPath);
44
+		$view->assign('sitePath', Environment::getPublicPath() . '/');
45
+		return $view->render();
46
+	}
47
+
48
+	/**
49
+	 * Do the job: analyse Index.
50
+	 *
51
+	 * @param array $arguments
52
+	 * @return string
53
+	 */
54
+	public function work(array $arguments = [])
55
+	{
56
+		// Possible clean up of missing files if the User has clicked so.
57
+		if (!empty($arguments['deleteMissingFiles'])) {
58
+			$this->deleteMissingFilesAction($arguments['files']);
59
+		}
60
+
61
+		$templateNameAndPath = 'EXT:media/Resources/Private/Standalone/Tool/MissingFilesFinder/WorkResult.html';
62
+		$view = $this->initializeStandaloneView($templateNameAndPath);
63
+
64
+		$missingReports = [];
65
+		foreach ($this->getStorageRepository()->findAll() as $storage) {
66
+			if ($storage->isOnline()) {
67
+				$missingFiles = $this->getIndexAnalyser()->searchForMissingFiles($storage);
68
+
69
+				$missingReports[] = array(
70
+					'storage' => $storage,
71
+					'missingFiles' => $missingFiles,
72
+					'numberOfMissingFiles' => count($missingFiles),
73
+				);
74
+			}
75
+		}
76
+
77
+		$view->assign('missingReports', $missingReports);
78
+
79
+		return $view->render();
80
+	}
81
+
82
+	/**
83
+	 * Delete files given as parameter.
84
+	 * This is a special case as we have a missing file in the file system
85
+	 * As a result, we can't use $fileObject->delete(); which will
86
+	 * raise exception "Error while fetching permissions".
87
+	 *
88
+	 * @param array $files
89
+	 * @return void
90
+	 */
91
+	protected function deleteMissingFilesAction(array $files = [])
92
+	{
93
+		foreach ($files as $fileUid) {
94
+			/** @var File $file */
95
+			try {
96
+				$file = $this->getResourceFactory()->getFileObject($fileUid);
97
+				if ($file) {
98
+					// The case is special as we have a missing file in the file system
99
+					// As a result, we can't use $fileObject->delete(); which will
100
+					// raise exception "Error while fetching permissions"
101
+					$this->getDataService()->delete('sys_file', ['uid' => $file->getUid()]);
102
+				}
103
+			} catch (\Exception $e) {
104
+				continue;
105
+			}
106
+		}
107
+	}
108
+
109
+	/**
110
+	 * Return a pointer to the database.
111
+	 *
112
+	 * @return IndexAnalyser|object
113
+	 */
114
+	protected function getIndexAnalyser()
115
+	{
116
+		return GeneralUtility::makeInstance(IndexAnalyser::class);
117
+	}
118
+
119
+	/**
120
+	 * @return StorageRepository|object
121
+	 */
122
+	protected function getStorageRepository()
123
+	{
124
+		return GeneralUtility::makeInstance(StorageRepository::class);
125
+	}
126
+
127
+	/**
128
+	 * Tell whether the tools should be displayed according to the context.
129
+	 *
130
+	 * @return bool
131
+	 */
132
+	public function isShown()
133
+	{
134
+		return $this->getBackendUser()->isAdmin();
135
+	}
136
+
137
+	/**
138
+	 * @return object|DataService
139
+	 */
140
+	protected function getDataService(): DataService
141
+	{
142
+		return GeneralUtility::makeInstance(DataService::class);
143
+	}
144
+
145
+	protected function getResourceFactory(): ResourceFactory
146
+	{
147
+		return GeneralUtility::makeInstance(ResourceFactory::class);
148
+	}
149 149
 }
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.