Skip to content

Commit

Permalink
Improve configuration option and parameter names
Browse files Browse the repository at this point in the history
  • Loading branch information
benr77 committed May 25, 2024
1 parent b473584 commit 22fc220
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/HeadsnetDoctrineToolsBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ public function configure(DefinitionConfigurator $definition): void
$definition->rootNode()
->children()
->scalarNode('root_namespace')->cannotBeEmpty()->end()
->arrayNode('preset_types')
->arrayNode('custom_types')
->canBeDisabled()
->children()
->arrayNode('scan_dirs')
->defaultValue(['src/'])->scalarPrototype()->end()
->end()
->end()
->end() // End preset_types
->end() // End custom_types
->arrayNode('custom_mappings')
->children()
->arrayNode('scan_dirs')
Expand All @@ -44,7 +44,7 @@ public function configure(DefinitionConfigurator $definition): void
/**
* @param array{
* root_namespace: string,
* preset_types: array{scan_dirs: array<string>},
* custom_types: array{scan_dirs: array<string>},
* custom_mappings: array{scan_dirs: array<string>},
* carbon_mappings: array{enabled: boolean, replace: boolean}
* } $config
Expand All @@ -55,7 +55,7 @@ public function loadExtension(array $config, ContainerConfigurator $container, C

$container->parameters()
->set('headsnet_doctrine_tools.root_namespace', $config['root_namespace'])
->set('headsnet_doctrine_tools.preset_types.scan_dirs', $config['preset_types']['scan_dirs'])
->set('headsnet_doctrine_tools.custom_types.scan_dirs', $config['custom_types']['scan_dirs'])
->set('headsnet_doctrine_tools.custom_mappings.scan_dirs', $config['custom_mappings']['scan_dirs'])
->set('headsnet_doctrine_tools.carbon_mappings.enabled', $config['carbon_mappings']['enabled'])
->set('headsnet_doctrine_tools.carbon_mappings.replace', $config['carbon_mappings']['replace'])
Expand Down
2 changes: 1 addition & 1 deletion src/Types/DoctrineTypesCompilerPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function process(ContainerBuilder $container): void
/** @var array<string, array{class: class-string}> $typeDefinitions */
$typeDefinitions = $container->getParameter(self::TYPE_DEFINITION_PARAMETER);
/** @var array<string> $scanDirs */
$scanDirs = $container->getParameter('headsnet_doctrine_tools.preset_types.scan_dirs');
$scanDirs = $container->getParameter('headsnet_doctrine_tools.custom_types.scan_dirs');
$this->rootNamespace = $container->getParameter('headsnet_doctrine_tools.root_namespace'); // @phpstan-ignore-line

$objectsToRegister = $this->findObjectsToRegister($scanDirs);
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixtures/config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
headsnet_doctrine_tools:
root_namespace: App
carbon_mappings:
custom_mappings:
scan_dirs:
- 'src/Infra/Persistence/DBAL/Types'
2 changes: 2 additions & 0 deletions tests/HeadsnetDoctrineToolsBundleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Headsnet\DoctrineToolsBundle\HeadsnetDoctrineToolsBundle;
use Headsnet\DoctrineToolsBundle\Mapping\CarbonTypeMappingsCompilerPass;
use Headsnet\DoctrineToolsBundle\Mapping\DoctrineTypeMappingsCompilerPass;
use Headsnet\DoctrineToolsBundle\Types\DoctrineTypesCompilerPass;
use Nyholm\BundleTest\TestKernel;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Test;
Expand All @@ -15,6 +16,7 @@
#[CoversClass(HeadsnetDoctrineToolsBundle::class)]
#[CoversClass(CarbonTypeMappingsCompilerPass::class)]
#[CoversClass(DoctrineTypeMappingsCompilerPass::class)]
#[CoversClass(DoctrineTypesCompilerPass::class)]
class HeadsnetDoctrineToolsBundleTest extends KernelTestCase
{
protected static function getKernelClass(): string
Expand Down

0 comments on commit 22fc220

Please sign in to comment.