GridCompilerPass   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 10
eloc 27
c 1
b 0
f 0
dl 0
loc 46
ccs 0
cts 29
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A addLiveJobs() 0 12 3
B process() 0 25 7
1
<?php
2
3
namespace Dtc\QueueBundle\DependencyInjection\Compiler;
4
5
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Depend...r\CompilerPassInterface 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...
6
use Symfony\Component\DependencyInjection\ContainerBuilder;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Depend...ection\ContainerBuilder 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...
7
8
class GridCompilerPass implements CompilerPassInterface
9
{
10
    use WorkerCompilerTrait;
11
12
    public function process(ContainerBuilder $container): void
13
    {
14
        if (!class_exists('Dtc\GridBundle\DtcGridBundle')) {
15
            $container->getDefinition('dtc_queue.grid_source.jobs_waiting.odm')->setClass('Dtc\QueueBundle\ODM\StubLiveJobsGridSource');
16
            $container->getDefinition('dtc_queue.grid_source.jobs_waiting.orm')->setClass('Dtc\QueueBundle\ORM\StubLiveJobsGridSource');
17
            $container->getDefinition('dtc_queue.grid_source.jobs_running.odm')->setClass('Dtc\QueueBundle\ODM\StubLiveJobsGridSource');
18
            $container->getDefinition('dtc_queue.grid_source.jobs_running.orm')->setClass('Dtc\QueueBundle\ORM\StubLiveJobsGridSource');
19
20
            return;
21
        }
22
        $container->getDefinition('dtc_queue.grid_source.jobs_waiting.odm')->setClass('Dtc\QueueBundle\ODM\LiveJobsGridSource');
23
        $container->getDefinition('dtc_queue.grid_source.jobs_waiting.orm')->setClass('Dtc\QueueBundle\ORM\LiveJobsGridSource');
24
        $container->getDefinition('dtc_queue.grid_source.jobs_running.odm')->setClass('Dtc\QueueBundle\ODM\LiveJobsGridSource');
25
        $container->getDefinition('dtc_queue.grid_source.jobs_running.orm')->setClass('Dtc\QueueBundle\ORM\LiveJobsGridSource');
26
        $defaultManagerType = $container->getParameter('dtc_queue.manager.job');
27
        $runManagerType = $container->getParameter($this->getRunManagerType($container));
28
        if ('orm' === $defaultManagerType || 'orm' === $runManagerType || 'odm' === $defaultManagerType || 'odm' === $runManagerType) {
29
            $filename = __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'Resources'.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'dtc_grid.yaml';
30
            $cacheDir = $container->getParameter('kernel.cache_dir');
31
            if (class_exists('Dtc\GridBundle\Util\ColumnUtil')) {
32
                \Dtc\GridBundle\Util\ColumnUtil::cacheClassesFromFile($cacheDir, $filename);
0 ignored issues
show
Bug introduced by
The type Dtc\GridBundle\Util\ColumnUtil 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...
33
            }
34
        }
35
36
        $this->addLiveJobs($container);
37
    }
38
39
    /**
40
     * @throws
41
     */
42
    protected function addLiveJobs(ContainerBuilder $container)
43
    {
44
        $jobReflection = new \ReflectionClass($container->getParameter('dtc_queue.class.job'));
45
46
        // Custom grid sources for waiting and running jobs.
47
        if ($jobReflection->isSubclassOf(\Dtc\QueueBundle\Document\BaseJob::class)) {
48
            \Dtc\GridBundle\DependencyInjection\Compiler\GridSourceCompilerPass::addGridSource($container, 'dtc_queue.grid_source.jobs_waiting.odm');
0 ignored issues
show
Bug introduced by
The type Dtc\GridBundle\Dependenc...\GridSourceCompilerPass 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...
49
            \Dtc\GridBundle\DependencyInjection\Compiler\GridSourceCompilerPass::addGridSource($container, 'dtc_queue.grid_source.jobs_running.odm');
50
        }
51
        if ($jobReflection->isSubclassOf(\Dtc\QueueBundle\Entity\BaseJob::class)) {
52
            \Dtc\GridBundle\DependencyInjection\Compiler\GridSourceCompilerPass::addGridSource($container, 'dtc_queue.grid_source.jobs_waiting.orm');
53
            \Dtc\GridBundle\DependencyInjection\Compiler\GridSourceCompilerPass::addGridSource($container, 'dtc_queue.grid_source.jobs_running.orm');
54
        }
55
    }
56
}
57