Skip to content

Commit 517eb64

Browse files
committed
Add dependency_support as a requirement for AmpPlugins & AmpThemes
1 parent 721916a commit 517eb64

File tree

3 files changed

+25
-5
lines changed

3 files changed

+25
-5
lines changed

src/Admin/AmpPlugins.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
use AmpProject\AmpWP\Infrastructure\Conditional;
1111
use AmpProject\AmpWP\Infrastructure\Delayed;
12+
use AmpProject\AmpWP\Infrastructure\HasRequirements;
1213
use AmpProject\AmpWP\Infrastructure\Registerable;
1314
use AmpProject\AmpWP\Infrastructure\Service;
1415
use AmpProject\AmpWP\Services;
@@ -22,7 +23,7 @@
2223
* @since 2.2
2324
* @internal
2425
*/
25-
class AmpPlugins implements Conditional, Delayed, Service, Registerable {
26+
class AmpPlugins implements Conditional, Delayed, HasRequirements, Service, Registerable {
2627

2728
/**
2829
* Slug for amp-compatible.
@@ -55,6 +56,16 @@ public static function get_registration_action() {
5556
return 'current_screen';
5657
}
5758

59+
/**
60+
* Get the list of service IDs required for this service to be registered.
61+
*
62+
* @return string[] List of required services.
63+
*/
64+
public static function get_requirements()
65+
{
66+
return [ 'dependency_support' ];
67+
}
68+
5869
/**
5970
* Check whether the conditional object is currently needed.
6071
*

src/Admin/AmpThemes.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
use AmpProject\AmpWP\Infrastructure\Conditional;
1111
use AmpProject\AmpWP\Infrastructure\Delayed;
12+
use AmpProject\AmpWP\Infrastructure\HasRequirements;
1213
use AmpProject\AmpWP\Infrastructure\Registerable;
1314
use AmpProject\AmpWP\Infrastructure\Service;
1415
use AmpProject\AmpWP\Services;
@@ -21,7 +22,7 @@
2122
* @since 2.2
2223
* @internal
2324
*/
24-
class AmpThemes implements Service, Registerable, Conditional, Delayed {
25+
class AmpThemes implements Service, HasRequirements, Registerable, Conditional, Delayed {
2526

2627
/**
2728
* Slug for amp-compatible.
@@ -54,6 +55,16 @@ public static function get_registration_action() {
5455
return 'admin_init';
5556
}
5657

58+
/**
59+
* Get the list of service IDs required for this service to be registered.
60+
*
61+
* @return string[] List of required services.
62+
*/
63+
public static function get_requirements()
64+
{
65+
return [ 'dependency_support' ];
66+
}
67+
5768
/**
5869
* Check whether the conditional object is currently needed.
5970
*

src/AmpWpPlugin.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,6 @@ final class AmpWpPlugin extends ServiceBasedPlugin {
6969
* @var string[]
7070
*/
7171
const SERVICES = [
72-
// @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>.
73-
'dependency_support' => DependencySupport::class,
74-
7572
'admin.analytics_menu' => Admin\AnalyticsOptionsSubmenu::class,
7673
'admin.google_fonts' => Admin\GoogleFonts::class,
7774
'admin.onboarding_menu' => Admin\OnboardingWizardSubmenu::class,
@@ -94,6 +91,7 @@ final class AmpWpPlugin extends ServiceBasedPlugin {
9491
'cli.validation_command' => Cli\ValidationCommand::class,
9592
'css_transient_cache.ajax_handler' => Admin\ReenableCssTransientCachingAjaxAction::class,
9693
'css_transient_cache.monitor' => BackgroundTask\MonitorCssTransientCaching::class,
94+
'dependency_support' => DependencySupport::class,
9795
'dev_tools.block_sources' => DevTools\BlockSources::class,
9896
'dev_tools.callback_reflection' => DevTools\CallbackReflection::class,
9997
'dev_tools.error_page' => DevTools\ErrorPage::class,

0 commit comments

Comments
 (0)