|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* This file is part of the eZ Publish Kernel package. |
|
4
|
|
|
* |
|
5
|
|
|
* @copyright Copyright (C) eZ Systems AS. All rights reserved. |
|
6
|
|
|
* @license For full copyright and license information view LICENSE file distributed with this source code. |
|
7
|
|
|
*/ |
|
8
|
|
|
namespace eZ\Bundle\EzPublishRestBundle\DependencyInjection; |
|
9
|
|
|
|
|
10
|
|
|
use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\SiteAccessAware\ConfigurationProcessor; |
|
11
|
|
|
use Symfony\Component\Config\FileLocator; |
|
12
|
|
|
use Symfony\Component\Config\Resource\FileResource; |
|
13
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
14
|
|
|
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface; |
|
15
|
|
|
use Symfony\Component\DependencyInjection\Loader; |
|
16
|
|
|
use Symfony\Component\HttpKernel\DependencyInjection\Extension; |
|
17
|
|
|
use Symfony\Component\Yaml\Yaml; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* This is the class that loads and manages your bundle configuration. |
|
21
|
|
|
* |
|
22
|
|
|
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html} |
|
23
|
|
|
*/ |
|
24
|
|
|
class EzPublishRestExtension extends Extension implements PrependExtensionInterface |
|
25
|
|
|
{ |
|
26
|
|
|
/** |
|
27
|
|
|
* {@inheritdoc} |
|
28
|
|
|
*/ |
|
29
|
|
|
public function load(array $configs, ContainerBuilder $container) |
|
30
|
|
|
{ |
|
31
|
|
|
$configuration = $this->getConfiguration($configs, $container); |
|
32
|
|
|
$config = $this->processConfiguration($configuration, $configs); |
|
|
|
|
|
|
33
|
|
|
|
|
34
|
|
|
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); |
|
35
|
|
|
$loader->load('services.yml'); |
|
36
|
|
|
$loader->load('value_object_visitors.yml'); |
|
37
|
|
|
$loader->load('input_parsers.yml'); |
|
38
|
|
|
$loader->load('security.yml'); |
|
39
|
|
|
$loader->load('default_settings.yml'); |
|
40
|
|
|
|
|
41
|
|
|
$processor = new ConfigurationProcessor($container, 'ezsettings'); |
|
42
|
|
|
$processor->mapConfigArray('rest_root_resources', $config); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
public function prepend(ContainerBuilder $container) |
|
46
|
|
|
{ |
|
47
|
|
|
if ($container->hasExtension('nelmio_cors')) { |
|
48
|
|
|
$file = __DIR__ . '/../Resources/config/nelmio_cors.yml'; |
|
49
|
|
|
$config = Yaml::parse(file_get_contents($file)); |
|
50
|
|
|
$container->prependExtensionConfig('nelmio_cors', $config); |
|
51
|
|
|
$container->addResource(new FileResource($file)); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
$this->prependRouterConfiguration($container); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
private function prependRouterConfiguration(ContainerBuilder $container) |
|
58
|
|
|
{ |
|
59
|
|
|
$config = ['router' => ['default_router' => ['non_siteaccess_aware_routes' => ['ezpublish_rest_']]]]; |
|
60
|
|
|
$container->prependExtensionConfig('ezpublish', $config); |
|
61
|
|
|
} |
|
62
|
|
|
} |
|
63
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: