Passed
Push — master ( 26ea1a...43abdf )
by Matthew
07:12
created

GridCompilerPass   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 19
c 1
b 0
f 0
dl 0
loc 39
ccs 0
cts 26
cp 0
rs 10
wmc 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A addLiveJobs() 0 12 3
B process() 0 17 7
1
<?php
2
3
namespace Dtc\QueueBundle\DependencyInjection\Compiler;
4
5
use Symfony\Component\DependencyInjection\ContainerBuilder;
6
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
7
8
class GridCompilerPass implements CompilerPassInterface
9
{
10
    use WorkerCompilerTrait;
11
    public function process(ContainerBuilder $container)
12
    {
13
        if (!class_exists('Dtc\GridBundle\DtcGridBundle')) {
14
            return;
15
        }
16
17
        $defaultManagerType = $container->getParameter('dtc_queue.manager.job');
18
        $runManagerType = $container->getParameter($this->getRunManagerType($container));
19
        if ($defaultManagerType === 'orm' || $runManagerType === 'orm' || $defaultManagerType === 'odm' || $runManagerType === 'odm') {
20
            $filename =__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'Resources' . DIRECTORY_SEPARATOR . 'dtc_grid.yaml';
21
            $cacheDir = $container->getParameter('kernel.cache_dir');
22
            if (class_exists('Dtc\GridBundle\Grid\Source\ColumnSource')) {
23
                \Dtc\GridBundle\Grid\Source\ColumnSource::cacheClassesFromFile($cacheDir, $filename);
0 ignored issues
show
Bug introduced by
The type Dtc\GridBundle\Grid\Source\ColumnSource was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
24
            }
25
        }
26
27
        $this->addLiveJobs($container);
28
    }
29
30
31
    /**
32
     * @param ContainerBuilder $container
33
     * @throws
34
     */
35
    protected function addLiveJobs(ContainerBuilder $container)
36
    {
37
        $jobReflection = new \ReflectionClass($container->getParameter('dtc_queue.class.job'));
38
39
        // Custom grid sources for waiting and running jobs.
40
        if ($jobReflection->isSubclassOf(\Dtc\QueueBundle\Document\BaseJob::class)) {
41
            \Dtc\GridBundle\DependencyInjection\Compiler\GridSourceCompilerPass::addGridSource($container, 'dtc_queue.grid_source.jobs_waiting.odm');
42
            \Dtc\GridBundle\DependencyInjection\Compiler\GridSourceCompilerPass::addGridSource($container, 'dtc_queue.grid_source.jobs_running.odm');
43
        }
44
        if ($jobReflection->isSubclassOf(\Dtc\QueueBundle\Entity\BaseJob::class)) {
45
            \Dtc\GridBundle\DependencyInjection\Compiler\GridSourceCompilerPass::addGridSource($container, 'dtc_queue.grid_source.jobs_waiting.orm');
46
            \Dtc\GridBundle\DependencyInjection\Compiler\GridSourceCompilerPass::addGridSource($container, 'dtc_queue.grid_source.jobs_running.orm');
47
        }
48
    }
49
50
51
}
52