Skip to content

Commit

Permalink
Add dependency_support as a requirement for AmpPlugins & AmpThemes
Browse files Browse the repository at this point in the history
  • Loading branch information
schlessera committed Dec 12, 2021
1 parent 721916a commit 30b78fc
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
12 changes: 11 additions & 1 deletion src/Admin/AmpPlugins.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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.
Expand Down Expand Up @@ -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.
*
Expand Down
12 changes: 11 additions & 1 deletion src/Admin/AmpThemes.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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.
Expand Down Expand Up @@ -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.
*
Expand Down
4 changes: 1 addition & 3 deletions src/AmpWpPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://github.com/ampproject/amp-wp/pull/6773#discussion_r767010989>.
'dependency_support' => DependencySupport::class,

'admin.analytics_menu' => Admin\AnalyticsOptionsSubmenu::class,
'admin.google_fonts' => Admin\GoogleFonts::class,
'admin.onboarding_menu' => Admin\OnboardingWizardSubmenu::class,
Expand All @@ -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,
Expand Down

0 comments on commit 30b78fc

Please sign in to comment.