Completed
Pull Request — master (#1674)
by Guilh
19:29 queued 09:42
created

FOSRestExtension::loadBodyConverter()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 3.0175

Importance

Changes 0
Metric Value
dl 0
loc 12
ccs 7
cts 8
cp 0.875
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 6
nc 3
nop 3
crap 3.0175
1
<?php
2
3
/*
4
 * This file is part of the FOSRestBundle package.
5
 *
6
 * (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace FOS\RestBundle\DependencyInjection;
13
14
use Symfony\Component\Config\FileLocator;
15
use Symfony\Component\DependencyInjection\ContainerBuilder;
16
use Symfony\Component\DependencyInjection\DefinitionDecorator;
17
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
18
use Symfony\Component\DependencyInjection\Reference;
19
use Symfony\Component\Form\AbstractType;
20
use Symfony\Component\Form\Extension\Core\Type\FormType;
21
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
22
use Symfony\Component\HttpFoundation\Response;
23
24
class FOSRestExtension extends Extension
25
{
26
    /**
27
     * {@inheritdoc}
28
     */
29 1
    public function getConfiguration(array $config, ContainerBuilder $container)
30
    {
31 1
        return new Configuration($container->getParameter('kernel.debug'));
32
    }
33
34
    /**
35
     * Loads the services based on your application configuration.
36
     *
37
     * @param array            $configs
38
     * @param ContainerBuilder $container
39
     *
40
     * @throws \InvalidArgumentException
41
     * @throws \LogicException
42
     */
43 55
    public function load(array $configs, ContainerBuilder $container)
44
    {
45 55
        $configuration = new Configuration($container->getParameter('kernel.debug'));
46 55
        $config = $this->processConfiguration($configuration, $configs);
47
48 50
        $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
49 50
        $loader->load('view.xml');
50 50
        $loader->load('routing.xml');
51 50
        $loader->load('request.xml');
52 50
        $loader->load('serializer.xml');
53
54 50
        $container->getDefinition('fos_rest.routing.loader.controller')->replaceArgument(4, $config['routing_loader']['default_format']);
55 50
        $container->getDefinition('fos_rest.routing.loader.yaml_collection')->replaceArgument(4, $config['routing_loader']['default_format']);
56 50
        $container->getDefinition('fos_rest.routing.loader.xml_collection')->replaceArgument(4, $config['routing_loader']['default_format']);
57
58 50
        $container->getDefinition('fos_rest.routing.loader.yaml_collection')->replaceArgument(2, $config['routing_loader']['include_format']);
59 50
        $container->getDefinition('fos_rest.routing.loader.xml_collection')->replaceArgument(2, $config['routing_loader']['include_format']);
60 50
        $container->getDefinition('fos_rest.routing.loader.reader.action')->replaceArgument(3, $config['routing_loader']['include_format']);
61
62
        foreach ($config['service'] as $key => $service) {
63 50
            if ('validator' === $service && empty($config['body_converter']['validate'])) {
64 50
                continue;
65
            }
66 50
67 50
            if (null !== $service) {
68 50
                $container->setAlias('fos_rest.'.$key, $service);
69 50
            }
70 50
        }
71
72 50
        $this->loadForm($config, $loader, $container);
73 50
        $this->loadException($config, $loader, $container);
74 50
        $this->loadBodyConverter($config, $loader, $container);
75 50
        $this->loadView($config, $loader, $container);
76
77 50
        $this->loadBodyListener($config, $loader, $container);
78 50
        $this->loadFormatListener($config, $loader, $container);
79 50
        $this->loadVersioning($config, $loader, $container);
80 50
        $this->loadParamFetcherListener($config, $loader, $container);
81 50
        $this->loadAllowedMethodsListener($config, $loader, $container);
82 50
        $this->loadAccessDeniedListener($config, $loader, $container);
83 50
        $this->loadZoneMatcherListener($config, $loader, $container);
84
85
        // Needs RequestBodyParamConverter and View Handler loaded.
86 50
        $this->loadSerializer($config, $container);
87 50
    }
88
89 50
    private function loadForm(array $config, XmlFileLoader $loader, ContainerBuilder $container)
90
    {
91 50
        if (!empty($config['disable_csrf_role'])) {
92 1
            $loader->load('forms.xml');
93
94 1
            $definition = $container->getDefinition('fos_rest.form.extension.csrf_disable');
95 1
            $definition->replaceArgument(1, $config['disable_csrf_role']);
96
97
            // BC for Symfony < 2.8: the extended_type attribute is used on higher versions
98 1
            if (!method_exists(AbstractType::class, 'getBlockPrefix')) {
99
                $definition->addTag('form.type_extension', ['alias' => 'form']);
100
            } else {
101 1
                $definition->addTag('form.type_extension', ['extended_type' => FormType::class]);
102
            }
103 1
        }
104 50
    }
105
106 50
    private function loadAccessDeniedListener(array $config, XmlFileLoader $loader, ContainerBuilder $container)
107
    {
108 50
        if ($config['access_denied_listener']['enabled'] && !empty($config['access_denied_listener']['formats'])) {
109
            $loader->load('access_denied_listener.xml');
110
111
            $service = $container->getDefinition('fos_rest.access_denied_listener');
112
113
            if (!empty($config['access_denied_listener']['service'])) {
114
                $service->clearTag('kernel.event_subscriber');
115
            }
116
117
            $service->replaceArgument(0, $config['access_denied_listener']['formats']);
118
            $service->replaceArgument(1, $config['unauthorized_challenge']);
119
        }
120 50
    }
121
122 50 View Code Duplication
    private function loadAllowedMethodsListener(array $config, XmlFileLoader $loader, ContainerBuilder $container)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
123
    {
124 50
        if ($config['allowed_methods_listener']['enabled']) {
125 2
            if (!empty($config['allowed_methods_listener']['service'])) {
126
                $service = $container->getDefinition('fos_rest.allowed_methods_listener');
127
                $service->clearTag('kernel.event_listener');
128
            }
129
130 2
            $loader->load('allowed_methods_listener.xml');
131
132 2
            $container->getDefinition('fos_rest.allowed_methods_loader')->replaceArgument(1, $config['cache_dir']);
133 2
        }
134 50
    }
135
136 50
    private function loadBodyListener(array $config, XmlFileLoader $loader, ContainerBuilder $container)
137
    {
138 50
        if ($config['body_listener']['enabled']) {
139 49
            $loader->load('body_listener.xml');
140
141 49
            $service = $container->getDefinition('fos_rest.body_listener');
142
143 49
            if (!empty($config['body_listener']['service'])) {
144
                $service->clearTag('kernel.event_listener');
145
            }
146
147 49
            $service->replaceArgument(1, $config['body_listener']['throw_exception_on_unsupported_content_type']);
148 49
            $service->addMethodCall('setDefaultFormat', array($config['body_listener']['default_format']));
149
150 49
            $container->getDefinition('fos_rest.decoder_provider')->replaceArgument(1, $config['body_listener']['decoders']);
151
152 49
            $arrayNormalizer = $config['body_listener']['array_normalizer'];
153
154 49
            if (null !== $arrayNormalizer['service']) {
155 3
                $bodyListener = $container->getDefinition('fos_rest.body_listener');
156 3
                $bodyListener->addArgument(new Reference($arrayNormalizer['service']));
157 3
                $bodyListener->addArgument($arrayNormalizer['forms']);
158 3
            }
159 49
        }
160 50
    }
161
162 50
    private function loadFormatListener(array $config, XmlFileLoader $loader, ContainerBuilder $container)
163
    {
164 50 View Code Duplication
        if ($config['format_listener']['enabled'] && !empty($config['format_listener']['rules'])) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
165 6
            $loader->load('format_listener.xml');
166
167 6
            if (!empty($config['format_listener']['service'])) {
168
                $service = $container->getDefinition('fos_rest.format_listener');
169
                $service->clearTag('kernel.event_listener');
170
            }
171
172 6
            $container->setParameter(
173 6
                'fos_rest.format_listener.rules',
174 6
                $config['format_listener']['rules']
175 6
            );
176 6
        }
177 50
    }
