termRepository = $termRepository; } public function createAction($terms, $categoryObj, $typeObj, $urlObj): void { $objectManager = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager'); $flashMessageService = $objectManager->get('TYPO3\\CMS\\Core\\Messaging\\FlashMessageService'); $messageQueue = $flashMessageService->getMessageQueueByIdentifier('begriffmgt'); foreach ($terms as $term) { if($term !== '' && !($this->termRepository->findByTitle($term))) { $termObj = new Term(); $termObj->setTerm($term); $termObj->setCategory($categoryObj); $termObj->setType($typeObj); $termObj->setUrl($urlObj); $this->termRepository->add($termObj); } elseif ($term !== '' && $this->termRepository->findByTitle($term)) { $termObj = $this->termRepository->findByUid(($this->termRepository->findByTitle($term))['uid']); $termObj->setCategory($categoryObj); $termObj->setType($typeObj); $termObj->setUrl($urlObj); $this->termRepository->update($termObj); $flashMessage = GeneralUtility::makeInstance( FlashMessage::class, 'Begriff ' . $term . ' wurde aktualisiert. Begriff war bereits vorhanden. Bitte Liste prüfen!', 'Update', // the header of the flash message FlashMessage::OK, // the severity of the flash message TRUE // whether the flash message should be stored in the session (to survive redirects) ); $messageQueue->addMessage($flashMessage); } } } public function deleteAction(int $termId): void { $term = $this->termRepository->findByUid($termId); if ($term) { $this->termRepository->remove($term); } } }