PluginProbe
Remove Schema / trunk
Remove Schema vtrunk
2.0.0 trunk 1.6.1 1.6.2
remove-schema / src / class-plugin.php

class-plugin.php in Remove Schema trunk, at src/class-plugin.php

84 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Main plugin runtime.
4 *
5 * @package TimVanIersel\RemoveSchema
6 */
7
8 declare(strict_types=1);
9
10 namespace TimVanIersel\RemoveSchema;
11
12 use TimVanIersel\RemoveSchema\Admin\AdminAssets;
13 use TimVanIersel\RemoveSchema\Admin\PostEditor;
14 use TimVanIersel\RemoveSchema\Admin\SettingsPage;
15 use TimVanIersel\RemoveSchema\Contracts\Service;
16 use TimVanIersel\RemoveSchema\Infrastructure\AssetLocator;
17 use TimVanIersel\RemoveSchema\PublicSite\SchemaRemoval;
18 use TimVanIersel\RemoveSchema\Schema\MarkupCleaner;
19
20 if ( ! defined( 'ABSPATH' ) ) {
21 exit;
22 }
23
24 /**
25 * Main plugin class responsible for bootstrapping all services.
26 */
27 final class Plugin {
28 /**
29 * Plugin context value object.
30 *
31 * @var PluginContext
32 */
33 private PluginContext $context;
34
35 /**
36 * Asset locator instance.
37 *
38 * @var AssetLocator
39 */
40 private AssetLocator $assets;
41
42 /**
43 * Constructor.
44 */
45 private function __construct() {
46 $this->context = new PluginContext(
47 REMOVE_SCHEMA_FILE,
48 REMOVE_SCHEMA_PATH,
49 REMOVE_SCHEMA_URL,
50 REMOVE_SCHEMA_VERSION,
51 'remove-schema',
52 'remove-schema'
53 );
54 $this->assets = new AssetLocator( $this->context );
55 }
56
57 /**
58 * Bootstrap the plugin.
59 *
60 * @return void
61 */
62 public static function boot(): void {
63 $plugin = new self();
64
65 foreach ( $plugin->services() as $service ) {
66 $service->register();
67 }
68 }
69
70 /**
71 * Build the service list explicitly.
72 *
73 * @return array<int, Service>
74 */
75 private function services(): array {
76 return array(
77 new SettingsPage( $this->context ),
78 new PostEditor( $this->context ),
79 new AdminAssets( $this->assets ),
80 new SchemaRemoval( $this->context, new MarkupCleaner() ),
81 );
82 }
83 }
84