Completed
Pull Request — master (#49)
by Daniel
08:41
created

SelectColumn::createCell()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Psi\Component\Grid\Column;
6
7
use Psi\Component\Grid\CellInterface;
8
use Psi\Component\Grid\ColumnInterface;
9
use Psi\Component\Grid\GridContext;
10
use Psi\Component\Grid\View\Cell;
11
use Psi\Component\Grid\View\Header;
12
use Psi\Component\ObjectAgent\AgentFinder;
13
use Symfony\Component\OptionsResolver\OptionsResolver;
14
15
class SelectColumn implements ColumnInterface
16
{
17
    const INPUT_NAME = '_select';
18
19
    private $agentFinder;
20
21
    public function __construct(AgentFinder $agentFinder)
22
    {
23
        $this->agentFinder = $agentFinder;
24
    }
25
26
    public function buildCell(Cell $cell, array $options)
27
    {
28
        $cell->template = 'Select';
29
30
        // TODO: maybe use the property accessor here instead? and default to the property "id".
31
        $agent = $this->agentFinder->findFor(get_class($cell->context));
32
33
        $cell->value = $agent->getIdentifier($cell->context);
34
    }
35
36
    public function configureOptions(OptionsResolver $options)
37
    {
38
        $options->setDefault('property', null);
39
    }
40
41
    public function getParent()
42
    {
43
    }
44
}
45