Implementing a connector service
A custom connector service must implement the interface \Cobweb\
.
However, there is an abstract base class (\Cobweb\
)
which contains some base implementations and some useful helper methods, it is thus
recommended to extend that class rather than implementing the interface from scratch.
namespace MyName\MyExt\Service;
class ConnectorSpecialThingy extends \Cobweb\Svconnector\Service\ConnectorBase {
protected string $extensionKey = 'my_ext';
...
}
It is considered a best practice to place your class file in the
Classes/
folder of your extension. It must declare an
$extension
member variable, as this is used by the API to fetch
the sample configuration.
You must then register your service with the connector registry. This is done
using the \Cobweb\
attribute,
with the service's type and name passed as attribute arguments (the type is
critical, since this is what identifies a service; the name is a description):
#[AsConnectorService(type: 'json', name: 'JSON connector')]
class ConnectorJson extends ConnectorBase
{
...
}
Note
A connector service can also be registered in the Configuration/
file,
but this is now deprecated in favor of using the PHP attribute described above. Example:
Cobweb\SvconnectorCsv\Service\ConnectorCsv:
public: true
arguments:
- !tagged_iterator connector.service
The base service provides several utility methods to access method or
properties of the \TYPO3\
class and of
the \TYPO3\
class
independently of context (FE or BE).
If you need to implement the __
method, make sure to call
parent::__
within it.