From 30b78fcd1a6df50e789ab900d4f16e7df14e1e52 Mon Sep 17 00:00:00 2001 From: Alain Schlesser Date: Sun, 12 Dec 2021 17:03:36 -0500 Subject: [PATCH] Add dependency_support as a requirement for AmpPlugins & AmpThemes --- src/Admin/AmpPlugins.php | 12 +++++++++++- src/Admin/AmpThemes.php | 12 +++++++++++- src/AmpWpPlugin.php | 4 +--- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/Admin/AmpPlugins.php b/src/Admin/AmpPlugins.php index 5da16c1e73b..ab71d942a39 100644 --- a/src/Admin/AmpPlugins.php +++ b/src/Admin/AmpPlugins.php @@ -9,6 +9,7 @@ use AmpProject\AmpWP\Infrastructure\Conditional; use AmpProject\AmpWP\Infrastructure\Delayed; +use AmpProject\AmpWP\Infrastructure\HasRequirements; use AmpProject\AmpWP\Infrastructure\Registerable; use AmpProject\AmpWP\Infrastructure\Service; use AmpProject\AmpWP\Services; @@ -22,7 +23,7 @@ * @since 2.2 * @internal */ -class AmpPlugins implements Conditional, Delayed, Service, Registerable { +class AmpPlugins implements Conditional, Delayed, HasRequirements, Service, Registerable { /** * Slug for amp-compatible. @@ -55,6 +56,15 @@ public static function get_registration_action() { return 'current_screen'; } + /** + * Get the list of service IDs required for this service to be registered. + * + * @return string[] List of required services. + */ + public static function get_requirements() { + return [ 'dependency_support' ]; + } + /** * Check whether the conditional object is currently needed. * diff --git a/src/Admin/AmpThemes.php b/src/Admin/AmpThemes.php index 834e7ca308d..8a5a9582dc9 100644 --- a/src/Admin/AmpThemes.php +++ b/src/Admin/AmpThemes.php @@ -9,6 +9,7 @@ use AmpProject\AmpWP\Infrastructure\Conditional; use AmpProject\AmpWP\Infrastructure\Delayed; +use AmpProject\AmpWP\Infrastructure\HasRequirements; use AmpProject\AmpWP\Infrastructure\Registerable; use AmpProject\AmpWP\Infrastructure\Service; use AmpProject\AmpWP\Services; @@ -21,7 +22,7 @@ * @since 2.2 * @internal */ -class AmpThemes implements Service, Registerable, Conditional, Delayed { +class AmpThemes implements Service, HasRequirements, Registerable, Conditional, Delayed { /** * Slug for amp-compatible. @@ -54,6 +55,15 @@ public static function get_registration_action() { return 'admin_init'; } + /** + * Get the list of service IDs required for this service to be registered. + * + * @return string[] List of required services. + */ + public static function get_requirements() { + return [ 'dependency_support' ]; + } + /** * Check whether the conditional object is currently needed. * diff --git a/src/AmpWpPlugin.php b/src/AmpWpPlugin.php index 6053cc35cc0..01575d06ecd 100644 --- a/src/AmpWpPlugin.php +++ b/src/AmpWpPlugin.php @@ -69,9 +69,6 @@ final class AmpWpPlugin extends ServiceBasedPlugin { * @var string[] */ const SERVICES = [ - // @todo This currently has to appear first to prevent a fatal error during activation. See . - 'dependency_support' => DependencySupport::class, - 'admin.analytics_menu' => Admin\AnalyticsOptionsSubmenu::class, 'admin.google_fonts' => Admin\GoogleFonts::class, 'admin.onboarding_menu' => Admin\OnboardingWizardSubmenu::class, @@ -94,6 +91,7 @@ final class AmpWpPlugin extends ServiceBasedPlugin { 'cli.validation_command' => Cli\ValidationCommand::class, 'css_transient_cache.ajax_handler' => Admin\ReenableCssTransientCachingAjaxAction::class, 'css_transient_cache.monitor' => BackgroundTask\MonitorCssTransientCaching::class, + 'dependency_support' => DependencySupport::class, 'dev_tools.block_sources' => DevTools\BlockSources::class, 'dev_tools.callback_reflection' => DevTools\CallbackReflection::class, 'dev_tools.error_page' => DevTools\ErrorPage::class,