This repository was archived by the owner on Nov 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathApiKeyProviderCompilerPass.php
More file actions
44 lines (39 loc) · 1.59 KB
/
ApiKeyProviderCompilerPass.php
File metadata and controls
44 lines (39 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
namespace Cethyworks\GooglePlaceAutocompleteBundle\DependencyInjection\Compiler;
use Cethyworks\GooglePlaceAutocompleteBundle\Command\GooglePlaceAutocompleteLibraryCommand;
use Cethyworks\GooglePlaceAutocompleteBundle\DependencyInjection\Configuration;
use Symfony\Component\Config\Definition\ConfigurationInterface;
use Symfony\Component\Config\Definition\Processor;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
/**
* Class ApiKeyProviderCompilerPass
*
* @package Cethyworks\GooglePlaceAutocompleteBundle\DependencyInjection
*/
class ApiKeyProviderCompilerPass implements CompilerPassInterface
{
/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container)
{
$configs = $container->getExtensionConfig('cethyworks_google_place_autocomplete');
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
$commandDefinition = $container->getDefinition(GooglePlaceAutocompleteLibraryCommand::class);
$providerDefinition = $container->getDefinition($config['google']['api_key_provider']);
$commandDefinition->setArgument(1, $providerDefinition);
}
/**
* @param ConfigurationInterface $configuration
* @param array $configs
*
* @return array
*/
protected function processConfiguration(ConfigurationInterface $configuration, array $configs)
{
$processor = new Processor();
return $processor->processConfiguration($configuration, $configs);
}
}