-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathIbexaCoreBundle.php
More file actions
158 lines (146 loc) · 8.84 KB
/
Copy pathIbexaCoreBundle.php
File metadata and controls
158 lines (146 loc) · 8.84 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
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
<?php
/**
* @copyright Copyright (C) Ibexa AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
declare(strict_types=1);
namespace Ibexa\Bundle\Core;
use Ibexa\Bundle\Core\DependencyInjection\Compiler\AsyncContentPublisherStrategyPass;
use Ibexa\Bundle\Core\DependencyInjection\Compiler\AsyncContentPublishTransportGuardPass;
use Ibexa\Bundle\Core\DependencyInjection\Compiler\BinaryContentDownloadPass;
use Ibexa\Bundle\Core\DependencyInjection\Compiler\ChainConfigResolverPass;
use Ibexa\Bundle\Core\DependencyInjection\Compiler\ChainRoutingPass;
use Ibexa\Bundle\Core\DependencyInjection\Compiler\ConsoleCacheWarmupPass;
use Ibexa\Bundle\Core\DependencyInjection\Compiler\EntityManagerFactoryServiceLocatorPass;
use Ibexa\Bundle\Core\DependencyInjection\Compiler\FieldTypeParameterProviderRegistryPass;
use Ibexa\Bundle\Core\DependencyInjection\Compiler\FragmentPass;
use Ibexa\Bundle\Core\DependencyInjection\Compiler\ImaginePass;
use Ibexa\Bundle\Core\DependencyInjection\Compiler\InjectEntityManagerMappingsPass;
use Ibexa\Bundle\Core\DependencyInjection\Compiler\LazyDoctrineRepositoriesPass;
use Ibexa\Bundle\Core\DependencyInjection\Compiler\NotificationRendererPass;
use Ibexa\Bundle\Core\DependencyInjection\Compiler\PlaceholderProviderPass;
use Ibexa\Bundle\Core\DependencyInjection\Compiler\QueryTypePass;
use Ibexa\Bundle\Core\DependencyInjection\Compiler\RegisterSearchEngineIndexerPass;
use Ibexa\Bundle\Core\DependencyInjection\Compiler\RegisterSearchEnginePass;
use Ibexa\Bundle\Core\DependencyInjection\Compiler\RegisterStorageEnginePass;
use Ibexa\Bundle\Core\DependencyInjection\Compiler\RouterPass;
use Ibexa\Bundle\Core\DependencyInjection\Compiler\SecurityPass;
use Ibexa\Bundle\Core\DependencyInjection\Compiler\SessionConfigurationPass;
use Ibexa\Bundle\Core\DependencyInjection\Compiler\SiteAccessMatcherRegistryPass;
use Ibexa\Bundle\Core\DependencyInjection\Compiler\SlugConverterConfigurationPass;
use Ibexa\Bundle\Core\DependencyInjection\Compiler\StorageConnectionFactoryPass;
use Ibexa\Bundle\Core\DependencyInjection\Compiler\StorageConnectionPass;
use Ibexa\Bundle\Core\DependencyInjection\Compiler\TranslationCollectorPass;
use Ibexa\Bundle\Core\DependencyInjection\Compiler\URLHandlerPass;
use Ibexa\Bundle\Core\DependencyInjection\Compiler\ViewProvidersPass;
use Ibexa\Bundle\Core\DependencyInjection\Configuration\ComplexSettings\ComplexSettingParser;
use Ibexa\Bundle\Core\DependencyInjection\Configuration\Parser as ConfigParser;
use Ibexa\Bundle\Core\DependencyInjection\Configuration\Parser\Repository as RepositoryConfigParser;
use Ibexa\Bundle\Core\DependencyInjection\IbexaCoreExtension;
use Ibexa\Contracts\Core\MVC\View\VariableProvider;
use Ibexa\Core\Base\Container\Compiler\FieldTypeRegistryPass;
use Ibexa\Core\Base\Container\Compiler\GenericFieldTypeConverterPass;
use Ibexa\Core\Base\Container\Compiler\Persistence\FieldTypeRegistryPass as PersistenceFieldTypeRegistryPass;
use Ibexa\Core\Base\Container\Compiler\Search\AggregateFieldValueMapperPass;
use Ibexa\Core\Base\Container\Compiler\Search\FieldRegistryPass;
use Ibexa\Core\Base\Container\Compiler\Storage\ExternalStorageRegistryPass;
use Ibexa\Core\Base\Container\Compiler\Storage\Legacy\FieldValueConverterRegistryPass;
use Ibexa\Core\Base\Container\Compiler\Storage\Legacy\RoleLimitationConverterPass;
use RuntimeException;
use Symfony\Component\DependencyInjection\Compiler\PassConfig;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
use Symfony\Component\HttpKernel\Bundle\Bundle;
final class IbexaCoreBundle extends Bundle
{
public function build(ContainerBuilder $container): void
{
parent::build($container);
$container->addCompilerPass(new GenericFieldTypeConverterPass(), PassConfig::TYPE_OPTIMIZE);
$container->addCompilerPass(new FieldTypeRegistryPass(), PassConfig::TYPE_OPTIMIZE);
$container->addCompilerPass(new PersistenceFieldTypeRegistryPass(), PassConfig::TYPE_OPTIMIZE);
$container->addCompilerPass(new FieldTypeParameterProviderRegistryPass());
$container->addCompilerPass(new ChainRoutingPass());
$container->addCompilerPass(new ChainConfigResolverPass());
$container->addCompilerPass(new RegisterStorageEnginePass());
$container->addCompilerPass(new RegisterSearchEnginePass());
$container->addCompilerPass(new RegisterSearchEngineIndexerPass());
$container->addCompilerPass(new AggregateFieldValueMapperPass());
$container->addCompilerPass(new FieldRegistryPass());
$container->addCompilerPass(new RouterPass());
$container->addCompilerPass(new SecurityPass());
$container->addCompilerPass(new FragmentPass());
$container->addCompilerPass(new StorageConnectionPass());
$container->addCompilerPass(new ImaginePass());
$container->addCompilerPass(new URLHandlerPass());
$container->addCompilerPass(new BinaryContentDownloadPass());
$container->addCompilerPass(new ViewProvidersPass());
$container->addCompilerPass(new PlaceholderProviderPass());
$container->addCompilerPass(new NotificationRendererPass());
$container->addCompilerPass(new ConsoleCacheWarmupPass());
$container->addCompilerPass(new SiteAccessMatcherRegistryPass());
$container->addCompilerPass(new LazyDoctrineRepositoriesPass(), PassConfig::TYPE_BEFORE_REMOVING);
$container->addCompilerPass(new EntityManagerFactoryServiceLocatorPass());
$container->addCompilerPass(new InjectEntityManagerMappingsPass());
$container->addCompilerPass(new SessionConfigurationPass());
// Storage passes
$container->addCompilerPass(new ExternalStorageRegistryPass());
$container->addCompilerPass(new StorageConnectionFactoryPass());
// Legacy Storage passes
$container->addCompilerPass(new FieldValueConverterRegistryPass());
$container->addCompilerPass(new RoleLimitationConverterPass());
$container->addCompilerPass(new QueryTypePass());
$container->addCompilerPass(new TranslationCollectorPass());
$container->addCompilerPass(new SlugConverterConfigurationPass());
$container->addCompilerPass(new AsyncContentPublishTransportGuardPass());
$container->addCompilerPass(new AsyncContentPublisherStrategyPass());
$container->registerForAutoconfiguration(VariableProvider::class)->addTag('ezplatform.view.variable_provider');
$this->validateIbexaCloudExistence($container);
}
public function getContainerExtension(): ExtensionInterface
{
if (!isset($this->extension)) {
$this->extension = new IbexaCoreExtension(
[
// LocationView config parser needs to be specified AFTER ContentView config
// parser since it is used to convert location view override rules to content
// view override rules. If it were specified before, ContentView provider would
// just undo the conversion LocationView did.
new ConfigParser\ContentView(),
new ConfigParser\LocationView(),
new ConfigParser\Common(),
new ConfigParser\Content(),
new ConfigParser\FieldType\ImageAsset(),
new ConfigParser\FieldTemplates(),
new ConfigParser\FieldEditTemplates(),
new ConfigParser\FieldDefinitionSettingsTemplates(),
new ConfigParser\FieldDefinitionEditTemplates(),
new ConfigParser\Image(),
new ConfigParser\Languages(),
new ConfigParser\IO(new ComplexSettingParser()),
new ConfigParser\UrlChecker(),
new ConfigParser\TwigVariablesParser(),
new ConfigParser\UserContentTypeIdentifier(),
new ConfigParser\Embeddings(),
],
[
new RepositoryConfigParser\AsyncContentPublish(),
new RepositoryConfigParser\Storage(),
new RepositoryConfigParser\Search(),
new RepositoryConfigParser\FieldGroups(),
new RepositoryConfigParser\Options(),
]
);
}
return $this->extension;
}
private function validateIbexaCloudExistence(ContainerBuilder $container): void
{
if (!isset($_SERVER['PLATFORM_RELATIONSHIPS']) || $container->hasExtension('ibexa_cloud')) {
return;
}
throw new RuntimeException(
'The package `ibexa/cloud` is mandatory for Ibexa Cloud deployments. Please install it according to the documentation: https://doc.ibexa.co/en/5.0/ibexa_cloud/install_on_ibexa_cloud/#1-prepare-configuration-files'
);
}
}