ListWorker::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace FSi\Bundle\AdminBundle\Factory\Worker;
6
7
use FSi\Bundle\AdminBundle\Admin\CRUD\ListElement;
8
use FSi\Bundle\AdminBundle\Admin\Element;
9
use FSi\Bundle\AdminBundle\Factory\Worker;
10
use FSi\Component\DataGrid\DataGridFactoryInterface;
11
use FSi\Component\DataSource\DataSourceFactoryInterface;
12
13
class ListWorker implements Worker
14
{
15
    /**
16
     * @var DataSourceFactoryInterface
17
     */
18
    private $dataSourceFactory;
19
20
    /**
21
     * @var DataGridFactoryInterface
22
     */
23
    private $dataGridFactory;
24
25
    public function __construct(
26
        DataSourceFactoryInterface $dataSourceFactory,
27
        DataGridFactoryInterface $dataGridFactory
28
    ) {
29
        $this->dataSourceFactory = $dataSourceFactory;
30
        $this->dataGridFactory = $dataGridFactory;
31
    }
32
33
    public function mount(Element $element): void
34
    {
35
        if ($element instanceof ListElement) {
36
            $element->setDataSourceFactory($this->dataSourceFactory);
37
            $element->setDataGridFactory($this->dataGridFactory);
38
        }
39
    }
40
}
41