File tree Expand file tree Collapse file tree 2 files changed +9
-14
lines changed
Expand file tree Collapse file tree 2 files changed +9
-14
lines changed Original file line number Diff line number Diff line change 1+ 2023-05-02 Francois Suter (Idéative) <typo3@ideative.ch>
2+
3+ * Update example code for service instanciation
4+
152022-12-27 Francois Suter (Idéative) <typo3@ideative.ch>
26
37 * Relase version 4.0.0
Original file line number Diff line number Diff line change @@ -16,21 +16,12 @@ easy task. The first step is to get the proper service object:
1616
1717.. code-block :: php
1818
19- $services = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::findService('connector', 'sql');
20- if ($services === false) {
21- // Issue an error
22- } else {
23- $connector = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstanceService('connector', 'sql');
24- }
19+ $registry = GeneralUtility::makeInstance(\Cobweb\Svconnector\Registry\ConnectorRegistry::class);
20+ $connector = $registry->getServiceForType('sql');
2521
26- On the first line, you get a list of all services that are of type
27- “connector” and subtype “sql”. If the result if false, it means no
28- appropriate services were found and you probably want to issue an
29- error message.
30-
31- On the contrary you are assured that there's at least one valid
32- service and you can get an instance of it by calling
33- :code: `\T YPO3\C MS\C ore\U tility\G eneralUtility::makeInstanceService() ` .
22+ An additional step could be to check if the service is indeed available,
23+ by calling :php: `$connector->isAvailable() `, although - in this particular
24+ case - the SQL connector service is always available.
3425
3526The next step is simply to call the appropriate method from the API –
3627with the right parameters – depending on which format you want to have
You can’t perform that action at this time.
0 commit comments