termRepository = $termRepository; $this->categoryRepository = $categoryRepository; } public function indexAction(): void { $terms = $this->termRepository->findAll(); $categories = $this->categoryRepository->findAll(); $this->view->assignMultiple([ 'terms' => $terms, 'categories' => $categories, ]); } public function newAction(): void { } public function listAction(): void { $terms = $this->termRepository->findAll(); $this->view->assign('terms', $terms); } public function createAction(string $termList, string $categoryTitle): void { $terms = array_map('trim', explode(',', $termList)); $category = $this->createCategoryAction($categoryTitle); $categoryObj = $this->categoryRepository->findByUid($category); foreach ($terms as $term) { $termObj = new Term(); $termObj->setTerm($term); $termObj->setCategory($categoryObj); $this->termRepository->add($termObj); } $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(); } }