|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Loevgaard\DandomainAltapayBundle\DependencyInjection; |
|
4
|
|
|
|
|
5
|
|
|
use Loevgaard\DandomainAltapayBundle\Entity\SiteSetting; |
|
6
|
|
|
use Symfony\Component\Config\FileLocator; |
|
7
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
8
|
|
|
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; |
|
9
|
|
|
use Symfony\Component\HttpKernel\DependencyInjection\Extension; |
|
10
|
|
|
|
|
11
|
|
|
class LoevgaardDandomainAltapayExtension extends Extension |
|
12
|
|
|
{ |
|
13
|
|
|
public function load(array $configs, ContainerBuilder $container) |
|
14
|
|
|
{ |
|
15
|
|
|
$configuration = new Configuration(); |
|
16
|
|
|
$config = $this->processConfiguration($configuration, $configs); |
|
17
|
|
|
|
|
18
|
|
|
$container->setParameter('loevgaard_dandomain_altapay.altapay_username', $config['altapay_username']); |
|
19
|
|
|
$container->setParameter('loevgaard_dandomain_altapay.altapay_password', $config['altapay_password']); |
|
20
|
|
|
$container->setParameter('loevgaard_dandomain_altapay.altapay_ips', $config['altapay_ips']); |
|
21
|
|
|
$container->setParameter('loevgaard_dandomain_altapay.altapay_url', $config['altapay_url']); |
|
22
|
|
|
$container->setParameter('loevgaard_dandomain_altapay.shared_key_1', $config['shared_key_1']); |
|
23
|
|
|
$container->setParameter('loevgaard_dandomain_altapay.shared_key_2', $config['shared_key_2']); |
|
24
|
|
|
$container->setParameter('loevgaard_dandomain_altapay.cookie_payment_id', $config['cookie_payment_id']); |
|
25
|
|
|
$container->setParameter('loevgaard_dandomain_altapay.cookie_checksum_complete', $config['cookie_checksum_complete']); |
|
26
|
|
|
$container->setParameter('loevgaard_dandomain_altapay.webhook_urls', $config['webhook_urls']); |
|
27
|
|
|
$container->setParameter('loevgaard_dandomain_altapay.default_settings', $config['default_settings']); |
|
28
|
|
|
|
|
29
|
|
|
// set individual default settings |
|
30
|
|
|
$container->setParameter('loevgaard_dandomain_altapay.default_settings.layout.logo', $config['default_settings']['layout']['logo']); |
|
31
|
|
|
|
|
32
|
|
|
$this->verifyDefaultSettings($container); |
|
33
|
|
|
|
|
34
|
|
|
$loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); |
|
35
|
|
|
$loader->load('services.yml'); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* This method will verify that all available settings in the SiteSetting are defined as parameters. |
|
40
|
|
|
* |
|
41
|
|
|
* @param ContainerBuilder $container |
|
42
|
|
|
* |
|
43
|
|
|
* @throws \RuntimeException |
|
44
|
|
|
*/ |
|
45
|
|
|
private function verifyDefaultSettings(ContainerBuilder $container) |
|
46
|
|
|
{ |
|
47
|
|
|
$settings = SiteSetting::getSettings(); |
|
48
|
|
|
foreach ($settings as $setting) { |
|
49
|
|
|
$parameter = 'loevgaard_dandomain_altapay.default_settings.'.$setting; |
|
50
|
|
|
if (!$container->hasParameter($parameter)) { |
|
51
|
|
|
throw new \RuntimeException('The parameter `'.$parameter.'` is not configured in the code'); |
|
52
|
|
|
} |
|
53
|
|
|
} |
|
54
|
|
|
} |
|
55
|
|
|
} |
|
56
|
|
|
|