|
|
@@ -4,23 +4,34 @@ declare(strict_types=1);
|
|
|
|
|
|
namespace Meramo\Begriffmgt\Controller;
|
|
|
|
|
|
-
|
|
|
-use Meramo\Begriffmgt\Domain\Model\Category;
|
|
|
+use Meramo\Begriffmgt\Domain\Repository\TypeRepository;
|
|
|
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
|
|
|
use Meramo\Begriffmgt\Domain\Repository\TermRepository;
|
|
|
-use Meramo\Begriffmgt\Domain\Model\Term;
|
|
|
use Meramo\Begriffmgt\Domain\Repository\CategoryRepository;
|
|
|
-use TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager;
|
|
|
-
|
|
|
|
|
|
class DashboardController extends ActionController
|
|
|
{
|
|
|
protected $termRepository;
|
|
|
+ protected $termController;
|
|
|
protected $categoryRepository;
|
|
|
+ protected $categoryController;
|
|
|
+ protected $typeRepository;
|
|
|
+ protected $typeController;
|
|
|
|
|
|
- public function __construct(TermRepository $termRepository, CategoryRepository $categoryRepository) {
|
|
|
+ public function __construct(
|
|
|
+ TermRepository $termRepository,
|
|
|
+ CategoryRepository $categoryRepository,
|
|
|
+ CategoryController $categoryController,
|
|
|
+ TypeRepository $typeRepository,
|
|
|
+ TypeController $typeController,
|
|
|
+ TermController $termController
|
|
|
+ ) {
|
|
|
$this->termRepository = $termRepository;
|
|
|
$this->categoryRepository = $categoryRepository;
|
|
|
+ $this->categoryController = $categoryController;
|
|
|
+ $this->termController = $termController;
|
|
|
+ $this->typeRepository = $typeRepository;
|
|
|
+ $this->typeController = $typeController;
|
|
|
}
|
|
|
|
|
|
public function indexAction(): void
|
|
|
@@ -41,26 +52,13 @@ class DashboardController extends ActionController
|
|
|
$this->view->assign('terms', $terms);
|
|
|
}
|
|
|
|
|
|
- public function createAction(string $termList, string $categoryTitle): void {
|
|
|
+ public function createAction(string $termList, string $categoryTitle, string $typeTitle): void {
|
|
|
$terms = array_map('trim', explode(',', $termList));
|
|
|
- $category = $this->createCategoryAction($categoryTitle);
|
|
|
-
|
|
|
+ $category = $this->categoryController->createAction($categoryTitle);
|
|
|
$categoryObj = $this->categoryRepository->findByUid($category);
|
|
|
- foreach ($terms as $term) {
|
|
|
- $termObj = new Term();
|
|
|
- $termObj->setTerm($term);
|
|
|
- $termObj->setCategory($categoryObj);
|
|
|
- $this->termRepository->add($termObj);
|
|
|
- }
|
|
|
+ $type = $this->typeController->createAction($typeTitle);
|
|
|
+ $typeObj = $this->typeRepository->findByUid($type);
|
|
|
+ $this->termController->createAction($terms, $categoryObj, $typeObj);
|
|
|
$this->redirect('index');
|
|
|
}
|
|
|
-
|
|
|
- public function createCategoryAction(string $title) {
|
|
|
- $category = new Category();
|
|
|
- $category->setTitle($title);
|
|
|
- $this->categoryRepository->add($category);
|
|
|
- $this->objectManager->get(PersistenceManager::class)->persistAll();
|
|
|
- return $category->getUid();
|
|
|
- }
|
|
|
-
|
|
|
}
|