178
179 50
    private function loadVersioning(array $config, XmlFileLoader $loader, ContainerBuilder $container)
180
    {
181 50
        if (!empty($config['versioning']['enabled'])) {
182 2
            $loader->load('versioning.xml');
183
184 2
            $versionListener = $container->getDefinition('fos_rest.versioning.listener');
185 2
            $versionListener->replaceArgument(2, $config['versioning']['default_version']);
186
187 2
            $resolvers = [];
188 2 View Code Duplication
            if ($config['versioning']['resolvers']['query']['enabled']) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
189 2
                $resolvers['query'] = $container->getDefinition('fos_rest.versioning.query_parameter_resolver');
190 2
                $resolvers['query']->replaceArgument(0, $config['versioning']['resolvers']['query']['parameter_name']);
191 2
            }
192 2 View Code Duplication
            if ($config['versioning']['resolvers']['custom_header']['enabled']) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
193 2
                $resolvers['custom_header'] = $container->getDefinition('fos_rest.versioning.header_resolver');
194 2
                $resolvers['custom_header']->replaceArgument(0, $config['versioning']['resolvers']['custom_header']['header_name']);
195 2
            }
196 2 View Code Duplication
            if ($config['versioning']['resolvers']['media_type']['enabled']) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
197 2
                $resolvers['media_type'] = $container->getDefinition('fos_rest.versioning.media_type_resolver');
