Skip to content

Commit 21f520e

Browse files
author
Francois Suter
committed
[BUGFIX] Update example code for service instanciation
1 parent d3919d2 commit 21f520e

File tree

2 files changed

+9
-14
lines changed

2 files changed

+9
-14
lines changed

ChangeLog

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
2023-05-02 Francois Suter (Idéative) <typo3@ideative.ch>
2+
3+
* Update example code for service instanciation
4+
15
2022-12-27 Francois Suter (Idéative) <typo3@ideative.ch>
26

37
* Relase version 4.0.0

Documentation/Developer/Index.rst

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff 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:`\TYPO3\CMS\Core\Utility\GeneralUtility::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

3526
The next step is simply to call the appropriate method from the API –
3627
with the right parameters – depending on which format you want to have

0 commit comments

Comments
 (0)