[FEATURE] Add symfony dependency injection for core and extbase
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / Classes / Controller / MaintenanceController.php
index 5ad4da1..25032a6 100644 (file)
@@ -40,6 +40,7 @@ use TYPO3\CMS\Install\Service\Typo3tempFileService;
 
 /**
  * Maintenance controller
+ * @internal This class is a specific controller implementation and is not considered part of the Public TYPO3 API.
  */
 class MaintenanceController extends AbstractController
 {
@@ -94,6 +95,12 @@ class MaintenanceController extends AbstractController
                 'success' => true,
                 'stats' => (new Typo3tempFileService())->getDirectoryStatistics(),
                 'html' => $view->render(),
+                'buttons' => [
+                    [
+                        'btnClass' => 'btn-default t3js-clearTypo3temp-stats',
+                        'text' => 'Scan again',
+                    ],
+                ],
             ]
         );
     }
@@ -160,24 +167,46 @@ class MaintenanceController extends AbstractController
     }
 
     /**
-     * Analyze current database situation
+     * Get main database analyzer modal HTML
      *
      * @param ServerRequestInterface $request
      * @return ResponseInterface
      */
-    public function databaseAnalyzerAnalyzeAction(ServerRequestInterface $request): ResponseInterface
+    public function databaseAnalyzerAction(ServerRequestInterface $request): ResponseInterface
     {
         $view = $this->initializeStandaloneView($request, 'Maintenance/DatabaseAnalyzer.html');
         $formProtection = FormProtectionFactory::get(InstallToolFormProtection::class);
         $view->assignMultiple([
             'databaseAnalyzerExecuteToken' => $formProtection->generateToken('installTool', 'databaseAnalyzerExecute'),
         ]);
-        $this->loadExtLocalconfDatabaseAndExtTables();
-        $messageQueue = new FlashMessageQueue('install');
+        return new JsonResponse([
+            'success' => true,
+            'html' => $view->render(),
+            'buttons' => [
+                [
+                    'btnClass' => 'btn-default t3js-databaseAnalyzer-analyze',
+                    'text' => 'Run database compare again',
+                ], [
+                    'btnClass' => 'btn-warning t3js-databaseAnalyzer-execute',
+                    'text' => 'Apply selected changes',
+                ],
+            ],
+        ]);
+    }
 
+    /**
+     * Analyze current database situation
+     *
+     * @param ServerRequestInterface $request
+     * @return ResponseInterface
+     */
+    public function databaseAnalyzerAnalyzeAction(ServerRequestInterface $request): ResponseInterface
+    {
+        $container = $this->loadExtLocalconfDatabaseAndExtTables();
+        $messageQueue = new FlashMessageQueue('install');
         $suggestions = [];
         try {
-            $sqlReader = GeneralUtility::makeInstance(SqlReader::class);
+            $sqlReader = $container->get(SqlReader::class);
             $sqlStatements = $sqlReader->getCreateTableStatementArray($sqlReader->getTablesDefinitionString());
             $schemaMigrationService = GeneralUtility::makeInstance(SchemaMigrator::class);
             $addCreateChange = $schemaMigrationService->getUpdateSuggestions($sqlStatements);
@@ -307,11 +336,6 @@ class MaintenanceController extends AbstractController
                 }
                 $suggestions[] = $suggestion;
             }
-
-            $messageQueue->enqueue(new FlashMessage(
-                '',
-                'Analyzed current database'
-            ));
         } catch (StatementException $e) {
             $messageQueue->enqueue(new FlashMessage(
                 $e->getMessage(),
@@ -323,7 +347,6 @@ class MaintenanceController extends AbstractController
             'success' => true,
             'status' => $messageQueue,
             'suggestions' => $suggestions,
-            'html' => $view->render(),
         ]);
     }
 
@@ -335,7 +358,7 @@ class MaintenanceController extends AbstractController
      */
     public function databaseAnalyzerExecuteAction(ServerRequestInterface $request): ResponseInterface
     {
-        $this->loadExtLocalconfDatabaseAndExtTables();
+        $container = $this->loadExtLocalconfDatabaseAndExtTables();
         $messageQueue = new FlashMessageQueue('install');
         $selectedHashes = $request->getParsedBody()['install']['hashes'] ?? [];
         if (empty($selectedHashes)) {
@@ -345,7 +368,7 @@ class MaintenanceController extends AbstractController
                 FlashMessage::WARNING
             ));
         } else {
-            $sqlReader = GeneralUtility::makeInstance(SqlReader::class);
+            $sqlReader = $container->get(SqlReader::class);
             $sqlStatements = $sqlReader->getCreateTableStatementArray($sqlReader->getTablesDefinitionString());
             $schemaMigrationService = GeneralUtility::makeInstance(SchemaMigrator::class);
             $statementHashesToPerform = array_flip($selectedHashes);
@@ -386,6 +409,12 @@ class MaintenanceController extends AbstractController
             'success' => true,
             'stats' => (new ClearTableService())->getTableStatistics(),
             'html' => $view->render(),
+            'buttons' => [
+                [
+                    'btnClass' => 'btn-default t3js-clearTables-stats',
+                    'text' => 'Scan again',
+                ],
+            ],
         ]);
     }
 
@@ -430,6 +459,12 @@ class MaintenanceController extends AbstractController
         return new JsonResponse([
             'success' => true,
             'html' => $view->render(),
+            'buttons' => [
+                [
+                    'btnClass' => 'btn-default t3js-createAdmin-create',
+                    'text' => 'Create administrator user',
+                ],
+            ],
         ]);
     }
 
@@ -749,8 +784,8 @@ class MaintenanceController extends AbstractController
             ->execute();
         $messageQueue = new FlashMessageQueue('install');
         $messageQueue->enqueue(new FlashMessage(
-            'All backend users preferences has been reseted',
-            'Reset all backend users preferences'
+            'Preferences of all backend users have been reset',
+            'Reset preferences of all backend users'
         ));
         return new JsonResponse([
             'success' => true,