You've already forked dolibarr-api-bundle
initial version
This commit is contained in:
0
src/.gitignore
vendored
Normal file
0
src/.gitignore
vendored
Normal file
37
src/DependencyInjection/Configuration.php
Normal file
37
src/DependencyInjection/Configuration.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
36
src/DependencyInjection/MagdevDolibarrApiExtension.php
Normal file
36
src/DependencyInjection/MagdevDolibarrApiExtension.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?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');
|
||||
}
|
||||
}
|
||||
14
src/MagdevDolibarrApiBundle.php
Normal file
14
src/MagdevDolibarrApiBundle.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Magdev\DolibarrApiBundle;
|
||||
|
||||
use Symfony\Component\HttpKernel\Bundle\Bundle;
|
||||
|
||||
/**
|
||||
* @author Marco Grätsch <magdev3.0@gmail.com>
|
||||
*/
|
||||
final class MagdevDolibarrApiBundle extends Bundle
|
||||
{
|
||||
|
||||
}
|
||||
3
src/Resources/config/services.yaml
Normal file
3
src/Resources/config/services.yaml
Normal file
@@ -0,0 +1,3 @@
|
||||
services:
|
||||
Magdev\DolibarrApi\DolibarrApiClient:
|
||||
arguments: [null, '%magdev.dolibarr_api.base_uri%', '%magdev.dolibarr_api.token%', '%magdev.dolibarr_api.verify_https%']
|
||||
Reference in New Issue
Block a user