AgentFactory.php
3 months ago
ApprovedFactory.php
3 months ago
AuthorAvatarFactory.php
3 months ago
AuthorEmailFactory.php
3 months ago
AuthorIpFactory.php
3 months ago
AuthorNameFactory.php
3 months ago
AuthorUrlFactory.php
3 months ago
CommentTypeFactory.php
3 months ago
DateGmtFactory.php
3 months ago
ExcerptFactory.php
3 months ago
IdFactory.php
3 months ago
PostFactory.php
3 months ago
ReplyToFactory.php
3 months ago
StatusFactory.php
3 months ago
UserFactory.php
3 months ago
WordCountFactory.php
3 months ago
UserFactory.php
59 lines
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace AC\ColumnFactory\Comment; |
| 6 | |
| 7 | use AC\Column\BaseColumnFactory; |
| 8 | use AC\Formatter\Comment\UserId; |
| 9 | use AC\FormatterCollection; |
| 10 | use AC\Setting\ComponentCollection; |
| 11 | use AC\Setting\ComponentFactory\UserLink; |
| 12 | use AC\Setting\ComponentFactory\UserProperty; |
| 13 | use AC\Setting\Config; |
| 14 | use AC\Setting\DefaultSettingsBuilder; |
| 15 | |
| 16 | class UserFactory extends BaseColumnFactory |
| 17 | { |
| 18 | |
| 19 | private UserProperty $user_property; |
| 20 | |
| 21 | private UserLink $user_link; |
| 22 | |
| 23 | public function __construct( |
| 24 | DefaultSettingsBuilder $default_settings_builder, |
| 25 | UserProperty $user_property, |
| 26 | UserLink $user_link |
| 27 | ) { |
| 28 | parent::__construct($default_settings_builder); |
| 29 | |
| 30 | $this->user_property = $user_property; |
| 31 | $this->user_link = $user_link; |
| 32 | } |
| 33 | |
| 34 | protected function get_settings(Config $config): ComponentCollection |
| 35 | { |
| 36 | return new ComponentCollection([ |
| 37 | $this->user_property->create($config), |
| 38 | $this->user_link->create($config), |
| 39 | ]); |
| 40 | } |
| 41 | |
| 42 | public function get_label(): string |
| 43 | { |
| 44 | return __('User', 'codepress-admin-columns'); |
| 45 | } |
| 46 | |
| 47 | public function get_column_type(): string |
| 48 | { |
| 49 | return 'column-user'; |
| 50 | } |
| 51 | |
| 52 | protected function get_formatters(Config $config): FormatterCollection |
| 53 | { |
| 54 | $formatters = parent::get_formatters($config); |
| 55 | $formatters->prepend(new UserId()); |
| 56 | |
| 57 | return $formatters; |
| 58 | } |
| 59 | } |