Developer Corner

The extension is build to be extended to your personal needs. To reach this goal all parts based registries, so you could add the code you need easily without re-implement some code.

There are two ways you could add your personal extensions

Authentication

Currently the only implemented authentication is the api_key-authentication. If you another (a.E. BasicAuth) you must add an authentication class to the registry. This must be done in the ext_localconf.php in your extension. The authentication class must implement the “BefloT3TranslatorAuthenticationAuthenticationInterface” interface. For convinience you could also extend the abstract class “BefloT3TranslatorAuthenticationServiceAbstractAuthentication”

Your authentication class should be similar to following example: .. code-block:: php

<?php

namespace BefloT3TranslatorAuthenticationService;

use GuzzleHttpClient; use GuzzleHttpExceptionGuzzleException;

class ApiKeyAuthentication extends AbstractAuthentication {

/**
  • @param string $url
  • @param array $data
  • @return array|null

*/

public function post(string $url, array $data, bool $jsonResponse = true): ?array {

$result = null; $client = new Client(); try {

$response = $client->request(‘POST’, $url, [
‘form_params’ => $data

]); if ($jsonResponse === true) {

$result = @json_decode($response->getBody()->getContents(), true);
} else {
$result = $response->getBody()->getContents();

}

} catch (GuzzleException $e) {
$this->logger->error($e->getMessage());

}

return $result;

}

/**
  • Initialize the required fields

*/

protected function initialize(): void {

$this->addRequiredField(‘api_key’);

}

}

and the registration in the ext_localconf.php should be similar to

With this you a new authentication method added. This method will NOT be shown in the backend as selection option. This will be done within a translation service.

Translation Service

If you want to select another translation in the backend record you have to register this translation service in your ext_localconf.php

The registration should be similar to

And your translation service should be similar to

In the translation service you only have to manage the translation process itself. The replacing in the correct fields etc. will be done automaticly. You just have to return the translated values like in the example above.