ListScreenServiceFactory.php
2 days ago
RenderFactory.php
2 days ago
TableRenderFactory.php
2 days ago
TableRenderFactory.php
48 lines
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace AC\Table\ManageValue; |
| 6 | |
| 7 | use AC\Formatter; |
| 8 | use AC\Formatter\TableRender; |
| 9 | use AC\ListScreen; |
| 10 | use AC\TableScreen; |
| 11 | use AC\Type\ColumnId; |
| 12 | |
| 13 | class TableRenderFactory implements RenderFactory |
| 14 | { |
| 15 | private ListScreen $list_screen; |
| 16 | |
| 17 | private TableScreen $table_screen; |
| 18 | |
| 19 | public function __construct(ListScreen $list_screen) |
| 20 | { |
| 21 | $this->list_screen = $list_screen; |
| 22 | $this->table_screen = $list_screen->get_table_screen(); |
| 23 | } |
| 24 | |
| 25 | public function create(ColumnId $columnId): ?Formatter |
| 26 | { |
| 27 | $column = $this->list_screen->get_column($columnId); |
| 28 | |
| 29 | if (! $column) { |
| 30 | return null; |
| 31 | } |
| 32 | |
| 33 | $formatters = $column->get_formatters(); |
| 34 | |
| 35 | if (0 === $formatters->count()) { |
| 36 | return null; |
| 37 | } |
| 38 | |
| 39 | return new TableRender( |
| 40 | $formatters, |
| 41 | $column->get_context(), |
| 42 | $this->table_screen, |
| 43 | $this->list_screen |
| 44 | ); |
| 45 | } |
| 46 | |
| 47 | } |
| 48 |