Jelajahi Sumber

Merge branch 'develop'

* develop:
  add dependency injection config
  add distinction whether called by a controller or a form
  Readme text deleted
  contents of README.md updated
ksieren 2 tahun lalu
induk
melakukan
82f6b25aa0
2 mengubah file dengan 43 tambahan dan 1 penghapusan
  1. 11 1
      Classes/Controller/DashboardController.php
  2. 32 0
      Configuration/Services.yaml

+ 11 - 1
Classes/Controller/DashboardController.php

@@ -9,6 +9,7 @@ use Meramo\Begriffmgt\Domain\Repository\UrlRepository;
 use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
 use Meramo\Begriffmgt\Domain\Repository\TermRepository;
 use Meramo\Begriffmgt\Domain\Repository\CategoryRepository;
+use TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager;
 
 class DashboardController extends ActionController
 {
@@ -72,7 +73,16 @@ class DashboardController extends ActionController
         $url = $this->urlController->createAction($urlTitle);
         $urlObj = $this->urlRepository->findByUid($url);
         $this->termController->createAction($terms, $categoryObj, $typeObj, $urlObj);
-        $this->redirect('index');
+
+        $request = $this->request;
+        if ($request) {
+            // Called by a form action - in this case the data is persisted to the db 'automatically'
+            $this->redirect('index');
+        } else {
+            // Called by another controller
+            $persistenceManager = $this->objectManager->get(PersistenceManager::class);
+            $persistenceManager->persistAll();
+        }
     }
 
     public function deleteTermAction(int $termId): void {

+ 32 - 0
Configuration/Services.yaml

@@ -0,0 +1,32 @@
+services:
+  _defaults:
+    autowire: true
+    autoconfigure: true
+    public: false
+
+  Meramo\Begriffmgt\Controller\DashboardController:
+    public: true
+
+  Meramo\Begriffmgt\Controller\TermController:
+    public: true
+
+  Meramo\Begriffmgt\Controller\CategoryController:
+    public: true
+
+  Meramo\Begriffmgt\Controller\TypeController:
+    public: true
+
+  Meramo\Begriffmgt\Controller\UrlController:
+    public: true
+
+  Meramo\Begriffmgt\Domain\Repository\TermRepository:
+    public: true
+
+  Meramo\Begriffmgt\Domain\Repository\TypeRepository:
+    public: true
+
+  Meramo\Begriffmgt\Domain\Repository\CategoryRepository:
+    public: true
+
+  Meramo\Begriffmgt\Domain\Repository\UrlRepository:
+    public: true