198 2
                $resolvers['media_type']->replaceArgument(0, $config['versioning']['resolvers']['media_type']['regex']);
199 2
            }
200
201 2
            $chainResolver = $container->getDefinition('fos_rest.versioning.chain_resolver');
202 2
            foreach ($config['versioning']['guessing_order'] as $resolver) {
203 2
                if (isset($resolvers[$resolver])) {
204 2
                    $chainResolver->addMethodCall('addResolver', [$resolvers[$resolver]]);
205 2
                }
206 2
            }
207 2
        }
208 50
    }
209
210 50 View Code Duplication
    private function loadParamFetcherListener(array $config, XmlFileLoader $loader, ContainerBuilder $container)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
211
    {
212 50
        if ($config['param_fetcher_listener']['enabled']) {
213 4
            $loader->load('param_fetcher_listener.xml');
214
215 4
            if (!empty($config['param_fetcher_listener']['service'])) {
216
                $service = $container->getDefinition('fos_rest.param_fetcher_listener');
217
                $service->clearTag('kernel.event_listener');
218
            }
219
220 4
            if ($config['param_fetcher_listener']['force']) {
221 1
                $container->getDefinition('fos_rest.param_fetcher_listener')->replaceArgument(1, true);
222 1
            }
223 4
        }
224 50
    }
225
226 50
    private function loadBodyConverter(array $config, XmlFileLoader $loader, ContainerBuilder $container)
227
    {
228 50
        if (!$this->isConfigEnabled($container, $config['body_converter'])) {
229
            return;
230
        }
231
232 50
        $loader->load('request_body_param_converter.xml');
233 2
234
        if (!empty($config['body_converter']['validation_errors_argument'])) {
235 2
            $container->getDefinition('fos_rest.converter.request_body')->replaceArgument(4, $config['body_converter']['validation_errors_argument']);
236 2
        }
237 2
    }
238 2
239
    private function loadView(array $config, XmlFileLoader $loader, ContainerBuilder $container)
