mirror of
https://github.com/OpenXE-org/OpenXE.git
synced 2024-12-27 15:10:28 +01:00
45 lines
1.1 KiB
PHP
45 lines
1.1 KiB
PHP
|
<?php
|
||
|
|
||
|
namespace Xentral\Modules\TaxdooApi;
|
||
|
|
||
|
use Xentral\Core\DependencyInjection\ContainerInterface;
|
||
|
use Xentral\Modules\TaxdooApi\Exception\ConfigurationMissingException;
|
||
|
use Xentral\Modules\TaxdooApi\Exception\KeyNotFoundException;
|
||
|
|
||
|
final class Bootstrap
|
||
|
{
|
||
|
/**
|
||
|
* @return array
|
||
|
*/
|
||
|
public static function registerServices()
|
||
|
{
|
||
|
return [
|
||
|
'TaxdooApiService' => 'onInitTaxdooApiService',
|
||
|
];
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @param ContainerInterface $container
|
||
|
*
|
||
|
* @throws KeyNotFoundException|ConfigurationMissingException
|
||
|
*
|
||
|
* @return TaxdooApiService
|
||
|
*/
|
||
|
public static function onInitTaxdooApiService(ContainerInterface $container)
|
||
|
{
|
||
|
$app = $container->get('LegacyApplication');
|
||
|
|
||
|
$token = $app->erp->GetKonfiguration('taxdoo_token');
|
||
|
if ($token === '') {
|
||
|
throw new KeyNotFoundException();
|
||
|
}
|
||
|
|
||
|
$land = $app->erp->GetKonfiguration('taxdoo_land');
|
||
|
if (strlen($land) !== 2) {
|
||
|
throw new ConfigurationMissingException('Land muss ISO-2 sein');
|
||
|
}
|
||
|
|
||
|
return new TaxdooApiService($token);
|
||
|
}
|
||
|
}
|