er' => ObsoleteBlockAttributeRemover::class, 'optimizer' => OptimizerService::class, 'optimizer.hero_candidate_filtering' => HeroCandidateFiltering::class, 'plugin_activation_notice' => Admin\PluginActivationNotice::class, 'plugin_registry' => PluginRegistry::class, 'plugin_suppression' => PluginSuppression::class, 'reader_theme_loader' => ReaderThemeLoader::class, 'reader_theme_support_features' => ReaderThemeSupportFeatures::class, 'rest.options_controller' => OptionsRESTController::class, 'rest.validation_counts_controller' => Validation\ValidationCountsRestController::class, 'server_timing' => Instrumentation\ServerTiming::class, 'site_health_integration' => Admin\SiteHealth::class, 'validated_url_stylesheet_gc' => BackgroundTask\ValidatedUrlStylesheetDataGarbageCollection::class, 'url_validation_rest_controller' => Validation\URLValidationRESTController::class, 'url_validation_cron' => URLValidationCron::class, 'save_post_validation_event' => SavePostValidationEvent::class, 'background_task_deactivator' => BackgroundTaskDeactivator::class, 'paired_routing' => PairedRouting::class, 'paired_url' => PairedUrl::class, ]; /** * Get the list of services to register. * * The services array contains a map of => * associations. * * @return array Associative array of identifiers mapped to fully * qualified class names. */ protected function get_service_classes() { return self::SERVICES; } /** * Get the bindings for the dependency injector. * * The bindings array contains a map of => * mappings, both of which should be fully qualified class names (FQCNs). * * The does not need to be the actual PHP `interface` language * construct, it can be a `class` as well. * * Whenever you ask the injector to "make()" an , it will resolve * these mappings and return an instance of the final it found. * * @return array Associative array of fully qualified class names. */ protected function get_bindings() { return [ Optimizer\Configuration::class => AmpWPConfiguration::class, ]; } /** * Get the argument bindings for the dependency injector. * * The arguments array contains a map of => mappings. * * The array is provided in the form => . * * @return array Associative array of arrays mapping argument names * to argument values. */ protected function get_arguments() { return [ Instrumentation\ServerTiming::class => [ // Wrapped in a closure so it is lazily evaluated. Otherwise, // is_user_logged_in() breaks because it's used too early. 'verbose' => static function () { return is_user_logged_in() && current_user_can( 'manage_options' ) && isset( $_GET[ QueryVar::VERBOSE_SERVER_TIMING ] ) // phpcs:ignore WordPress.Security.NonceVerification.Recommended && filter_var( $_GET[ QueryVar::VERBOSE_SERVER_TIMING ], // phpcs:ignore WordPress.Security.NonceVerification.Recommended FILTER_VALIDATE_BOOLEAN ); }, ], ]; } /** * Get the shared instances for the dependency injector. * * The shared instances array contains a list of FQCNs that are meant to be * reused. For multiple "make()" requests, the injector will return the same * instance reference for these, instead of always returning a new one. * * This effectively turns these FQCNs into a "singleton", without incurring * all the drawbacks of the Singleton design anti-pattern. * * @return array Array of fully qualified class names. */ protected function get_shared_instances() { return [ AmpSlugCustomizationWatcher::class, PluginRegistry::class, Instrumentation\StopWatch::class, DependencySupport::class, DevTools\CallbackReflection::class, DevTools\FileReflection::class, ReaderThemeLoader::class, ReaderThemeSupportFeatures::class, BackgroundTask\BackgroundTaskDeactivator::class, PairedRouting::class, Injector::class, ]; } /** * Get the delegations for the dependency injector. * * The delegations array contains a map of => * mappings. * * The is basically a factory to provide custom instantiation * logic for the given . * * @return array Associative array of callables. */ protected function get_delegations() { return [ Injector::class => static function () { return Services::get( 'injector' ); }, RemoteGetRequest::class => static function () { $fallback_pipeline = new FallbackRemoteGetRequest( new WpHttpRemoteGetRequest(), new FilesystemRemoteGetRequest( Optimizer\LocalFallback::getMappings() ) ); return new CachedRemoteGetRequest( $fallback_pipeline, WEEK_IN_SECONDS ); }, ]; } }