240 50
    {
241 2
        if (!empty($config['view']['jsonp_handler'])) {
242 2
            $handler = new DefinitionDecorator($config['service']['view_handler']);
243 50
            $handler->setPublic(true);
244
245 50
            $jsonpHandler = new Reference('fos_rest.view_handler.jsonp');
246
            $handler->addMethodCall('registerHandler', ['jsonp', [$jsonpHandler, 'createResponse']]);
247 50
            $container->setDefinition('fos_rest.view_handler', $handler);
248 1
249 1
            $container->getDefinition('fos_rest.view_handler.jsonp')->replaceArgument(0, $config['view']['jsonp_handler']['callback_param']);
250
251 1
            if (empty($config['view']['mime_types']['jsonp'])) {
252 1
                $config['view']['mime_types']['jsonp'] = $config['view']['jsonp_handler']['mime_type'];
253 1
            }
254
        }
255 1
256 View Code Duplication
        if ($config['view']['mime_types']['enabled']) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
257 1
            $loader->load('mime_type_listener.xml');
258 1
259 1
            if (!empty($config['mime_type_listener']['service'])) {
260 1
                $service = $container->getDefinition('fos_rest.mime_type_listener');
261
                $service->clearTag('kernel.event_listener');
262 50
            }
263 2
264
            $container->getDefinition('fos_rest.mime_type_listener')->replaceArgument(0, $config['view']['mime_types']['formats']);
265 2
        }
266
267 View Code Duplication
        if ($config['view']['view_response_listener']['enabled']) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
268
            $loader->load('view_response_listener.xml');
269
            $service = $container->getDefinition('fos_rest.view_response_listener');
270 2
271 2
            if (!empty($config['view_response_listener']['service'])) {
272
                $service->clearTag('kernel.event_listener');
273 50
            }
274 8
275 8
            $service->replaceArgument(1, $config['view']['view_response_listener']['force']);
276
        }
277 8
278
        $formats = [];
279 View Code Duplication
        foreach ($config['view']['formats'] as $format => $enabled) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
280
            if ($enabled) {
281 8
                $formats[$format] = false;
282 8
            }
283
        }
284 50 View Code Duplication
        foreach ($config['view']['templating_formats'] as $format => $enabled) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
285 50
            if ($enabled) {
286 50
                $formats[$format] = true;
287 50
            }
288 50
        }
289 50
290 50
        $container->getDefinition('fos_rest.routing.loader.yaml_collection')->replaceArgument(3, $formats);
291 50
        $container->getDefinition('fos_rest.routing.loader.xml_collection')->replaceArgument(3, $formats);
292 50
        $container->getDefinition('fos_rest.routing.loader.reader.action')->replaceArgument(4, $formats);
293 50
294 50
        foreach ($config['view']['force_redirects'] as $format => $code) {
295
            if (true === $code) {
296 50
                $config['view']['force_redirects'][$format] = Response::HTTP_FOUND;
297 50
            }
298 50
        }
299
300 50 View Code Duplication
        if (!is_numeric($config['view']['failed_validation'])) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
301 50
            $config['view']['failed_validation'] = constant('\Symfony\Component\HttpFoundation\Response::'.$config['view']['failed_validation']);
302 50
        }
303 50
304 50
        $defaultViewHandler = $container->getDefinition('fos_rest.view_handler.default');
305
        $defaultViewHandler->replaceArgument(4, $formats);
306 50
        $defaultViewHandler->replaceArgument(5, $config['view']['failed_validation']);
307
308 View Code Duplication
        if (!is_numeric($config['view']['empty_content'])) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
309
            $config['view']['empty_content'] = constant('\Symfony\Component\HttpFoundation\Response::'.$config['view']['empty_content']);
310 50
        }
311 50
312 50
        $defaultViewHandler->replaceArgument(6, $config['view']['empty_content']);
313
        $defaultViewHandler->replaceArgument(7, $config['view']['serialize_null']);
314 50
        $defaultViewHandler->replaceArgument(8, $config['view']['force_redirects']);
315
        $defaultViewHandler->replaceArgument(9, $config['view']['default_engine']);
316
    }
317
318 50
    private function loadException(array $config, XmlFileLoader $loader, ContainerBuilder $container)
