forked from sulu/SuluArticleBundle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SuluArticleBundle.php
85 lines (74 loc) · 2.75 KB
/
SuluArticleBundle.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
<?php
/*
* This file is part of Sulu.
*
* (c) Sulu GmbH
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace Sulu\Bundle\ArticleBundle;
use Sulu\Bundle\ArticleBundle\DependencyInjection\Configuration;
use Sulu\Bundle\ArticleBundle\DependencyInjection\ConverterCompilerPass;
use Sulu\Bundle\ArticleBundle\DependencyInjection\RouteEnhancerCompilerPass;
use Sulu\Bundle\ArticleBundle\DependencyInjection\StructureValidatorCompilerPass;
use Sulu\Bundle\ArticleBundle\Domain\Model\ArticleDimensionContentInterface;
use Sulu\Bundle\ArticleBundle\Domain\Model\ArticleInterface;
use Sulu\Bundle\PersistenceBundle\DependencyInjection\Compiler\ResolveTargetEntitiesPass;
use Sulu\Bundle\PersistenceBundle\PersistenceBundleTrait;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\Compiler\PassConfig;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Bundle\Bundle;
/**
* Entry-point for article-bundle.
*/
class SuluArticleBundle extends Bundle implements CompilerPassInterface
{
use PersistenceBundleTrait;
/**
* {@inheritdoc}
*/
public function build(ContainerBuilder $container)
{
$container->addCompilerPass($this);
$container->addCompilerPass(new StructureValidatorCompilerPass(), PassConfig::TYPE_AFTER_REMOVING);
}
public function process(ContainerBuilder $container): void
{
$storage = $container->getParameter('sulu_article.article_storage');
$compilerPasses = [];
if (Configuration::ARTICLE_STORAGE_PHPCR === $storage) {
$compilerPasses = $this->getPHPCRStorageCompilerPasses($container);
} elseif (Configuration::ARTICLE_STORAGE_EXPERIMENTAL === $storage) {
$compilerPasses = $this->getExperimentalStorageCompilerPasses($container);
}
foreach ($compilerPasses as $compilerPass) {
$compilerPass->process($container);
}
}
/**
* @return CompilerPassInterface[]
*/
private function getExperimentalStorageCompilerPasses(ContainerBuilder $container): array
{
return [
new ResolveTargetEntitiesPass([
ArticleInterface::class => 'sulu.model.article.class',
ArticleDimensionContentInterface::class => 'sulu.model.article_content.class',
]),
];
}
/**
* @return compilerPassInterface[]
*
* Can be removed when phpcr storage is removed
*/
private function getPHPCRStorageCompilerPasses(ContainerBuilder $container): array
{
return [
new RouteEnhancerCompilerPass(),
new ConverterCompilerPass(),
];
}
}