DashboardController.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. declare(strict_types=1);
  3. namespace Meramo\Begriffmgt\Controller;
  4. use Meramo\Begriffmgt\Domain\Repository\TypeRepository;
  5. use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
  6. use Meramo\Begriffmgt\Domain\Repository\TermRepository;
  7. use Meramo\Begriffmgt\Domain\Repository\CategoryRepository;
  8. class DashboardController extends ActionController
  9. {
  10. protected $termRepository;
  11. protected $termController;
  12. protected $categoryRepository;
  13. protected $categoryController;
  14. protected $typeRepository;
  15. protected $typeController;
  16. public function __construct(
  17. TermRepository $termRepository,
  18. CategoryRepository $categoryRepository,
  19. CategoryController $categoryController,
  20. TypeRepository $typeRepository,
  21. TypeController $typeController,
  22. TermController $termController
  23. ) {
  24. $this->termRepository = $termRepository;
  25. $this->categoryRepository = $categoryRepository;
  26. $this->categoryController = $categoryController;
  27. $this->termController = $termController;
  28. $this->typeRepository = $typeRepository;
  29. $this->typeController = $typeController;
  30. }
  31. public function indexAction(): void
  32. {
  33. $terms = $this->termRepository->findAll();
  34. $categories = $this->categoryRepository->findAll();
  35. $this->view->assignMultiple([
  36. 'terms' => $terms,
  37. 'categories' => $categories,
  38. ]);
  39. }
  40. public function newAction(): void {
  41. }
  42. public function listAction(): void {
  43. $terms = $this->termRepository->findAll();
  44. $this->view->assign('terms', $terms);
  45. }
  46. public function createAction(string $termList, string $categoryTitle, string $typeTitle): void {
  47. $terms = array_map('trim', explode(',', $termList));
  48. $category = $this->categoryController->createAction($categoryTitle);
  49. $categoryObj = $this->categoryRepository->findByUid($category);
  50. $type = $this->typeController->createAction($typeTitle);
  51. $typeObj = $this->typeRepository->findByUid($type);
  52. $this->termController->createAction($terms, $categoryObj, $typeObj);
  53. $this->redirect('index');
  54. }
  55. }