PluginProbe
YayMail – WooCommerce Email Customizer / 4.4.2
YayMail – WooCommerce Email Customizer v4.4.2
4.4.6 4.4.5 4.4.4 4.4.3 4.4.2 4.4.1 trunk 1.9.6 2.1.4 2.1.5 3.2.2 3.2.6 3.2.7.1 3.2.8.1 3.2.9 3.3 3.3.1 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9 3.4 3.4.1 All 57 releases
yaymail / vendor-prefixed / src / Registry / LicenseRegistry.php

LicenseRegistry.php in YayMail – WooCommerce Email Customizer 4.4.2, at vendor-prefixed/src/Registry/LicenseRegistry.php

60 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace YayMailScoped\YayCommerce\AdminShell\Registry;
4
5 /**
6 * Central registry for all plugin license info objects.
7 *
8 * Plugins call register() during 'yaycommerce_admin_shell_booted' action.
9 * The Licenses page calls all() to render the unified list.
10 * @internal
11 */
12 class LicenseRegistry
13 {
14 /** @var PluginLicenseInfo[] keyed by slug */
15 private array $plugins = [];
16 /**
17 * Register a plugin's license info. Applies the decoration filter before storing.
18 */
19 public function register($info) : void
20 {
21 /** @var PluginLicenseInfo $info */
22 $info = \apply_filters('yaycommerce_admin_shell_plugin_info', $info, $info->slug);
23 $this->plugins[$info->slug] = $info;
24 }
25 /**
26 * Return all registered PluginLicenseInfo objects, keyed by slug.
27 *
28 * @return PluginLicenseInfo[]
29 */
30 public function all() : array
31 {
32 // Refactor old licensing plugin integration
33 $old_plugins = [];
34 $handlers = ['YayMailScoped\\YAYDP\\License\\License_Handler', 'YayMailScoped\\YayMail\\License\\LicenseHandler', 'YayMailScoped\\Yay_Currency\\License\\LicenseHandler', 'YayMailScoped\\Yay_Swatches\\License\\LicenseHandler', 'YayMailScoped\\YayExtra\\License\\LicenseHandler', 'YayMailScoped\\YayRev\\License\\LicenseHandler', 'YayMailScoped\\YayWholesaleB2B\\License\\LicenseHandler', 'YayMailScoped\\YaySMTP\\License\\LicenseHandler'];
35 foreach ($handlers as $handler) {
36 if (\class_exists($handler) && \method_exists($handler, 'get_licensing_plugins')) {
37 $plugins = $handler::get_licensing_plugins();
38 if (\is_array($plugins)) {
39 $old_plugins = \array_merge($old_plugins, $plugins);
40 }
41 }
42 }
43 return \array_merge($this->plugins, $old_plugins);
44 }
45 /**
46 * Return a single PluginLicenseInfo by slug, or null if not registered.
47 */
48 public function get(string $slug) : ?PluginLicenseInfo
49 {
50 return $this->plugins[$slug] ?? null;
51 }
52 /**
53 * Check if a slug is registered.
54 */
55 public function has(string $slug) : bool
56 {
57 return isset($this->plugins[$slug]);
58 }
59 }
60