-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathGallySyliusExtension.php
More file actions
71 lines (59 loc) · 2.26 KB
/
Copy pathGallySyliusExtension.php
File metadata and controls
71 lines (59 loc) · 2.26 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
/**
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Gally to newer versions in the future.
*
* @package Gally
* @author Stephan Hochdörfer <S.Hochdoerfer@bitexpert.de>, Gally Team <elasticsuite@smile.fr>
* @copyright 2022-present Smile
* @license Open Software License v. 3.0 (OSL-3.0)
*/
declare(strict_types=1);
namespace Gally\SyliusPlugin\DependencyInjection;
use Sylius\Bundle\CoreBundle\DependencyInjection\PrependDoctrineMigrationsTrait;
use Sylius\Bundle\ResourceBundle\DependencyInjection\Extension\AbstractResourceExtension;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
final class GallySyliusExtension extends AbstractResourceExtension implements PrependExtensionInterface
{
use PrependDoctrineMigrationsTrait;
/** @psalm-suppress UnusedVariable */
public function load(array $configs, ContainerBuilder $container): void
{
$config = $this->processConfiguration($this->getConfiguration([], $container), $configs);
$loader = new PhpFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('services.php');
/** @var string $driver */
$driver = $config['driver'];
/** @var array $resources */
$resources = $config['resources'];
$this->registerResources('gally_sylius', $driver, $resources, $container);
}
public function prepend(ContainerBuilder $container): void
{
$this->prependDoctrineMigrations($container);
$container->prependExtensionConfig('twig', [
'globals' => [
'gally' => '@Gally\SyliusPlugin\Twig\GallyContext',
],
]);
}
protected function getMigrationsNamespace(): string
{
return 'Gally\SyliusPlugin\Migrations';
}
protected function getMigrationsDirectory(): string
{
return '@GallySyliusPlugin/Migrations';
}
/** @return string[] */
protected function getNamespacesOfMigrationsExecutedBefore(): array
{
return [
'Sylius\Bundle\CoreBundle\Migrations',
];
}
}