319 50
    {
320 50
        if ($config['exception']['enabled']) {
321 50
            $loader->load('exception_listener.xml');
322 50
323
            if (!empty($config['exception']['service'])) {
324 50
                $service = $container->getDefinition('fos_rest.exception_listener');
325
                $service->clearTag('kernel.event_subscriber');
326 50
            }
327 14
328
            if ($config['exception']['exception_controller']) {
329 14
                $container->getDefinition('fos_rest.exception_listener')->replaceArgument(0, $config['exception']['exception_controller']);
330
            } elseif (isset($container->getParameter('kernel.bundles')['TwigBundle'])) {
331
                $container->getDefinition('fos_rest.exception_listener')->replaceArgument(0, 'fos_rest.exception.twig_controller:showAction');
332
            }
333
334 14
            $container->getDefinition('fos_rest.exception.codes_map')
335
                ->replaceArgument(0, $config['exception']['codes']);
336 14
            $container->getDefinition('fos_rest.exception.messages_map')
337 4
                ->replaceArgument(0, $config['exception']['messages']);
338 4
339
            $container->getDefinition('fos_rest.exception.controller')
340 14
                ->replaceArgument(2, $config['exception']['debug']);
341 14
            $container->getDefinition('fos_rest.serializer.exception_normalizer.jms')
342 14
                ->replaceArgument(1, $config['exception']['debug']);
343 14
            $container->getDefinition('fos_rest.serializer.exception_normalizer.symfony')
344
                ->replaceArgument(1, $config['exception']['debug']);
345 14
        }
346 14
    }
347 14
348 14
    private function loadSerializer(array $config, ContainerBuilder $container)
349 14
    {
350 14
        $bodyConverter = $container->hasDefinition('fos_rest.converter.request_body') ? $container->getDefinition('fos_rest.converter.request_body') : null;
351 14
        $viewHandler = $container->getDefinition('fos_rest.view_handler.default');
352 50
353 View Code Duplication
        if (!empty($config['serializer']['version'])) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
354 50
            if ($bodyConverter) {
355
                $bodyConverter->replaceArgument(2, $config['serializer']['version']);
356 50
            }
357 50
            $viewHandler->addMethodCall('setExclusionStrategyVersion', array($config['serializer']['version']));
358
        }
359 50
360 1 View Code Duplication
        if (!empty($config['serializer']['groups'])) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
361
            if ($bodyConverter) {
362
                $bodyConverter->replaceArgument(1, $config['serializer']['groups']);
363 1
            }
364 1
            $viewHandler->addMethodCall('setExclusionStrategyGroups', array($config['serializer']['groups']));
365
        }
366 50
367 1
        $viewHandler->addMethodCall('setSerializeNullStrategy', array($config['serializer']['serialize_null']));
368
    }
369
370 1
    private function loadZoneMatcherListener(array $config, XmlFileLoader $loader, ContainerBuilder $container)
371 1
    {
372
        if (!empty($config['zone'])) {
373 50
            $loader->load('zone_matcher_listener.xml');
374 50
            $zoneMatcherListener = $container->getDefinition('fos_rest.zone_matcher_listener');
375
376 50
            foreach ($config['zone'] as $zone) {
377
                $matcher = $this->createZoneRequestMatcher($container,
378 50
                    $zone['path'],
379 2
                    $zone['host'],
380 2
                    $zone['methods'],
381
                    $zone['ips']
382 2
                );
383 2
384 2
                $zoneMatcherListener->addMethodCall('addRequestMatcher', array($matcher));
385 2
            }
386 2
        }
387 2
    }
388 2
389
    private function createZoneRequestMatcher(ContainerBuilder $container, $path = null, $host = null, $methods = array(), $ip = null)
390 2
    {
391 2
        if ($methods) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $methods of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
392 2
            $methods = array_map('strtoupper', (array) $methods);
393 50
        }
394
395 2
        $serialized = serialize(array($path, $host, $methods, $ip));
396
        $id = 'fos_rest.zone_request_matcher.'.md5($serialized).sha1($serialized);
397 2
398
        // only add arguments that are necessary
399
        $arguments = array($path, $host, $methods, $ip);
400
        while (count($arguments) > 0 && !end($arguments)) {
401 2
            array_pop($arguments);
402 2
        }
403
404
        $container
405 2
            ->setDefinition($id, new DefinitionDecorator('fos_rest.zone_request_matcher'))
406 2
            ->setArguments($arguments)
407 2
        ;
408 2
409
        return new Reference($id);
410
    }
411
}
412