Completed
Pull Request — 2.0 (#1105)
by
unknown
07:06 queued 04:41
created

DriverCompilerPass::process()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 10
rs 9.9332
cc 2
nc 2
nop 1
1
<?php
2
3
/*
4
 * This file is part of the `liip/LiipImagineBundle` project.
5
 *
6
 * (c) https://github.com/liip/LiipImagineBundle/graphs/contributors
7
 *
8
 * For the full copyright and license information, please view the LICENSE.md
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Liip\ImagineBundle\DependencyInjection\Compiler;
13
14
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
15
use Symfony\Component\DependencyInjection\ContainerBuilder;
16
17
/**
18
 * Give a helpful exception message in case the imagine driver does not exist.
19
 *
20
 * Third parties can provide a driver, and thus we can only validate after the container has been built.
21
 */
22
class DriverCompilerPass extends AbstractCompilerPass
23
{
24
    /**
25
     * {@inheritdoc}
26
     */
27
    public function process(ContainerBuilder $container)
28
    {
29
        $liipImagineDriver = $container->getParameter('liip_imagine.driver_service');
30
31
        if (!$container->hasDefinition($liipImagineDriver)) {
32
            throw new InvalidConfigurationException(sprintf(
33
                "Specified driver '%s' is not defined.", $liipImagineDriver
34
            ));
35
        }
36
    }
37
}
38