GenerateThemeCacheDispatcher::dispatch()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 7
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 12
ccs 0
cts 7
cp 0
crap 6
rs 10
1
<?php
2
3
namespace Deployee\Plugins\ShopwareTasks\Dispatcher;
4
5
use Deployee\Plugins\Deploy\Definitions\Tasks\TaskDefinitionInterface;
6
use Deployee\Plugins\Deploy\Dispatcher\AbstractTaskDefinitionDispatcher;
7
use Deployee\Plugins\Deploy\Dispatcher\DispatchResultInterface;
8
use Deployee\Plugins\ShopwareTasks\Definitions\GenerateThemeCacheDefinition;
9
use Deployee\Plugins\ShopwareTasks\Definitions\ShopwareCommandDefinition;
10
11
class GenerateThemeCacheDispatcher extends AbstractTaskDefinitionDispatcher
12
{
13
    /**
14
     * @param TaskDefinitionInterface $taskDefinition
15
     * @return bool
16
     */
17
    public function canDispatchTaskDefinition(TaskDefinitionInterface $taskDefinition): bool
18
    {
19
        return $taskDefinition instanceof GenerateThemeCacheDefinition;
20
    }
21
22
    /**
23
     * @param TaskDefinitionInterface $taskDefinition
24
     * @return DispatchResultInterface
25
     * @throws \Deployee\Plugins\Deploy\Exception\DispatcherException
26
     */
27
    public function dispatch(TaskDefinitionInterface $taskDefinition): DispatchResultInterface
28
    {
29
        $parameter = $taskDefinition->define();
30
        $shopIds = $parameter->get('shopId');
31
32
        $arguments = '';
33
        foreach($shopIds as $shopId){
34
            $arguments .= ' --shopId=' . $shopId;
35
        }
36
37
        return $this->delegate(
38
            new ShopwareCommandDefinition('theme:compile', '-n ' . $arguments)
39
        );
40
    }
41
}