Columns.php
132 lines
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace AC\Admin\Page; |
| 6 | |
| 7 | use AC\Admin; |
| 8 | use AC\Admin\Banner\BannerContextResolver; |
| 9 | use AC\Admin\RenderableHead; |
| 10 | use AC\AdminColumns; |
| 11 | use AC\Asset\Assets; |
| 12 | use AC\Asset\Enqueueables; |
| 13 | use AC\Asset\Location; |
| 14 | use AC\Asset\Script; |
| 15 | use AC\Asset\Style; |
| 16 | use AC\ColumnGroups; |
| 17 | use AC\Integration\IntegrationRepository; |
| 18 | use AC\Promo\PromoRepository; |
| 19 | use AC\Renderable; |
| 20 | use AC\Storage\Repository\EditorFavorites; |
| 21 | use AC\Table\TableScreenCollection; |
| 22 | use AC\Table\TableScreenRepository; |
| 23 | use AC\TableScreen; |
| 24 | use AC\Type\ListScreenId; |
| 25 | |
| 26 | class Columns implements Enqueueables, Renderable, RenderableHead |
| 27 | { |
| 28 | public const NAME = 'columns'; |
| 29 | |
| 30 | private Location $location; |
| 31 | |
| 32 | private Renderable $head; |
| 33 | |
| 34 | private TableScreen $table_screen; |
| 35 | |
| 36 | private Admin\MenuListItems $menu_items; |
| 37 | |
| 38 | private EditorFavorites $favorite_repository; |
| 39 | |
| 40 | private TableScreenRepository $table_screen_repository; |
| 41 | |
| 42 | private TableScreenCollection $uninitialized_screens; |
| 43 | |
| 44 | private ColumnGroups $column_groups; |
| 45 | |
| 46 | private PromoRepository $promos; |
| 47 | |
| 48 | private IntegrationRepository $integration_repository; |
| 49 | |
| 50 | private bool $is_pro_active; |
| 51 | |
| 52 | private ?ListScreenId $list_id; |
| 53 | |
| 54 | private BannerContextResolver $banner_context_resolver; |
| 55 | |
| 56 | public function __construct( |
| 57 | AdminColumns $plugin, |
| 58 | TableScreenCollection $uninitialized_screens, |
| 59 | Renderable $head, |
| 60 | TableScreen $table_screen, |
| 61 | Admin\MenuListItems $menu_items, |
| 62 | EditorFavorites $favorite_repository, |
| 63 | TableScreenRepository $table_screen_repository, |
| 64 | ColumnGroups $column_groups, |
| 65 | PromoRepository $promos, |
| 66 | IntegrationRepository $integration_repository, |
| 67 | bool $is_pro_active, |
| 68 | BannerContextResolver $banner_context_resolver, |
| 69 | ?ListScreenId $list_id = null |
| 70 | ) { |
| 71 | $this->location = $plugin->get_location(); |
| 72 | $this->head = $head; |
| 73 | $this->table_screen = $table_screen; |
| 74 | $this->menu_items = $menu_items; |
| 75 | $this->favorite_repository = $favorite_repository; |
| 76 | $this->table_screen_repository = $table_screen_repository; |
| 77 | $this->uninitialized_screens = $uninitialized_screens; |
| 78 | $this->column_groups = $column_groups; |
| 79 | $this->promos = $promos; |
| 80 | $this->integration_repository = $integration_repository; |
| 81 | $this->is_pro_active = $is_pro_active; |
| 82 | $this->banner_context_resolver = $banner_context_resolver; |
| 83 | $this->list_id = $list_id; |
| 84 | } |
| 85 | |
| 86 | public function get_table_screen(): TableScreen |
| 87 | { |
| 88 | return $this->table_screen; |
| 89 | } |
| 90 | |
| 91 | public function render_head(): Renderable |
| 92 | { |
| 93 | return $this->head; |
| 94 | } |
| 95 | |
| 96 | public function get_assets(): Assets |
| 97 | { |
| 98 | return new Assets([ |
| 99 | new Script('jquery-ui-slider'), |
| 100 | new Admin\Asset\Columns( |
| 101 | 'ac-admin-page-columns', |
| 102 | $this->location->with_suffix('assets/js/admin-page-columns.js'), |
| 103 | $this->table_screen, |
| 104 | $this->uninitialized_screens, |
| 105 | $this->menu_items, |
| 106 | $this->table_screen_repository, |
| 107 | $this->favorite_repository, |
| 108 | $this->column_groups, |
| 109 | $this->promos, |
| 110 | $this->integration_repository, |
| 111 | $this->location, |
| 112 | $this->is_pro_active, |
| 113 | $this->banner_context_resolver, |
| 114 | $this->list_id |
| 115 | ), |
| 116 | new Style( |
| 117 | 'ac-admin-page-columns-css', |
| 118 | $this->location->with_suffix('assets/css/admin-page-columns.css'), |
| 119 | ['ac-utilities'] |
| 120 | ), |
| 121 | new Style('ac-select2'), |
| 122 | new Script('ac-select2'), |
| 123 | ]); |
| 124 | } |
| 125 | |
| 126 | public function render(): string |
| 127 | { |
| 128 | return (string)apply_filters('ac/page/columns/render', '<div></div>', $this->list_id); |
| 129 | } |
| 130 | |
| 131 | } |
| 132 |