|
|
@@ -0,0 +1,36 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace Meramo\Speedbase\Hooks;
|
|
|
+
|
|
|
+use Meramo\Speedbase\Controller\SimpleController;
|
|
|
+use TYPO3\CMS\Core\DataHandling\DataHandler;
|
|
|
+use TYPO3\CMS\Core\Utility\GeneralUtility;
|
|
|
+
|
|
|
+class TermsDataHandler
|
|
|
+{
|
|
|
+
|
|
|
+ public function processDatamap_afterDatabaseOperations($status, $table, $id, $fieldArray, DataHandler $dataHandler)
|
|
|
+ {
|
|
|
+ if ($table === 'tt_content') {
|
|
|
+ // Get the CType for the content element
|
|
|
+ $cType = $dataHandler->datamap[$table][$id]['CType'] ?? null;
|
|
|
+
|
|
|
+ if ($cType === 'speedbase') {
|
|
|
+ // $fieldArray contains the updated field values of the content element
|
|
|
+ if ($fieldArray['tx_speedbase_chatbotterms']){
|
|
|
+ // list of terms in input field got changed
|
|
|
+ $termsList = $fieldArray['tx_speedbase_chatbotterms'];
|
|
|
+ } else {
|
|
|
+ // list of terms in input field got not changed just saved
|
|
|
+ $termsList = $dataHandler->recordInfo($table, $id, 'tx_speedbase_chatbotterms');
|
|
|
+ }
|
|
|
+ $category = $dataHandler->recordInfo($table, $id, 'tx_speedbase_chatbottermscategory');
|
|
|
+ $type = $dataHandler->recordInfo($table, $id, 'tx_speedbase_chatbottermstype');
|
|
|
+ $url = $dataHandler->recordInfo($table, $id, 'tx_speedbase_chatbottermsurl');
|
|
|
+
|
|
|
+ $controller = GeneralUtility::makeInstance(SimpleController::class);
|
|
|
+ $controller->persistDataToDBAction($termsList['tx_speedbase_chatbotterms'], $category['tx_speedbase_chatbottermscategory'], $type['tx_speedbase_chatbottermstype'], $url['tx_speedbase_chatbottermsurl']);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|