Base.php
3 months ago
BaseColumnFactory.php
3 months ago
ColumnFactory.php
3 months ago
ColumnIdGenerator.php
3 months ago
ColumnLabelTrait.php
3 months ago
Context.php
3 months ago
CustomFieldContext.php
3 months ago
GroupTrait.php
3 months ago
LabelEncoder.php
3 months ago
SettingUpdater.php
3 months ago
ColumnFactory.php
54 lines
| 1 | <?php |
| 2 | |
| 3 | namespace AC\Column; |
| 4 | |
| 5 | use AC\Column; |
| 6 | use AC\FormatterCollection; |
| 7 | use AC\Setting\ComponentCollection; |
| 8 | use AC\Setting\Config; |
| 9 | |
| 10 | abstract class ColumnFactory |
| 11 | { |
| 12 | |
| 13 | abstract public function create(Config $config): Column; |
| 14 | |
| 15 | abstract public function get_column_type(): string; |
| 16 | |
| 17 | abstract public function get_label(): string; |
| 18 | |
| 19 | public function get_description(): ?string |
| 20 | { |
| 21 | return null; |
| 22 | } |
| 23 | |
| 24 | protected function get_settings(Config $config): ComponentCollection |
| 25 | { |
| 26 | return new ComponentCollection(); |
| 27 | } |
| 28 | |
| 29 | protected function get_context(Config $config): Context |
| 30 | { |
| 31 | return new Context($config, $this->get_label()); |
| 32 | } |
| 33 | |
| 34 | protected function get_formatters(Config $config): FormatterCollection |
| 35 | { |
| 36 | return $this->get_formatters_from_settings( |
| 37 | $this->get_settings($config) |
| 38 | ); |
| 39 | } |
| 40 | |
| 41 | private function get_formatters_from_settings(ComponentCollection $settings): FormatterCollection |
| 42 | { |
| 43 | $formatters = new FormatterCollection(); |
| 44 | |
| 45 | foreach ($settings as $setting) { |
| 46 | foreach ($setting->get_formatters() as $formatter) { |
| 47 | $formatters->add($formatter); |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | return $formatters; |
| 52 | } |
| 53 | |
| 54 | } |