-
Notifications
You must be signed in to change notification settings - Fork 2
/
CoreShopResourceBundle.php
121 lines (100 loc) · 4.79 KB
/
CoreShopResourceBundle.php
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<?php
declare(strict_types=1);
/*
* CoreShop
*
* This source file is available under two different licenses:
* - GNU General Public License version 3 (GPLv3)
* - CoreShop Commercial License (CCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) CoreShop GmbH (https://www.coreshop.org)
* @license https://www.coreshop.org/license GPLv3 and CCL
*
*/
namespace CoreShop\Bundle\ResourceBundle;
use Composer\InstalledVersions;
use CoreShop\Bundle\ResourceBundle\DependencyInjection\Compiler\DoctrineTargetEntitiesResolverPass;
use CoreShop\Bundle\ResourceBundle\DependencyInjection\Compiler\RegisterInstallersPass;
use CoreShop\Bundle\ResourceBundle\DependencyInjection\Compiler\RegisterPimcoreRepositoriesPass;
use CoreShop\Bundle\ResourceBundle\DependencyInjection\Compiler\RegisterPimcoreResourcesPass;
use CoreShop\Bundle\ResourceBundle\DependencyInjection\Compiler\RegisterResourcesPass;
use CoreShop\Bundle\ResourceBundle\DependencyInjection\Compiler\StackClassesPass;
use CoreShop\Bundle\ResourceBundle\DependencyInjection\Compiler\StackRepositoryPass;
use CoreShop\Bundle\ResourceBundle\DependencyInjection\Compiler\ValidatorAutoMappingFixPass;
use JMS\SerializerBundle\JMSSerializerBundle;
use Pimcore\Bundle\AdminBundle\PimcoreAdminBundle;
use Pimcore\Bundle\ApplicationLoggerBundle\PimcoreApplicationLoggerBundle;
use Pimcore\Bundle\SimpleBackendSearchBundle\PimcoreSimpleBackendSearchBundle;
use Pimcore\Bundle\StaticRoutesBundle\PimcoreStaticRoutesBundle;
use Pimcore\Extension\Bundle\AbstractPimcoreBundle;
use Pimcore\HttpKernel\Bundle\DependentBundleInterface;
use Pimcore\HttpKernel\BundleCollection\BundleCollection;
use Symfony\Component\DependencyInjection\ContainerBuilder;
final class CoreShopResourceBundle extends AbstractPimcoreBundle implements DependentBundleInterface
{
public const DRIVER_DOCTRINE_ORM = 'doctrine/orm';
public const DRIVER_PIMCORE = 'pimcore';
public const PIMCORE_MODEL_TYPE_OBJECT = 'object';
public const PIMCORE_MODEL_TYPE_FIELD_COLLECTION = 'fieldcollection';
public const PIMCORE_MODEL_TYPE_BRICK = 'brick';
public function build(ContainerBuilder $container): void
{
parent::build($container);
$container->addCompilerPass(new RegisterResourcesPass());
$container->addCompilerPass(new RegisterPimcoreResourcesPass());
$container->addCompilerPass(new DoctrineTargetEntitiesResolverPass());
$container->addCompilerPass(new RegisterInstallersPass());
$container->addCompilerPass(new StackClassesPass());
$container->addCompilerPass(new StackRepositoryPass());
$container->addCompilerPass(new RegisterPimcoreRepositoriesPass());
$container->addCompilerPass(new ValidatorAutoMappingFixPass());
}
public static function registerDependentBundles(BundleCollection $collection): void
{
$collection->addBundle(new JMSSerializerBundle(), 3900);
$collection->addBundle(new \CoreShop\Bundle\PimcoreBundle\CoreShopPimcoreBundle(), 3850);
$collection->addBundle(new \CoreShop\Bundle\OptimisticEntityLockBundle\CoreShopOptimisticEntityLockBundle(), 3800);
$collection->addBundle(new \CoreShop\Bundle\LocaleBundle\CoreShopLocaleBundle(), 3850);
$collection->addBundle(new \Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(), 1200);
$collection->addBundle(new PimcoreAdminBundle(), 10);
$collection->addBundle(new PimcoreApplicationLoggerBundle(), 10);
$collection->addBundle(new PimcoreStaticRoutesBundle(), 10);
$collection->addBundle(new PimcoreSimpleBackendSearchBundle(), 10);
}
public function getNiceName(): string
{
return 'CoreShop - Resource';
}
public function getDescription(): string
{
return 'CoreShop - Resource Bundle';
}
public function getVersion(): string
{
if (class_exists('\\CoreShop\\Bundle\\CoreBundle\\Application\\Version')) {
return \CoreShop\Bundle\CoreBundle\Application\Version::getVersion() . ' (' . $this->getComposerVersion() . ')';
}
return $this->getComposerVersion();
}
public function getComposerVersion(): string
{
$bundleName = 'coreshop/resource-bundle';
if (class_exists(InstalledVersions::class)) {
if (InstalledVersions::isInstalled('coreshop/core-shop')) {
return InstalledVersions::getPrettyVersion('coreshop/core-shop');
}
if (InstalledVersions::isInstalled($bundleName)) {
return InstalledVersions::getPrettyVersion($bundleName);
}
}
return '';
}
public static function getAvailableDrivers(): array
{
return [
self::DRIVER_DOCTRINE_ORM,
];
}
}