Skip to content

Commit

Permalink
move bundle to base src
Browse files Browse the repository at this point in the history
  • Loading branch information
Gyvastis committed Apr 13, 2021
1 parent 8b7c1fe commit d7b76a8
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 60 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"license": "MIT",
"autoload": {
"psr-4": {
"PhpArsenal\\": "src"
"PhpArsenal\\SalesforceBundle\\": "src"
}
},
"autoload-dev": {
Expand Down
File renamed without changes.
43 changes: 43 additions & 0 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

namespace PhpArsenal\SalesforceBundle\DependencyInjection;

use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;

/**
* This is the class that validates and merges configuration from your app/config files
*
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html#cookbook-bundles-extension-config-class}
*/
class Configuration implements ConfigurationInterface
{
/**
* {@inheritDoc}
*/
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder('arsenal_salesforce_soap_client');
$treeBuilder
->getRootNode()
->children()
->scalarNode('wsdl')
->isRequired()
->end()
->scalarNode('username')
->isRequired()
->end()
->scalarNode('password')
->isRequired()
->end()
->scalarNode('token')
->isRequired()
->end()
->scalarNode('logging')
->defaultValue('%kernel.debug%')
->end()
->end();

return $treeBuilder;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ class SalesforceExtension extends Extension
public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
$processedConfiguration = $this->processConfiguration($configuration, $configs);

$loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));

$loader->load('soap_client.xml');
$loader->load('rest_client.xml');
foreach ($config['soap_client'] as $key => $value) {
foreach ($processedConfiguration['soap_client'] as $key => $value) {
$container->setParameter('arsenal.soap_client.' . $key, $value);
}

if (true == $config['soap_client']['logging']) {
if (true == $processedConfiguration['soap_client']['logging']) {
$builder = $container->getDefinition('arsenal.soap_client.builder');
// $builder->addMethodCall('withLog', array(new Reference('arsenal_salesforce.logger')));
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
47 changes: 0 additions & 47 deletions src/SalesforceBundle/DependencyInjection/Configuration.php

This file was deleted.

14 changes: 5 additions & 9 deletions tests/Unit/DependencyInjection/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@ class ConfigurationTest extends TestCase
public function testConfiguration(): void
{
$inputOutput = [
'salesforce_soap_client' => [
'wsdl' => '%kernel.project_dir%/Resources/wsdl/%env(SALESFORCE_WSDL)%',
'username' => '%env(SALESFORCE_USERNAME)%',
'password' => '%env(SALESFORCE_PASSWORD)%',
'token' => '~',
]
'wsdl' => '%kernel.project_dir%/Resources/wsdl/%env(SALESFORCE_WSDL)%',
'username' => '%env(SALESFORCE_USERNAME)%',
'password' => '%env(SALESFORCE_PASSWORD)%',
'token' => '~',
];

$configuration = new Configuration();
Expand All @@ -30,9 +28,7 @@ public function testConfiguration(): void
$resultConfig = $configNode->finalize($configNode->normalize($inputOutput));

$this->assertEquals(array_merge_recursive($inputOutput, [
'salesforce_soap_client' => [
'logging' => '%kernel.debug%',
]
'logging' => '%kernel.debug%',
]), $resultConfig);
}
}

0 comments on commit d7b76a8

Please sign in to comment.