2626use Cobweb \SvconnectorSql \Database \DoctrineDbalConnection ;
2727use Cobweb \SvconnectorSql \Exception \DatabaseConnectionException ;
2828use Cobweb \SvconnectorSql \Exception \QueryErrorException ;
29+ use Doctrine \DBAL \Exception ;
2930use TYPO3 \CMS \Core \Utility \GeneralUtility ;
3031
3132/**
@@ -50,32 +51,13 @@ public function isAvailable(): bool
5051 * This method calls the fetchArray() method and returns the result as is,
5152 * i.e. the SQL record set, but without any additional work performed on it
5253 *
53- * @param array $parameters Parameters for the call
54- * @return mixed Server response
5554 * @throws \Exception
5655 */
57- public function fetchRaw (array $ parameters = [])
56+ public function fetchRaw (): mixed
5857 {
59- // Call to parent is used only to raise flag about argument deprecation
60- // TODO: remove once method signature is changed in next major version
61- parent ::fetchRaw (...func_get_args ());
62-
6358 // Get the data as an array
6459 // NOTE: this may throw an exception, but we let it bubble up
6560 $ result = $ this ->fetchArray ();
66- // Implement post-processing hook
67- $ hooks = $ GLOBALS ['TYPO3_CONF_VARS ' ]['SC_OPTIONS ' ][$ this ->extensionKey ]['processRaw ' ] ?? null ;
68- if (is_array ($ hooks ) && count ($ hooks ) > 0 ) {
69- trigger_error (
70- 'Using the processRaw hook is deprecated. Use the ProcessRawDataEvent instead ' ,
71- E_USER_DEPRECATED
72- );
73- foreach ($ GLOBALS ['TYPO3_CONF_VARS ' ]['SC_OPTIONS ' ][$ this ->extensionKey ]['processRaw ' ] as $ className ) {
74- $ processor = GeneralUtility::makeInstance ($ className );
75- $ result = $ processor ->processRaw ($ result , $ this );
76- }
77- }
78- /** @var ProcessRawDataEvent $event */
7961 $ event = $ this ->eventDispatcher ->dispatch (
8062 new ProcessRawDataEvent ($ result , $ this )
8163 );
@@ -85,34 +67,15 @@ public function fetchRaw(array $parameters = [])
8567 /**
8668 * This method calls the query and returns the results from the response as an XML structure
8769 *
88- * @param array $parameters Parameters for the call
89- * @return string XML structure
9070 * @throws \Exception
9171 */
92- public function fetchXML (array $ parameters = [] ): string
72+ public function fetchXML (): string
9373 {
94- // Call to parent is used only to raise flag about argument deprecation
95- // TODO: remove once method signature is changed in next major version
96- parent ::fetchXML (...func_get_args ());
97-
9874 // Get the data as an array
9975 // NOTE: this may throw an exception, but we let it bubble up
10076 $ result = $ this ->fetchArray ();
10177 // Transform result to XML
10278 $ xml = '<?xml version="1.0" encoding="utf-8" standalone="yes" ?> ' . "\n" . GeneralUtility::array2xml ($ result );
103- // Implement post-processing hook
104- $ hooks = $ GLOBALS ['TYPO3_CONF_VARS ' ]['SC_OPTIONS ' ][$ this ->extensionKey ]['processXML ' ] ?? null ;
105- if (is_array ($ hooks ) && count ($ hooks ) > 0 ) {
106- trigger_error (
107- 'Using the processXML hook is deprecated. Use the ProcessXmlDataEvent instead ' ,
108- E_USER_DEPRECATED
109- );
110- foreach ($ GLOBALS ['TYPO3_CONF_VARS ' ]['SC_OPTIONS ' ][$ this ->extensionKey ]['processXML ' ] as $ className ) {
111- $ processor = GeneralUtility::makeInstance ($ className );
112- $ xml = $ processor ->processXML ($ xml , $ this );
113- }
114- }
115- /** @var ProcessXmlDataEvent $event */
11679 $ event = $ this ->eventDispatcher ->dispatch (
11780 new ProcessXmlDataEvent ($ xml , $ this )
11881 );
@@ -123,38 +86,20 @@ public function fetchXML(array $parameters = []): string
12386 /**
12487 * This method calls the query and returns the results from the response as a PHP array
12588 *
126- * @param array $parameters Parameters for the call
127- * @throws \Exception
12889 * @return array PHP array
90+ * @throws DatabaseConnectionException
91+ * @throws QueryErrorException
12992 */
130- public function fetchArray (array $ parameters = [] ): array
93+ public function fetchArray (): array
13194 {
132- // Call to parent is used only to raise flag about argument deprecation
133- // TODO: remove once method signature is changed in next major version
134- parent ::fetchArray (...func_get_args ());
135-
13695 try {
13796 $ data = $ this ->query ();
13897 $ this ->logger ->info ('Structured data ' , $ data );
139-
140- // Implement post-processing hook
141- $ hooks = $ GLOBALS ['TYPO3_CONF_VARS ' ]['SC_OPTIONS ' ][$ this ->extensionKey ]['processArray ' ] ?? null ;
142- if (is_array ($ hooks ) && count ($ hooks ) > 0 ) {
143- trigger_error (
144- 'Using the processArray hook is deprecated. Use the ProcessArrayDataEvent instead ' ,
145- E_USER_DEPRECATED
146- );
147- foreach ($ GLOBALS ['TYPO3_CONF_VARS ' ]['SC_OPTIONS ' ][$ this ->extensionKey ]['processArray ' ] as $ className ) {
148- $ processor = GeneralUtility::makeInstance ($ className );
149- $ data = $ processor ->processArray ($ data , $ this );
150- }
151- }
15298 } catch (\Exception $ e ) {
15399 // Log exception and throw it further
154100 $ this ->logger ->error ('An error occurred: ' . $ e ->getMessage ());
155101 throw $ e ;
156102 }
157- /** @var ProcessArrayDataEvent $event */
158103 $ event = $ this ->eventDispatcher ->dispatch (
159104 new ProcessArrayDataEvent ($ data , $ this )
160105 );
@@ -164,20 +109,13 @@ public function fetchArray(array $parameters = []): array
164109 /**
165110 * This method connects to the designated database, executes the given query and returns the data an an array
166111 *
167- * NOTE: this method does not implement the "processParameters" hook,
168- * as it does not make sense in this case
169- *
170- * @param array $parameters Parameters for the call
112+ * @return mixed Result of the SQL query
171113 * @throws DatabaseConnectionException
172114 * @throws QueryErrorException
173- * @return mixed Result of the SQL query
115+ * @throws Exception
174116 */
175- protected function query (array $ parameters = [])
117+ protected function query (): mixed
176118 {
177- // Call to parent is used only to raise flag about argument deprecation
178- // TODO: remove once method signature is changed in next major version
179- parent ::query (...func_get_args ());
180-
181119 // Connect to the database and execute the query
182120 // NOTE: this may throw exceptions, but we let them bubble up
183121 $ databaseConnection = GeneralUtility::makeInstance (DoctrineDbalConnection::class);
@@ -187,19 +125,6 @@ protected function query(array $parameters = [])
187125 (int )($ this ->parameters ['fetchMode ' ] ?? 0 )
188126 );
189127
190- // Process the result if any hook is registered
191- $ hooks = $ GLOBALS ['TYPO3_CONF_VARS ' ]['SC_OPTIONS ' ][$ this ->extensionKey ]['processResponse ' ] ?? null ;
192- if (is_array ($ hooks ) && count ($ hooks ) > 0 ) {
193- trigger_error (
194- 'Using the processResponse hook is deprecated. Use the ProcessResponseEvent instead ' ,
195- E_USER_DEPRECATED
196- );
197- foreach ($ GLOBALS ['TYPO3_CONF_VARS ' ]['SC_OPTIONS ' ][$ this ->extensionKey ]['processResponse ' ] as $ className ) {
198- $ processor = GeneralUtility::makeInstance ($ className );
199- $ data = $ processor ->processResponse ($ data , $ this );
200- }
201- }
202- /** @var ProcessResponseEvent $event */
203128 $ event = $ this ->eventDispatcher ->dispatch (
204129 new ProcessResponseEvent ($ data , $ this )
205130 );
0 commit comments