You've already forked dolibarr-api-bundle
moved to updated bundle structure
This commit is contained in:
23
config/definition.php
Normal file
23
config/definition.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
use Symfony\Component\Config\Definition\Configurator\DefinitionConfigurator;
|
||||
|
||||
return static function (DefinitionConfigurator $definition): void {
|
||||
$definition->rootNode()
|
||||
->children()
|
||||
->scalarNode(name: 'baseUri')
|
||||
->isRequired()
|
||||
->cannotBeEmpty()
|
||||
->example(example: 'http://localhost')
|
||||
->end()
|
||||
->scalarNode(name: 'token')
|
||||
->isRequired()
|
||||
->cannotBeEmpty()
|
||||
->example(example: 'your-secret-api-token')
|
||||
->end()
|
||||
->booleanNode(name: 'verifyHttps')
|
||||
->defaultTrue()
|
||||
->end()
|
||||
->end()
|
||||
;
|
||||
};
|
||||
@@ -3,4 +3,4 @@ services:
|
||||
class: Magdev\DolibarrApi\DolibarrApiClient
|
||||
arguments: [null, '%magdev.dolibarr_api.base_uri%', '%magdev.dolibarr_api.token%', '%magdev.dolibarr_api.verify_https%']
|
||||
|
||||
Magdev\DolibarrApi\DolibarrApiClientInterface: ['@magdev.dolibarr_api.client']
|
||||
Magdev\DolibarrApi\DolibarrApiClientInterface: '@magdev.dolibarr_api.client'
|
||||
@@ -1,37 +0,0 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Magdev\DolibarrApiBundle\DependencyInjection;
|
||||
|
||||
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
|
||||
use Symfony\Component\Config\Definition\ConfigurationInterface;
|
||||
|
||||
/**
|
||||
* @author Marco Grätsch <magdev3.0@gmail.com>
|
||||
*/
|
||||
final class Configuration implements ConfigurationInterface
|
||||
{
|
||||
public function getConfigTreeBuilder(): TreeBuilder
|
||||
{
|
||||
$treeBuilder = new TreeBuilder(name: 'magdev_dolibarr_api');
|
||||
$rootNode = $treeBuilder->getRootNode();
|
||||
$rootNode->children()
|
||||
->scalarNode(name: 'baseUri')
|
||||
->isRequired()
|
||||
->cannotBeEmpty()
|
||||
->example(example: 'http://localhost')
|
||||
->end()
|
||||
->scalarNode(name: 'token')
|
||||
->isRequired()
|
||||
->cannotBeEmpty()
|
||||
->example(example: 'your-secret-api-token')
|
||||
->end()
|
||||
->booleanNode(name: 'verifyHttps')
|
||||
->defaultTrue()
|
||||
->end()
|
||||
->end()
|
||||
;
|
||||
|
||||
return $treeBuilder;
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Magdev\DolibarrApiBundle\DependencyInjection;
|
||||
|
||||
use Symfony\Component\Config\FileLocator;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Extension\Extension;
|
||||
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
|
||||
|
||||
/**
|
||||
* @author Marco Grätsch <magdev3.0@gmail.com>
|
||||
*/
|
||||
final class MagdevDolibarrApiExtension extends Extension
|
||||
{
|
||||
public function load(array $configs, ContainerBuilder $container): void
|
||||
{
|
||||
$config = $this->processConfiguration(configuration: new Configuration(), configs: $configs);
|
||||
|
||||
if (isset($config['baseUri'])) {
|
||||
$container->setParameter(name: 'magdev.dolibarr_api.base_uri', value: $config['baseUri']);
|
||||
}
|
||||
if (isset($config['token'])) {
|
||||
$container->setParameter(name: 'magdev.dolibarr_api.token', value: $config['token']);
|
||||
}
|
||||
if (isset($config['verifyHttps'])) {
|
||||
$container->setParameter(name: 'magdev.dolibarr_api.verify_https', value: $config['verifyHttps']);
|
||||
}
|
||||
|
||||
$loader = new YamlFileLoader(
|
||||
container: $container,
|
||||
locator: new FileLocator(paths: __DIR__.'/../Resources/config')
|
||||
);
|
||||
$loader->load(resource: 'services.yaml');
|
||||
}
|
||||
}
|
||||
@@ -3,12 +3,31 @@ declare(strict_types=1);
|
||||
|
||||
namespace Magdev\DolibarrApiBundle;
|
||||
|
||||
use Symfony\Component\HttpKernel\Bundle\Bundle;
|
||||
use Symfony\Component\Config\Definition\Configurator\DefinitionConfigurator;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
use Symfony\Component\HttpKernel\Bundle\AbstractBundle;
|
||||
|
||||
/**
|
||||
* @author Marco Grätsch <magdev3.0@gmail.com>
|
||||
*/
|
||||
final class MagdevDolibarrApiBundle extends Bundle
|
||||
final class MagdevDolibarrApiBundle extends AbstractBundle
|
||||
{
|
||||
public function configure(DefinitionConfigurator $definition): void
|
||||
{
|
||||
$definition->import(resource: '../config/definition.php');
|
||||
}
|
||||
|
||||
public function loadExtension(array $config, ContainerConfigurator $container, ContainerBuilder $builder): void
|
||||
{
|
||||
$container->parameters()
|
||||
->set(name: 'magdev.dolibarr_api.base_uri', value: $config['baseUri'])
|
||||
->set(name: 'magdev.dolibarr_api.token', value: $config['token'])
|
||||
->set(name: 'magdev.dolibarr_api.verify_https', value: $config['verifyHttps'])
|
||||
;
|
||||
|
||||
$container->import(resource: '../config/services.yaml');
|
||||
|
||||
$container->services();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user