Completed
Pull Request — master (#29)
by Daniel
02:17
created

SelectColumn::createHeader()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 2
1
<?php
2
3
namespace Psi\Component\Grid\Column;
4
5
use Psi\Component\Grid\CellInterface;
6
use Psi\Component\Grid\ColumnInterface;
7
use Psi\Component\Grid\GridContext;
8
use Psi\Component\Grid\RowData;
9
use Psi\Component\Grid\View\Cell as Cell;
10
use Psi\Component\Grid\View\Header;
11
use Psi\Component\ObjectAgent\AgentFinder;
12
use Symfony\Component\OptionsResolver\OptionsResolver;
13
14
class SelectColumn implements ColumnInterface
15
{
16
    private $agentFinder;
17
18
    public function __construct(AgentFinder $agentFinder)
19
    {
20
        $this->agentFinder = $agentFinder;
21
    }
22
23
    public function createCell(RowData $data, array $options): CellInterface
24
    {
25
        // TODO: This is inefficient and will not work for proxies ...
26
        $agent = $this->agentFinder->findFor(get_class($data->getObject()));
27
28
        return new Cell\SelectCell($agent->getIdentifier($data->getObject()));
29
    }
30
31
    public function createHeader(GridContext $context, array $options)
32
    {
33
        return new Header($context, $options['column_name']);
34
    }
35
36
    public function configureOptions(OptionsResolver $options)
37
    {
38
    }
39
}
40