ParserCompilerPass::process()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 18
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 18
rs 9.2
c 0
b 0
f 0
cc 4
eloc 10
nc 4
nop 1
1
<?php
2
3
/*
4
 * This file is part of the Stinger Media Parser package.
5
*
6
* (c) Oliver Kotte <[email protected]>
7
* (c) Florian Meyer <[email protected]>
8
*
9
* For the full copyright and license information, please view the LICENSE
10
* file that was distributed with this source code.
11
*/
12
13
namespace StingerSoft\MediaParsingBundle\Parser;
14
15
use Symfony\Component\DependencyInjection\ContainerBuilder;
16
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
17
use Symfony\Component\DependencyInjection\Reference;
18
19
class ParserCompilerPass implements CompilerPassInterface {
20
	/**
21
	 * Searches for all Audio Parsers that are tagged as 'stinger_soft.audioparser' inside all services.yml files
22
	 * @see Symfony\Component\DependencyInjection\Compiler.CompilerPassInterface::process()
23
	 */
24
	public function process(ContainerBuilder $container){
25
		if (!$container->hasDefinition(ParserChainInterface::SERVICE_ID)) {
26
			return;
27
		}
28
		
29
		$definition = $container->getDefinition(ParserChainInterface::SERVICE_ID);
30
31
		$taggedServices = $container->findTaggedServiceIds(MediaParserInterface::SERVICE_TAG);
32
		
33
		foreach ($taggedServices as $id => $tagAttributes) {
34
			foreach ($tagAttributes as $attributes) {
35
				$definition->addMethodCall(
36
						'addParser',
37
						array(new Reference($id))
38
				);
39
			}
40
		}
41
	}
42
}
43