Passed
Push — master ( 4d8734...991786 )
by Matthew
09:35 queued 06:44
created

ControllerTrait::addCssJs()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 1
dl 0
loc 7
ccs 6
cts 6
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Dtc\QueueBundle\Controller;
4
5
use Dtc\QueueBundle\Exception\UnsupportedException;
6
7
trait ControllerTrait
8
{
9 1
    protected function validateJobTimingManager()
10
    {
11 1
        if ($this->container->hasParameter('dtc_queue.manager.job_timing')) {
12
            $this->validateManagerType('dtc_queue.manager.job_timing');
13 1
        } elseif ($this->container->hasParameter('dtc_queue.manager.job_timing')) {
14
            $this->validateManagerType('dtc_queue.manager.run');
15
        } else {
16 1
            $this->validateManagerType('dtc_queue.manager.job');
17
        }
18 1
    }
19
20 1
    protected function validateRunManager()
21
    {
22 1
        if ($this->container->hasParameter('dtc_queue.manager.job_timing')) {
23
            $this->validateManagerType('dtc_queue.manager.run');
24
        } else {
25 1
            $this->validateManagerType('dtc_queue.manager.job');
26
        }
27 1
    }
28
29
    /**
30
     * @param string $type
31
     */
32 5
    protected function validateManagerType($type)
33
    {
34 5
        $managerType = $this->container->getParameter($type);
35 5
        if ('mongodb' !== $managerType && 'orm' != $managerType && 'odm' != $managerType) {
36
            throw new UnsupportedException("Unsupported manager type: $managerType");
37
        }
38 5
    }
39
40 7
    protected function addCssJs(array &$params)
41
    {
42 7
        $params['css'] = $this->container->getParameter('dtc_grid.theme.css');
43 7
        $params['js'] = $this->container->getParameter('dtc_grid.theme.js');
44 7
        $jQuery = $this->container->getParameter('dtc_grid.jquery');
45 7
        array_unshift($params['js'], $jQuery['url']);
46 7
        $params['chartjs'] = $this->container->getParameter('dtc_queue.admin.chartjs');
47 7
    }
48
}
49