AuthorSlugFactory.php
3 months ago
CommentCountFactory.php
3 months ago
DescriptionFactory.php
3 months ago
DisplayNameFactory.php
3 months ago
FirstNameFactory.php
3 months ago
FirstPostFactory.php
3 months ago
FullNameFactory.php
3 months ago
LastNameFactory.php
3 months ago
LastPostFactory.php
3 months ago
NicknameFactory.php
3 months ago
PostCountFactory.php
3 months ago
RegisteredDateFactory.php
3 months ago
ShowToolbarFactory.php
3 months ago
UserIdFactory.php
3 months ago
UserNameFactory.php
3 months ago
UserUrlFactory.php
3 months ago
VisualEditingFactory.php
3 months ago
RegisteredDateFactory.php
56 lines
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace AC\ColumnFactory\User; |
| 6 | |
| 7 | use AC; |
| 8 | use AC\Column\BaseColumnFactory; |
| 9 | use AC\FormatterCollection; |
| 10 | use AC\Setting\ComponentCollection; |
| 11 | use AC\Setting\ComponentFactory\DateFormat\Date; |
| 12 | use AC\Setting\Config; |
| 13 | use AC\Setting\DefaultSettingsBuilder; |
| 14 | |
| 15 | class RegisteredDateFactory extends BaseColumnFactory |
| 16 | { |
| 17 | |
| 18 | private Date $date_format; |
| 19 | |
| 20 | public function __construct( |
| 21 | DefaultSettingsBuilder $default_settings_builder, |
| 22 | Date $date_format |
| 23 | ) { |
| 24 | parent::__construct($default_settings_builder); |
| 25 | |
| 26 | $this->date_format = $date_format; |
| 27 | } |
| 28 | |
| 29 | public function get_label(): string |
| 30 | { |
| 31 | return __('Registered', 'codepress-admin-columns'); |
| 32 | } |
| 33 | |
| 34 | public function get_column_type(): string |
| 35 | { |
| 36 | return 'column-user_registered'; |
| 37 | } |
| 38 | |
| 39 | protected function get_formatters(Config $config): FormatterCollection |
| 40 | { |
| 41 | $formatters = new FormatterCollection([ |
| 42 | new AC\Formatter\User\Property('user_registered'), |
| 43 | new AC\Formatter\Date\Timestamp(), |
| 44 | ]); |
| 45 | |
| 46 | return $formatters->merge(parent::get_formatters($config)); |
| 47 | } |
| 48 | |
| 49 | protected function get_settings(Config $config): ComponentCollection |
| 50 | { |
| 51 | return new ComponentCollection([ |
| 52 | $this->date_format->create($config), |
| 53 | ]); |
| 54 | } |
| 55 | |
| 56 | } |