|
|
@@ -4,46 +4,80 @@ declare(strict_types=1);
|
|
|
|
|
|
namespace Meramo\Begriffmgt\Controller;
|
|
|
|
|
|
+use Meramo\Begriffmgt\Domain\Repository\TypeRepository;
|
|
|
+use Meramo\Begriffmgt\Domain\Repository\UrlRepository;
|
|
|
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
|
|
|
use Meramo\Begriffmgt\Domain\Repository\TermRepository;
|
|
|
-use TYPO3\CMS\Extbase\Persistence\QueryInterface;
|
|
|
-use TYPO3\CMS\Extbase\Utility\DebuggerUtility;
|
|
|
-use Meramo\Begriffmgt\Domain\Model\Term;
|
|
|
+use Meramo\Begriffmgt\Domain\Repository\CategoryRepository;
|
|
|
|
|
|
-
|
|
|
-/**
|
|
|
- * Determines what happens when the Module Buttom/Link is clicked
|
|
|
- */
|
|
|
class DashboardController extends ActionController
|
|
|
{
|
|
|
- /**
|
|
|
- * @var TermRepository $termRepository
|
|
|
- */
|
|
|
- protected $termRepository;
|
|
|
-
|
|
|
- /**
|
|
|
- * Set Sort order of Data in List Module
|
|
|
- */
|
|
|
- protected $defaultOrderings = ['uid' => QueryInterface::ORDER_ASCENDING];
|
|
|
-
|
|
|
- /**
|
|
|
- * @param TermRepository $termRepository
|
|
|
- */
|
|
|
- public function injectTermRepository(TermRepository $termRepository): void
|
|
|
- {
|
|
|
- $this->termRepository = $termRepository;
|
|
|
- }
|
|
|
-
|
|
|
- public function indexAction()
|
|
|
- {
|
|
|
-
|
|
|
- $terms = $this->termRepository->findAll();
|
|
|
- // DebuggerUtility::var_dump($terms);
|
|
|
- $query = $terms->getQuery();
|
|
|
- // DebuggerUtility::var_dump($query);
|
|
|
- $query->setOrderings(['uid' => QueryInterface::ORDER_ASCENDING]);
|
|
|
-
|
|
|
- $this->view->assign('terms', $query->execute());
|
|
|
-
|
|
|
- }
|
|
|
+ protected $termRepository;
|
|
|
+ protected $termController;
|
|
|
+ protected $categoryRepository;
|
|
|
+ protected $categoryController;
|
|
|
+ protected $typeRepository;
|
|
|
+ protected $typeController;
|
|
|
+ protected $urlRepository;
|
|
|
+ protected $urlController;
|
|
|
+
|
|
|
+ public function __construct(
|
|
|
+ TermRepository $termRepository,
|
|
|
+ CategoryRepository $categoryRepository,
|
|
|
+ CategoryController $categoryController,
|
|
|
+ TypeRepository $typeRepository,
|
|
|
+ TypeController $typeController,
|
|
|
+ UrlRepository $urlRepository,
|
|
|
+ UrlController $urlController,
|
|
|
+ TermController $termController
|
|
|
+ ) {
|
|
|
+ $this->termRepository = $termRepository;
|
|
|
+ $this->categoryRepository = $categoryRepository;
|
|
|
+ $this->categoryController = $categoryController;
|
|
|
+ $this->termController = $termController;
|
|
|
+ $this->typeRepository = $typeRepository;
|
|
|
+ $this->typeController = $typeController;
|
|
|
+ $this->urlRepository = $urlRepository;
|
|
|
+ $this->urlController = $urlController;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function indexAction(): void
|
|
|
+ {
|
|
|
+ $terms = $this->termRepository->findAllOrderedByTerm();
|
|
|
+ $categories = $this->categoryRepository->findAll();
|
|
|
+ $types = $this->typeRepository->findAll();
|
|
|
+ $urls = $this->urlRepository->findAll();
|
|
|
+ $this->view->assignMultiple([
|
|
|
+ 'terms' => $terms,
|
|
|
+ 'categories' => $categories,
|
|
|
+ 'types' => $types,
|
|
|
+ 'urls' => $urls
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function newAction(): void {
|
|
|
+ }
|
|
|
+
|
|
|
+ public function listAction(): void {
|
|
|
+ $terms = $this->termRepository->findAll();
|
|
|
+ $this->view->assign('terms', $terms);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function createAction(string $termList, string $categoryTitle, string $typeTitle, string $urlTitle): void {
|
|
|
+ $terms = array_map('trim', explode(';', $termList));
|
|
|
+ $category = $this->categoryController->createAction($categoryTitle);
|
|
|
+ $categoryObj = $this->categoryRepository->findByUid($category);
|
|
|
+ $type = $this->typeController->createAction($typeTitle);
|
|
|
+ $typeObj = $this->typeRepository->findByUid($type);
|
|
|
+ $url = $this->urlController->createAction($urlTitle);
|
|
|
+ $urlObj = $this->urlRepository->findByUid($url);
|
|
|
+ $this->termController->createAction($terms, $categoryObj, $typeObj, $urlObj);
|
|
|
+ $this->redirect('index');
|
|
|
+ }
|
|
|
+
|
|
|
+ public function deleteTermAction(int $termId): void {
|
|
|
+ $this->termController->deleteAction($termId);
|
|
|
+ $this->redirect('index');
|
|
|
+ }
|
|
|
+
|
|
|
}
|