1 | <?php |
||
21 | class ShowBuilder implements ShowBuilderInterface |
||
22 | { |
||
23 | /** |
||
24 | * @var TypeGuesserInterface |
||
25 | */ |
||
26 | protected $guesser; |
||
27 | |||
28 | /** |
||
29 | * @var string[] |
||
30 | */ |
||
31 | protected $templates; |
||
32 | |||
33 | /** |
||
34 | * @param TypeGuesserInterface $guesser |
||
35 | * @param string[] $templates |
||
36 | */ |
||
37 | public function __construct(TypeGuesserInterface $guesser, array $templates) |
||
38 | { |
||
39 | $this->guesser = $guesser; |
||
40 | $this->templates = $templates; |
||
41 | } |
||
42 | |||
43 | /** |
||
44 | * {@inheritdoc} |
||
45 | */ |
||
46 | public function getBaseList(array $options = array()) |
||
50 | |||
51 | /** |
||
52 | * {@inheritdoc} |
||
53 | */ |
||
54 | public function addField(FieldDescriptionCollection $list, $type, FieldDescriptionInterface $fieldDescription, AdminInterface $admin) |
||
55 | { |
||
56 | if ($type == null) { |
||
|
|||
57 | $guessType = $this->guesser->guessType($admin->getClass(), $fieldDescription->getName(), $admin->getModelManager()); |
||
58 | $fieldDescription->setType($guessType->getType()); |
||
59 | } else { |
||
60 | $fieldDescription->setType($type); |
||
61 | } |
||
62 | |||
63 | $this->fixFieldDescription($admin, $fieldDescription); |
||
64 | $admin->addShowFieldDescription($fieldDescription->getName(), $fieldDescription); |
||
65 | |||
66 | $list->add($fieldDescription); |
||
67 | } |
||
68 | |||
69 | /** |
||
70 | * {@inheritdoc} |
||
71 | */ |
||
72 | public function fixFieldDescription(AdminInterface $admin, FieldDescriptionInterface $fieldDescription) |
||
128 | |||
129 | /** |
||
130 | * @param string $type |
||
131 | * |
||
132 | * @return string |
||
133 | */ |
||
134 | private function getTemplate($type) |
||
142 | } |
||
143 |