22declare (strict_types = 1 );
33namespace In2code \Powermail \Finisher ;
44
5+ use Doctrine \DBAL \DBALException ;
6+ use In2code \Powermail \Domain \Model \Mail ;
57use In2code \Powermail \Domain \Repository \MailRepository ;
68use In2code \Powermail \Domain \Service \SaveToAnyTableService ;
9+ use In2code \Powermail \Exception \DatabaseFieldMissingException ;
10+ use In2code \Powermail \Exception \PropertiesMissingException ;
711use In2code \Powermail \Utility \ObjectUtility ;
812use In2code \Powermail \Utility \StringUtility ;
913use TYPO3 \CMS \Core \TypoScript \TypoScriptService ;
14+ use TYPO3 \CMS \Core \Utility \GeneralUtility ;
15+ use TYPO3 \CMS \Extbase \Configuration \ConfigurationManagerInterface ;
1016use TYPO3 \CMS \Extbase \Object \Exception ;
1117use TYPO3 \CMS \Extbase \SignalSlot \Exception \InvalidSlotException ;
1218use TYPO3 \CMS \Extbase \SignalSlot \Exception \InvalidSlotReturnException ;
19+ use TYPO3 \CMS \Frontend \ContentObject \ContentObjectRenderer ;
1320
1421/**
1522 * Class SaveToAnyTableFinisher
1623 */
1724class SaveToAnyTableFinisher extends AbstractFinisher implements FinisherInterface
1825{
26+ /**
27+ * @var ContentObjectRenderer
28+ * local instance that can be manipulated via start() and has no influence to parent::contentObject
29+ */
30+ protected $ contentObjectLocal ;
31+
1932 /**
2033 * @var array
2134 */
2235 protected $ dataArray = [];
2336
37+ /**
38+ * @param Mail $mail
39+ * @param array $configuration
40+ * @param array $settings
41+ * @param bool $formSubmitted
42+ * @param string $actionMethodName
43+ * @param ContentObjectRenderer $contentObject
44+ */
45+ public function __construct (
46+ Mail $ mail ,
47+ array $ configuration ,
48+ array $ settings ,
49+ bool $ formSubmitted ,
50+ string $ actionMethodName ,
51+ ContentObjectRenderer $ contentObject
52+ ) {
53+ parent ::__construct ($ mail , $ configuration , $ settings , $ formSubmitted , $ actionMethodName , $ contentObject );
54+ $ configurationManager = GeneralUtility::makeInstance (ConfigurationManagerInterface::class);
55+ $ this ->contentObjectLocal = $ configurationManager ->getContentObject ();
56+ }
57+
2458 /**
2559 * Preperation function for every table
2660 *
2761 * @return void
28- * @throws Exception
62+ * @throws DBALException
63+ * @throws DatabaseFieldMissingException
64+ * @throws PropertiesMissingException
2965 */
3066 public function savePreflightFinisher (): void
3167 {
3268 if ($ this ->isConfigurationAvailable ()) {
3369 foreach (array_keys ($ this ->configuration ) as $ key ) {
34- $ this ->contentObject ->start ($ this ->getDataArray ());
70+ $ this ->contentObjectLocal ->start ($ this ->getDataArray ());
3571 $ tableConfiguration = $ this ->configuration [$ key ];
3672 $ numberKey = (int )StringUtility::removeLastDot ($ key );
3773 if ($ this ->isSaveToAnyTableActivatedForSpecifiedTable ($ tableConfiguration )) {
@@ -47,12 +83,14 @@ public function savePreflightFinisher(): void
4783 * @param int $numberKey
4884 * @param array $tableConfiguration
4985 * @return void
50- * @throws Exception
86+ * @throws DBALException
87+ * @throws DatabaseFieldMissingException
88+ * @throws PropertiesMissingException
5189 */
5290 protected function saveSpecifiedTablePreflight (int $ numberKey , array $ tableConfiguration ): void
5391 {
5492 /* @var $saveService SaveToAnyTableService */
55- $ saveService = ObjectUtility:: getObjectManager ()-> get (
93+ $ saveService = GeneralUtility:: makeInstance (
5694 SaveToAnyTableService::class,
5795 $ this ->getTableName ($ tableConfiguration )
5896 );
@@ -73,7 +111,7 @@ protected function setPropertiesInSaveService(SaveToAnyTableService $saveService
73111 {
74112 foreach (array_keys ($ tableConfiguration ) as $ field ) {
75113 if (!$ this ->isSkippedKey ($ field )) {
76- $ value = $ this ->contentObject ->cObjGetSingle (
114+ $ value = $ this ->contentObjectLocal ->cObjGetSingle (
77115 $ tableConfiguration [$ field ],
78116 $ tableConfiguration [$ field . '. ' ]
79117 );
@@ -123,7 +161,7 @@ protected function addAdditionalWhereClause(SaveToAnyTableService $saveService,
123161 }
124162 if (!empty ($ tableConfiguration ['_ifUniqueWhereClause ' ])
125163 && !empty ($ tableConfiguration ['_ifUniqueWhereClause. ' ])) {
126- $ whereClause = $ this ->contentObject ->cObjGetSingle (
164+ $ whereClause = $ this ->contentObjectLocal ->cObjGetSingle (
127165 $ tableConfiguration ['_ifUniqueWhereClause ' ],
128166 $ tableConfiguration ['_ifUniqueWhereClause. ' ]
129167 );
@@ -143,7 +181,7 @@ protected function addAdditionalWhereClause(SaveToAnyTableService $saveService,
143181 */
144182 protected function getTableName (array $ tableConfiguration ): string
145183 {
146- return $ this ->contentObject ->cObjGetSingle ($ tableConfiguration ['_table ' ], $ tableConfiguration ['_table. ' ]);
184+ return $ this ->contentObjectLocal ->cObjGetSingle ($ tableConfiguration ['_table ' ], $ tableConfiguration ['_table. ' ]);
147185 }
148186
149187 /**
@@ -152,7 +190,10 @@ protected function getTableName(array $tableConfiguration): string
152190 */
153191 protected function isSaveToAnyTableActivatedForSpecifiedTable ($ tableConfiguration ): bool
154192 {
155- $ enable = $ this ->contentObject ->cObjGetSingle ($ tableConfiguration ['_enable ' ]??'' , $ tableConfiguration ['_enable. ' ]??null );
193+ $ enable = $ this ->contentObjectLocal ->cObjGetSingle (
194+ $ tableConfiguration ['_enable ' ] ?? '' ,
195+ $ tableConfiguration ['_enable. ' ] ?? null
196+ );
156197 return !empty ($ enable );
157198 }
158199
0 commit comments