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
Base.php
97 lines
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace AC\Column; |
| 6 | |
| 7 | use AC\Column; |
| 8 | use AC\FormatterCollection; |
| 9 | use AC\Setting\Component; |
| 10 | use AC\Setting\ComponentCollection; |
| 11 | use AC\Type\ColumnId; |
| 12 | |
| 13 | class Base implements Column |
| 14 | { |
| 15 | |
| 16 | protected string $type; |
| 17 | |
| 18 | protected string $label; |
| 19 | |
| 20 | protected ComponentCollection $settings; |
| 21 | |
| 22 | private ColumnId $id; |
| 23 | |
| 24 | private Context $context; |
| 25 | |
| 26 | private FormatterCollection $formatters; |
| 27 | |
| 28 | protected string $group; |
| 29 | |
| 30 | protected ?string $description; |
| 31 | |
| 32 | public function __construct( |
| 33 | string $type, |
| 34 | string $label, |
| 35 | ComponentCollection $settings, |
| 36 | ColumnId $id, |
| 37 | Context $context, |
| 38 | ?FormatterCollection $formatters = null, |
| 39 | ?string $group = null, |
| 40 | ?string $description = null |
| 41 | ) { |
| 42 | $this->type = $type; |
| 43 | $this->label = $label; |
| 44 | $this->settings = $settings; |
| 45 | $this->context = $context; |
| 46 | $this->id = $id; |
| 47 | $this->formatters = $formatters ?? new FormatterCollection(); |
| 48 | $this->group = $group ?? 'custom'; |
| 49 | $this->description = $description; |
| 50 | } |
| 51 | |
| 52 | public function get_type(): string |
| 53 | { |
| 54 | return $this->type; |
| 55 | } |
| 56 | |
| 57 | public function get_id(): ColumnId |
| 58 | { |
| 59 | return $this->id; |
| 60 | } |
| 61 | |
| 62 | public function get_label(): string |
| 63 | { |
| 64 | return $this->label; |
| 65 | } |
| 66 | |
| 67 | public function get_group(): string |
| 68 | { |
| 69 | return $this->group; |
| 70 | } |
| 71 | |
| 72 | public function get_description(): ?string |
| 73 | { |
| 74 | return $this->description; |
| 75 | } |
| 76 | |
| 77 | public function get_settings(): ComponentCollection |
| 78 | { |
| 79 | return $this->settings; |
| 80 | } |
| 81 | |
| 82 | public function get_formatters(): FormatterCollection |
| 83 | { |
| 84 | return $this->formatters; |
| 85 | } |
| 86 | |
| 87 | public function get_setting(string $name): ?Component |
| 88 | { |
| 89 | return $this->settings->find($name); |
| 90 | } |
| 91 | |
| 92 | public function get_context(): Context |
| 93 | { |
| 94 | return $this->context; |
| 95 | } |
| 96 | |
| 97 | } |