[CLEANUP] Code cleanup in ext:reports
[Packages/TYPO3.CMS.git] / typo3 / sysext / reports / Classes / Report / Status / FalStatus.php
index 86610d2..6d6344d 100644 (file)
@@ -14,12 +14,17 @@ namespace TYPO3\CMS\Reports\Report\Status;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Database\DatabaseConnection;
+use TYPO3\CMS\Core\Resource\StorageRepository;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Lang\LanguageService;
+use TYPO3\CMS\Reports\Status;
+use TYPO3\CMS\Reports\StatusProviderInterface;
 
 /**
  * Performs several checks about the FAL status
  */
-class FalStatus implements \TYPO3\CMS\Reports\StatusProviderInterface
+class FalStatus implements StatusProviderInterface
 {
     /**
      * Determines the status of the FAL index.
@@ -41,18 +46,18 @@ class FalStatus implements \TYPO3\CMS\Reports\StatusProviderInterface
      */
     protected function getMissingFilesStatus()
     {
-        $value = $GLOBALS['LANG']->getLL('status_none');
+        $value = $this->getLanguageService()->getLL('status_none');
         $count = 0;
         $maxFilesToShow = 100;
         $message = '';
-        $severity = \TYPO3\CMS\Reports\Status::OK;
+        $severity = Status::OK;
 
-        /** @var $storageRepository \TYPO3\CMS\Core\Resource\StorageRepository */
-        $storageRepository = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Resource\StorageRepository::class);
+        /** @var StorageRepository $storageRepository */
+        $storageRepository = GeneralUtility::makeInstance(StorageRepository::class);
         $storageObjects = $storageRepository->findAll();
         $storages = array();
 
-        /** @var $storageObject \TYPO3\CMS\Core\Resource\ResourceStorage */
+        /** @var \TYPO3\CMS\Core\Resource\ResourceStorage $storageObject */
         foreach ($storageObjects as $storageObject) {
 
             // We only check missing files for storages that are online
@@ -62,7 +67,7 @@ class FalStatus implements \TYPO3\CMS\Reports\StatusProviderInterface
         }
 
         if (!empty($storages)) {
-            $count = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows(
+            $count = $this->getDatabaseConnection()->exec_SELECTcountRows(
                 '*',
                 'sys_file',
                 'missing=1 AND storage IN (' . implode(',', array_keys($storages)) . ')'
@@ -70,10 +75,10 @@ class FalStatus implements \TYPO3\CMS\Reports\StatusProviderInterface
         }
 
         if ($count) {
-            $value = sprintf($GLOBALS['LANG']->getLL('status_missingFilesCount'), $count);
-            $severity = \TYPO3\CMS\Reports\Status::WARNING;
+            $value = sprintf($this->getLanguageService()->getLL('status_missingFilesCount'), $count);
+            $severity = Status::WARNING;
 
-            $files = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
+            $files = $this->getDatabaseConnection()->exec_SELECTgetRows(
                 'identifier,storage',
                 'sys_file',
                 'missing=1 AND storage IN (' . implode(',', array_keys($storages)) . ')',
@@ -82,7 +87,7 @@ class FalStatus implements \TYPO3\CMS\Reports\StatusProviderInterface
                 $maxFilesToShow
             );
 
-            $message = '<p>' . $GLOBALS['LANG']->getLL('status_missingFilesMessage') . '</p>';
+            $message = '<p>' . $this->getLanguageService()->getLL('status_missingFilesMessage') . '</p>';
             foreach ($files as $file) {
                 $message .= $storages[$file['storage']]->getName() . ' ' . $file['identifier'] . '<br />';
             }
@@ -92,6 +97,22 @@ class FalStatus implements \TYPO3\CMS\Reports\StatusProviderInterface
             }
         }
 
-        return GeneralUtility::makeInstance(\TYPO3\CMS\Reports\Status::class, $GLOBALS['LANG']->getLL('status_missingFiles'), $value, $message, $severity);
+        return GeneralUtility::makeInstance(Status::class, $this->getLanguageService()->getLL('status_missingFiles'), $value, $message, $severity);
+    }
+
+    /**
+     * @return LanguageService
+     */
+    protected function getLanguageService()
+    {
+        return $GLOBALS['LANG'];
+    }
+
+    /**
+     * @return DatabaseConnection
+     */
+    protected function getDatabaseConnection()
+    {
+        return $GLOBALS['TYPO3_DB'];
     }
 }