DashboardController.php 2.9 KB

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