Completed
Push — develop ( ff2c8c...33336f )
by René
05:02
created

OnPageCommandController::fillCacheCommand()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
rs 9.4285
cc 2
eloc 4
nc 2
nop 0
1
<?php
2
3
/**
4
 * Class OnPageCommandController
5
 */
6
7
namespace HDNET\OnpageIntegration\Command;
8
9
use HDNET\OnpageIntegration\Persister\ApiResultToCachePersister;
10
use HDNET\OnpageIntegration\Service\DataService;
11
use TYPO3\CMS\Extbase\Mvc\Controller\CommandController;
12
13
/**
14
 * Class OnPageCommandController
15
 */
16
class OnPageCommandController extends CommandController
17
{
18
19
    /**
20
     * @var DataService
21
     */
22
    protected $dataService;
23
24
    /**
25
     * @var ApiResultToCachePersister
26
     */
27
    protected $persister;
28
29
    /**
30
     * OnPageCommandController constructor.
31
     *
32
     * @param DataService               $dataService
33
     * @param ApiResultToCachePersister $persister
34
     */
35
    public function __construct(DataService $dataService, ApiResultToCachePersister $persister)
36
    {
37
        $this->dataService = $dataService;
38
        $this->persister = $persister;
39
    }
40
41
    /**
42
     * Fill the caches
43
     */
44
    public function fillCacheCommand()
45
    {
46
        $results = $this->dataService->getAllResults();
47
48
        foreach ($results as $key => $result) {
49
            $this->persister->persist($result, $key);
50
        }
51
    }
52
}
53