|
1
|
|
|
<?php |
|
2
|
|
|
namespace CodeCloud\Bundle\ShopifyBundle\DependencyInjection; |
|
3
|
|
|
|
|
4
|
|
|
use CodeCloud\Bundle\ShopifyBundle\Security\DevAuthenticator; |
|
5
|
|
|
use Symfony\Component\Config\FileLocator; |
|
6
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
7
|
|
|
use Symfony\Component\DependencyInjection\Definition; |
|
8
|
|
|
use Symfony\Component\DependencyInjection\Extension\Extension; |
|
9
|
|
|
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; |
|
10
|
|
|
|
|
11
|
|
|
class CodeCloudShopifyExtension extends Extension |
|
12
|
|
|
{ |
|
13
|
|
|
/** |
|
14
|
|
|
* {@inheritdoc} |
|
15
|
|
|
*/ |
|
16
|
|
|
public function load(array $configs, ContainerBuilder $container) |
|
17
|
|
|
{ |
|
18
|
|
|
$configuration = new Configuration(); |
|
19
|
|
|
$config = $this->processConfiguration($configuration, $configs); |
|
20
|
|
|
|
|
21
|
|
|
$container->setParameter('codecloud_shopify', $config); |
|
22
|
|
|
$container->setParameter('codecloud_shopify.oauth', $config['oauth']); |
|
23
|
|
|
$container->setParameter('codecloud_shopify.webhooks', $config['webhooks']); |
|
24
|
|
|
$container->setParameter('codecloud_shopify.api_version', $config['api_version']); |
|
25
|
|
|
|
|
26
|
|
|
foreach ($config['oauth'] as $key => $value) { |
|
27
|
|
|
$container->setParameter('codecloud_shopify.oauth.'.$key, $value); |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
$loader = new YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); |
|
31
|
|
|
$loader->load('services.yml'); |
|
32
|
|
|
|
|
33
|
|
|
$container->setAlias('codecloud_shopify.store_manager', $config['store_manager_id']); |
|
34
|
|
|
|
|
35
|
|
|
if (!empty($config['dev_impersonate_store'])) { |
|
36
|
|
|
$definition = new Definition( |
|
37
|
|
|
DevAuthenticator::class, |
|
38
|
|
|
[$config['dev_impersonate_store']] |
|
39
|
|
|
); |
|
40
|
|
|
$container->setDefinition('codecloud_shopify.security.session_authenticator', $definition); |
|
41
|
|
|
} |
|
42
|
|
|
} |
|
43
|
|
|
} |
|
44
|
|
|
|