diff --git a/core/core.services.yml b/core/core.services.yml index ed139f79ba54ad2861902daf27f4962c74e79f5d..cbfeefe9ef289966aa49a2100100358e61c352a0 100644 --- a/core/core.services.yml +++ b/core/core.services.yml @@ -1,4 +1,9 @@ parameters: + # The app.root and site.path parameters are dynamically set by + # \Drupal\Core\DrupalKernel::initializeContainer(). They are listed here to + # allow IDEs to autocomplete them when writing new service YAML files. + app.root: '' + site.path: '' session.storage.options: gc_probability: 1 gc_divisor: 100 @@ -201,7 +206,7 @@ services: arguments: ['@database', '@cache_tags.invalidator.checksum', '@settings'] cache.backend.apcu: class: Drupal\Core\Cache\ApcuBackendFactory - arguments: ['@app.root', '@site.path', '@cache_tags.invalidator.checksum'] + arguments: ['%app.root%', '%site.path%', '@cache_tags.invalidator.checksum'] cache.backend.php: class: Drupal\Core\Cache\PhpBackendFactory arguments: ['@cache_tags.invalidator.checksum'] @@ -395,7 +400,7 @@ services: class: Drupal\Core\Form\FormErrorHandler form_cache: class: Drupal\Core\Form\FormCache - arguments: ['@app.root', '@keyvalue.expirable', '@module_handler', '@current_user', '@csrf_token', '@logger.channel.form', '@request_stack', '@page_cache_request_policy'] + arguments: ['%app.root%', '@keyvalue.expirable', '@module_handler', '@current_user', '@csrf_token', '@logger.channel.form', '@request_stack', '@page_cache_request_policy'] public: false # Private to form_builder keyvalue: class: Drupal\Core\KeyValueStore\KeyValueFactory @@ -484,7 +489,7 @@ services: arguments: ['@http_handler_stack'] plugin.manager.link_relation_type: class: \Drupal\Core\Http\LinkRelationTypeManager - arguments: ['@app.root', '@module_handler', '@cache.discovery'] + arguments: ['%app.root%', '@module_handler', '@cache.discovery'] theme.negotiator: class: Drupal\Core\Theme\ThemeNegotiator arguments: ['@access_check.theme', '@class_resolver'] @@ -512,25 +517,25 @@ services: arguments: ['@container.namespaces', '@cache.discovery', '@module_handler'] module_handler: class: Drupal\Core\Extension\ModuleHandler - arguments: ['@app.root', '%container.modules%', '@cache.bootstrap'] + arguments: ['%app.root%', '%container.modules%', '@cache.bootstrap'] module_installer: class: Drupal\Core\Extension\ModuleInstaller tags: - { name: service_collector, tag: 'module_install.uninstall_validator', call: addUninstallValidator } - arguments: ['@app.root', '@module_handler', '@kernel'] + arguments: ['%app.root%', '@module_handler', '@kernel'] lazy: true extension.list.module: class: Drupal\Core\Extension\ModuleExtensionList - arguments: ['@app.root', 'module', '@cache.default', '@info_parser', '@module_handler', '@state', '@config.factory', '@extension.list.profile', '%install_profile%', '%container.modules%'] + arguments: ['%app.root%', 'module', '@cache.default', '@info_parser', '@module_handler', '@state', '@config.factory', '@extension.list.profile', '%install_profile%', '%container.modules%'] extension.list.profile: class: Drupal\Core\Extension\ProfileExtensionList - arguments: ['@app.root', 'profile', '@cache.default', '@info_parser', '@module_handler', '@state', '%install_profile%'] + arguments: ['%app.root%', 'profile', '@cache.default', '@info_parser', '@module_handler', '@state', '%install_profile%'] extension.list.theme: class: Drupal\Core\Extension\ThemeExtensionList - arguments: ['@app.root', 'theme', '@cache.default', '@info_parser', '@module_handler', '@state', '@config.factory', '@extension.list.theme_engine', '%install_profile%'] + arguments: ['%app.root%', 'theme', '@cache.default', '@info_parser', '@module_handler', '@state', '@config.factory', '@extension.list.theme_engine', '%install_profile%'] extension.list.theme_engine: class: Drupal\Core\Extension\ThemeEngineExtensionList - arguments: ['@app.root', 'theme_engine', '@cache.default', '@info_parser', '@module_handler', '@state', '%install_profile%'] + arguments: ['%app.root%', 'theme_engine', '@cache.default', '@info_parser', '@module_handler', '@state', '%install_profile%'] content_uninstall_validator: class: Drupal\Core\Entity\ContentUninstallValidator tags: @@ -545,7 +550,7 @@ services: lazy: true theme_handler: class: Drupal\Core\Extension\ThemeHandler - arguments: ['@app.root', '@config.factory', '@extension.list.theme'] + arguments: ['%app.root%', '@config.factory', '@extension.list.theme'] theme_installer: class: Drupal\Core\Extension\ThemeInstaller arguments: ['@theme_handler', '@config.factory', '@config.installer', '@module_handler', '@config.manager', '@asset.css.collection_optimizer', '@router.builder', '@logger.channel.default', '@state'] @@ -696,23 +701,27 @@ services: class: Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher arguments: ['@service_container'] app.root: - class: SplString + class: \SplString factory: ['@app.root.factory', 'get'] + deprecated: The "%service_id%" service is deprecated in drupal:9.0.0 and is removed from drupal:10.0.0. Use the app.root parameter instead. See https://www.drupal.org/node/3080612 tags: - { name: parameter_service } app.root.factory: class: Drupal\Core\AppRootFactory arguments: ['@kernel'] public: false + deprecated: The "%service_id%" service is deprecated in drupal:9.0.0 and is removed from drupal:10.0.0. Use the app.root parameter instead. See https://www.drupal.org/node/3080612 site.path: - class: SplString + class: \SplString factory: ['@site.path.factory', 'get'] + deprecated: The "%service_id%" service is deprecated in drupal:9.0.0 and is removed from drupal:10.0.0. Use the site.path parameter instead. See https://www.drupal.org/node/3080612 tags: - { name: parameter_service } site.path.factory: class: Drupal\Core\SitePathFactory arguments: ['@kernel'] public: false + deprecated: The "%service_id%" service is deprecated in drupal:9.0.0 and is removed from drupal:10.0.0. Use the site.path parameter instead. See https://www.drupal.org/node/3080612 controller_resolver: class: Drupal\Core\Controller\ControllerResolver arguments: ['@psr7.http_message_factory', '@class_resolver'] @@ -1462,15 +1471,15 @@ services: shared: false theme.manager: class: Drupal\Core\Theme\ThemeManager - arguments: ['@app.root', '@theme.negotiator', '@theme.initialization', '@module_handler'] + arguments: ['%app.root%', '@theme.negotiator', '@theme.initialization', '@module_handler'] calls: - [setThemeRegistry, ['@theme.registry']] theme.initialization: class: Drupal\Core\Theme\ThemeInitialization - arguments: ['@app.root', '@theme_handler', '@cache.bootstrap', '@module_handler'] + arguments: ['%app.root%', '@theme_handler', '@cache.bootstrap', '@module_handler'] theme.registry: class: Drupal\Core\Theme\Registry - arguments: ['@app.root', '@cache.default', '@lock', '@module_handler', '@theme_handler', '@theme.initialization', null, '@cache.bootstrap'] + arguments: ['%app.root%', '@cache.default', '@lock', '@module_handler', '@theme_handler', '@theme.initialization', null, '@cache.bootstrap'] tags: - { name: needs_destruction } calls: @@ -1567,10 +1576,10 @@ services: - { name: needs_destruction } library.discovery.parser: class: Drupal\Core\Asset\LibraryDiscoveryParser - arguments: ['@app.root', '@module_handler', '@theme.manager', '@stream_wrapper_manager', '@library.libraries_directory_file_finder'] + arguments: ['%app.root%', '@module_handler', '@theme.manager', '@stream_wrapper_manager', '@library.libraries_directory_file_finder'] library.libraries_directory_file_finder: class: Drupal\Core\Asset\LibrariesDirectoryFileFinder - arguments: ['@app.root', '@site.path', '@extension.list.profile', '%install_profile%'] + arguments: ['%app.root%', '%site.path%', '@extension.list.profile', '%install_profile%'] library.dependency_resolver: class: Drupal\Core\Asset\LibraryDependencyResolver arguments: ['@library.discovery'] @@ -1579,10 +1588,10 @@ services: arguments: ['@library.discovery', '@library.dependency_resolver', '@module_handler', '@theme.manager', '@language_manager', '@cache.data'] info_parser: class: Drupal\Core\Extension\InfoParser - arguments: ['@app.root'] + arguments: ['%app.root%'] twig: class: Drupal\Core\Template\TwigEnvironment - arguments: ['@app.root', '@cache.default', '%twig_extension_hash%', '@state', '@twig.loader', '%twig.config%'] + arguments: ['%app.root%', '@cache.default', '%twig_extension_hash%', '@state', '@twig.loader', '%twig.config%'] tags: - { name: service_collector, tag: 'twig.extension', call: addExtension } twig.extension: @@ -1603,7 +1612,7 @@ services: - { name: service_collector, tag: twig.loader, call: addLoader, required: TRUE } twig.loader.filesystem: class: Drupal\Core\Template\Loader\FilesystemLoader - # We use '.' instead of '@app.root' as the path for non-namespaced template + # We use '.' instead of '%app.root%' as the path for non-namespaced template # files so that they match the relative paths of templates loaded via the # theme registry or via Twig namespaces. arguments: ['.', '@module_handler', '@theme_handler'] diff --git a/core/includes/errors.inc b/core/includes/errors.inc index 68e2482d8d10994d55663e4d7efebec283387e3d..fdd9ba58ad643603149a3b4a9054961f5caaa500 100644 --- a/core/includes/errors.inc +++ b/core/includes/errors.inc @@ -220,7 +220,7 @@ function _drupal_log_error($error, $fatal = FALSE) { // Attempt to reduce verbosity by removing DRUPAL_ROOT from the file path // in the message. This does not happen for (false) security. - if (\Drupal::hasService('app.root')) { + if (\Drupal::hasService('kernel')) { $root_length = strlen(\Drupal::root()); if (substr($error['%file'], 0, $root_length) == \Drupal::root()) { $error['%file'] = substr($error['%file'], $root_length + 1); diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc index d187a9a320f04810a468c20b9fb5af79b7df67aa..d9977fb6b84d27c09f8565dd286263d2243ac6c6 100644 --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -447,7 +447,7 @@ function install_begin_request($class_loader, &$install_state) { ->addTranslator($container->get('string_translator.file_translation')); // Add list of all available profiles to the installation state. - $listing = new ExtensionDiscovery($container->get('app.root')); + $listing = new ExtensionDiscovery($container->getParameter('app.root')); $listing->setProfileDirectories([]); $install_state['profiles'] += $listing->scan('profile'); @@ -1896,7 +1896,7 @@ function install_check_translations($langcode, $server_pattern) { $readable = FALSE; $writable = FALSE; // @todo: Make this configurable. - $site_path = \Drupal::service('site.path'); + $site_path = \Drupal::getContainer()->getParameter('site.path'); $files_directory = $site_path . '/files'; $translations_directory = $site_path . '/files/translations'; $translations_directory_exists = FALSE; @@ -2075,7 +2075,7 @@ function install_check_requirements($install_state) { foreach ($default_files as $default_file_info) { $readable = FALSE; $writable = FALSE; - $site_path = './' . \Drupal::service('site.path'); + $site_path = './' . \Drupal::getContainer()->getParameter('site.path'); $file = $site_path . "/{$default_file_info['file']}"; $default_file = "./sites/default/{$default_file_info['file_default']}"; $exists = FALSE; diff --git a/core/includes/install.inc b/core/includes/install.inc index 34c47d8ae17d530c5553359ce970df3c4296a4e9..457dc50bafba6677171b567bb293f793a615c11b 100644 --- a/core/includes/install.inc +++ b/core/includes/install.inc @@ -217,7 +217,7 @@ function drupal_get_database_types() { */ function drupal_rewrite_settings($settings = [], $settings_file = NULL) { if (!isset($settings_file)) { - $settings_file = \Drupal::service('site.path') . '/settings.php'; + $settings_file = \Drupal::getContainer()->getParameter('site.path') . '/settings.php'; } // Build list of setting names and insert the values into the global namespace. $variable_names = []; diff --git a/core/lib/Drupal.php b/core/lib/Drupal.php index f6ba4727cf806954ef1f9bd369b0ff6fcf6f75e3..eb155efb0e9da4f59198ae677ca551a3af982ceb 100644 --- a/core/lib/Drupal.php +++ b/core/lib/Drupal.php @@ -176,7 +176,7 @@ public static function hasService($id) { * @return string */ public static function root() { - return static::getContainer()->get('app.root'); + return static::getContainer()->getParameter('app.root'); } /** diff --git a/core/lib/Drupal/Core/AppRootFactory.php b/core/lib/Drupal/Core/AppRootFactory.php index 65c4592ede80d87e53091d7c2277edbe8bbdcd1e..892492380e046ba19fd8d65a467e2b78d80d4cf4 100644 --- a/core/lib/Drupal/Core/AppRootFactory.php +++ b/core/lib/Drupal/Core/AppRootFactory.php @@ -28,9 +28,10 @@ public function __construct(DrupalKernelInterface $drupal_kernel) { * Gets the app root. * * @return string + * The app root. */ public function get() { - return $this->drupalKernel->getAppRoot(); + return $this->drupalKernel->getContainer()->getParameter('app.root'); } } diff --git a/core/lib/Drupal/Core/Database/Driver/sqlite/Install/Tasks.php b/core/lib/Drupal/Core/Database/Driver/sqlite/Install/Tasks.php index 4b61fe364eba97c2c2442f147ed3a7a11c016c7e..ae0fd9731261538db2a08778eae79f123e9e447c 100644 --- a/core/lib/Drupal/Core/Database/Driver/sqlite/Install/Tasks.php +++ b/core/lib/Drupal/Core/Database/Driver/sqlite/Install/Tasks.php @@ -43,7 +43,7 @@ public function getFormOptions(array $database) { // Make the text more accurate for SQLite. $form['database']['#title'] = t('Database file'); $form['database']['#description'] = t('The absolute path to the file where @drupal data will be stored. This must be writable by the web server and should exist outside of the web root.', ['@drupal' => drupal_install_profile_distribution_name()]); - $default_database = \Drupal::service('site.path') . '/files/.ht.sqlite'; + $default_database = \Drupal::getContainer()->getParameter('site.path') . '/files/.ht.sqlite'; $form['database']['#default_value'] = empty($database['database']) ? $default_database : $database['database']; return $form; } diff --git a/core/lib/Drupal/Core/DrupalKernel.php b/core/lib/Drupal/Core/DrupalKernel.php index ff44a539b26c488f7f5005fb6474bbe9454675cb..ed776bf5511cb2ef7b40bc391c6da57119616822 100644 --- a/core/lib/Drupal/Core/DrupalKernel.php +++ b/core/lib/Drupal/Core/DrupalKernel.php @@ -896,6 +896,10 @@ protected function initializeContainer() { // Only create a new class if we have a container definition. if (isset($container_definition)) { + // Drupal provides two dynamic parameters to access specific paths that + // are determined from the request. + $container_definition['parameters']['app.root'] = $this->getAppRoot(); + $container_definition['parameters']['site.path'] = $this->getSitePath(); $class = Settings::get('container_base_class', '\Drupal\Core\DependencyInjection\Container'); $container = new $class($container_definition); } @@ -1271,6 +1275,9 @@ protected function compileContainer() { } $container->setParameter('persist_ids', $persist_ids); + $container->setParameter('app.root', $this->getAppRoot()); + $container->setParameter('site.path', $this->getSitePath()); + $container->compile(); return $container; } diff --git a/core/lib/Drupal/Core/Extension/Extension.php b/core/lib/Drupal/Core/Extension/Extension.php index 84792b976c848d2b93e4a30b3e4bd963512b56fe..0b3fc6c57976a5b7aae7329942c0dee0cd4c1cc4 100644 --- a/core/lib/Drupal/Core/Extension/Extension.php +++ b/core/lib/Drupal/Core/Extension/Extension.php @@ -182,8 +182,14 @@ public function __sleep() { * Magic method implementation to unserialize the extension object. */ public function __wakeup() { - // Get the app root from the container. - $this->root = \Drupal::hasService('app.root') ? \Drupal::root() : DRUPAL_ROOT; + // Get the app root from the container. While compiling the container we + // have to discover all the extension service files in + // \Drupal\Core\DrupalKernel::initializeServiceProviders(). This results in + // creating extension objects before the container has the kernel. + // Specifically, this occurs during the call to + // \Drupal\Core\Extension\ExtensionDiscovery::scanDirectory(). + $container = \Drupal::hasContainer() ? \Drupal::getContainer() : FALSE; + $this->root = $container && $container->hasParameter('app.root') ? $container->getParameter('app.root') : DRUPAL_ROOT; } } diff --git a/core/lib/Drupal/Core/Extension/ExtensionDiscovery.php b/core/lib/Drupal/Core/Extension/ExtensionDiscovery.php index f9c7421dd7ac5f89caedcd315d312bff0f15e051..3dc28a8d42f1fe562a4e09205a7366c80cb5ab31 100644 --- a/core/lib/Drupal/Core/Extension/ExtensionDiscovery.php +++ b/core/lib/Drupal/Core/Extension/ExtensionDiscovery.php @@ -103,7 +103,7 @@ class ExtensionDiscovery { * @param string $site_path * The path to the site. */ - public function __construct($root, $use_file_cache = TRUE, $profile_directories = NULL, $site_path = NULL) { + public function __construct(string $root, $use_file_cache = TRUE, array $profile_directories = NULL, string $site_path = NULL) { $this->root = $root; $this->fileCache = $use_file_cache ? FileCacheFactory::get('extension_discovery') : NULL; $this->profileDirectories = $profile_directories; @@ -184,7 +184,7 @@ public function scan($type, $include_tests = NULL) { // at install time. Therefore Kernel service is not always available, but is // preferred. if (\Drupal::hasService('kernel')) { - $searchdirs[static::ORIGIN_SITE] = \Drupal::service('site.path'); + $searchdirs[static::ORIGIN_SITE] = \Drupal::getContainer()->getParameter('site.path'); } else { $searchdirs[static::ORIGIN_SITE] = $this->sitePath ?: DrupalKernel::findSitePath(Request::createFromGlobals()); diff --git a/core/lib/Drupal/Core/Extension/InfoParserDynamic.php b/core/lib/Drupal/Core/Extension/InfoParserDynamic.php index 1b5f948f1399d6a9935f57b19fc73b79ca466e96..f793c4ff6adf84862aa6760cfe911c6cf9088168 100644 --- a/core/lib/Drupal/Core/Extension/InfoParserDynamic.php +++ b/core/lib/Drupal/Core/Extension/InfoParserDynamic.php @@ -33,7 +33,7 @@ public function __construct(string $app_root = NULL) { if ($app_root === NULL) { // @todo https://www.drupal.org/project/drupal/issues/3087975 Require // $app_root argument. - $app_root = \Drupal::hasService('app.root') ? (string) \Drupal::service('app.root') : DRUPAL_ROOT; + $app_root = \Drupal::hasService('kernel') ? \Drupal::root() : DRUPAL_ROOT; } $this->root = $app_root; } diff --git a/core/lib/Drupal/Core/FileTransfer/Form/FileTransferAuthorizeForm.php b/core/lib/Drupal/Core/FileTransfer/Form/FileTransferAuthorizeForm.php index 857fb2014755f36e0d59225b347e6787d6debd22..563aff847e5b4f2ee2c7cf546a206ecfdbe37c5e 100644 --- a/core/lib/Drupal/Core/FileTransfer/Form/FileTransferAuthorizeForm.php +++ b/core/lib/Drupal/Core/FileTransfer/Form/FileTransferAuthorizeForm.php @@ -36,7 +36,7 @@ public function __construct($root) { * {@inheritdoc} */ public static function create(ContainerInterface $container) { - return new static($container->get('app.root')); + return new static($container->getParameter('app.root')); } /** diff --git a/core/lib/Drupal/Core/Installer/Form/SiteConfigureForm.php b/core/lib/Drupal/Core/Installer/Form/SiteConfigureForm.php index 70e257642c9f097672e5a01a291dda50b27b7a87..a550e4219d2151a7091c4d413c4ed9a4f54be7a7 100644 --- a/core/lib/Drupal/Core/Installer/Form/SiteConfigureForm.php +++ b/core/lib/Drupal/Core/Installer/Form/SiteConfigureForm.php @@ -91,8 +91,8 @@ public function __construct($root, $site_path, UserStorageInterface $user_storag */ public static function create(ContainerInterface $container) { return new static( - $container->get('app.root'), - $container->get('site.path'), + $container->getParameter('app.root'), + $container->getParameter('site.path'), $container->get('entity_type.manager')->getStorage('user'), $container->get('state'), $container->get('module_installer'), diff --git a/core/lib/Drupal/Core/Installer/Form/SiteSettingsForm.php b/core/lib/Drupal/Core/Installer/Form/SiteSettingsForm.php index 75099a2a354acd7ec52e32b937550d423143f1c8..aa2ce36680afdaf459e5e1f3d2db1f2a6756ffd0 100644 --- a/core/lib/Drupal/Core/Installer/Form/SiteSettingsForm.php +++ b/core/lib/Drupal/Core/Installer/Form/SiteSettingsForm.php @@ -48,7 +48,7 @@ public function __construct($site_path, RendererInterface $renderer) { */ public static function create(ContainerInterface $container) { return new static( - $container->get('site.path'), + $container->getParameter('site.path'), $container->get('renderer') ); } @@ -264,7 +264,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { * The path to the generated config sync directory. */ protected function createRandomConfigDirectory() { - $config_sync_directory = \Drupal::service('site.path') . '/files/config_' . Crypt::randomBytesBase64(55) . '/sync'; + $config_sync_directory = $this->sitePath . '/files/config_' . Crypt::randomBytesBase64(55) . '/sync'; // This should never fail, it is created here inside the public files // directory, which has already been verified to be writable itself. if (\Drupal::service('file_system')->prepareDirectory($config_sync_directory, FileSystemInterface::CREATE_DIRECTORY | FileSystemInterface::MODIFY_PERMISSIONS)) { diff --git a/core/lib/Drupal/Core/SitePathFactory.php b/core/lib/Drupal/Core/SitePathFactory.php index 7a01ff17a4a6fd8058ea6cb546c704597c9cecc5..307d6aa42a0bf03482381f2b8700c435609a9f41 100644 --- a/core/lib/Drupal/Core/SitePathFactory.php +++ b/core/lib/Drupal/Core/SitePathFactory.php @@ -31,7 +31,7 @@ public function __construct(DrupalKernelInterface $drupal_kernel) { * The site path. */ public function get() { - return $this->drupalKernel->getSitePath(); + return $this->drupalKernel->getContainer()->getParameter('site.path'); } } diff --git a/core/lib/Drupal/Core/StreamWrapper/PublicStream.php b/core/lib/Drupal/Core/StreamWrapper/PublicStream.php index 403263e30178a02c2b25f27fa764ff40b1ba0f25..e89e43219eab46b3fca9ec4310fe50dfc5d86d57 100644 --- a/core/lib/Drupal/Core/StreamWrapper/PublicStream.php +++ b/core/lib/Drupal/Core/StreamWrapper/PublicStream.php @@ -86,7 +86,7 @@ public static function baseUrl() { * * The site path is injectable from the site.path service: * @code - * $base_path = PublicStream::basePath(\Drupal::service('site.path')); + * $base_path = PublicStream::basePath(\Drupal::getContainer()->getParameter('site.path')); * @endcode * * @param string $site_path @@ -104,7 +104,7 @@ public static function basePath($site_path = NULL) { // Find the site path. Kernel service is not always available at this // point, but is preferred, when available. if (\Drupal::hasService('kernel')) { - $site_path = \Drupal::service('site.path'); + $site_path = \Drupal::getContainer()->getParameter('site.path'); } else { // If there is no kernel available yet, we call the static diff --git a/core/lib/Drupal/Core/Test/PhpUnitTestRunner.php b/core/lib/Drupal/Core/Test/PhpUnitTestRunner.php index bc7846e81970694a6d9a5dd08f138f500861a192..f4113a1db695242c655cd94b599afcbc9f14662b 100644 --- a/core/lib/Drupal/Core/Test/PhpUnitTestRunner.php +++ b/core/lib/Drupal/Core/Test/PhpUnitTestRunner.php @@ -44,7 +44,7 @@ class PhpUnitTestRunner implements ContainerInjectionInterface { */ public static function create(ContainerInterface $container) { return new static( - (string) $container->get('app.root'), + (string) $container->getParameter('app.root'), (string) $container->get('file_system')->realpath('public://simpletest') ); } diff --git a/core/lib/Drupal/Core/Test/TestRunnerKernel.php b/core/lib/Drupal/Core/Test/TestRunnerKernel.php index 95d69464c1bc9b6b76fa73affe2020378d090f00..85d84b75a7bd0f2ee72a94e5bd979bdf906c37a1 100644 --- a/core/lib/Drupal/Core/Test/TestRunnerKernel.php +++ b/core/lib/Drupal/Core/Test/TestRunnerKernel.php @@ -77,7 +77,7 @@ public function boot() { $this->getContainer()->get('module_handler')->loadAll(); $test_discovery = new TestDiscovery( - $this->getContainer()->get('app.root'), + $this->getContainer()->getParameter('app.root'), $this->getContainer()->get('class_loader') ); $test_discovery->registerTestNamespaces(); diff --git a/core/lib/Drupal/Core/Update/UpdateRegistryFactory.php b/core/lib/Drupal/Core/Update/UpdateRegistryFactory.php index b17815bf7b0db2a48dcc223118f985049599bff7..bbb06747924305d9a60fe26382dcacfdee49b849 100644 --- a/core/lib/Drupal/Core/Update/UpdateRegistryFactory.php +++ b/core/lib/Drupal/Core/Update/UpdateRegistryFactory.php @@ -19,7 +19,7 @@ class UpdateRegistryFactory implements ContainerAwareInterface { * The update registry instance. */ public function create() { - return new UpdateRegistry($this->container->get('app.root'), $this->container->get('site.path'), array_keys($this->container->get('module_handler')->getModuleList()), $this->container->get('keyvalue')->get('post_update')); + return new UpdateRegistry($this->container->getParameter('app.root'), $this->container->getParameter('site.path'), array_keys($this->container->get('module_handler')->getModuleList()), $this->container->get('keyvalue')->get('post_update')); } } diff --git a/core/modules/block/tests/src/Unit/Menu/BlockLocalTasksTest.php b/core/modules/block/tests/src/Unit/Menu/BlockLocalTasksTest.php index c61e3a1cd844c01dd432e9eb456f7ef6acbb97ae..18486e3ca70c28ebf64337f49225e249fc14561e 100644 --- a/core/modules/block/tests/src/Unit/Menu/BlockLocalTasksTest.php +++ b/core/modules/block/tests/src/Unit/Menu/BlockLocalTasksTest.php @@ -55,7 +55,7 @@ protected function setUp() { $container = new ContainerBuilder(); $container->set('config.factory', $config_factory); $container->set('theme_handler', $theme_handler); - $container->set('app.root', $this->root); + $container->setParameter('app.root', $this->root); \Drupal::setContainer($container); } diff --git a/core/modules/file/tests/file_test/src/StreamWrapper/DummyReadOnlyStreamWrapper.php b/core/modules/file/tests/file_test/src/StreamWrapper/DummyReadOnlyStreamWrapper.php index c1c36af4138c46019998a08c184ccbb9e2564b6a..3acbd451c582c5c97f518f65ba90514e12e8e459 100644 --- a/core/modules/file/tests/file_test/src/StreamWrapper/DummyReadOnlyStreamWrapper.php +++ b/core/modules/file/tests/file_test/src/StreamWrapper/DummyReadOnlyStreamWrapper.php @@ -26,7 +26,7 @@ public function getDescription() { } public function getDirectoryPath() { - return \Drupal::service('site.path') . '/files'; + return \Drupal::getContainer()->getParameter('site.path') . '/files'; } /** diff --git a/core/modules/file/tests/file_test/src/StreamWrapper/DummyStreamWrapper.php b/core/modules/file/tests/file_test/src/StreamWrapper/DummyStreamWrapper.php index 6ce842470fcd4955e7d66c5079664e8443ef51fb..20def09697513da8c463f72266e59f0525cedc94 100644 --- a/core/modules/file/tests/file_test/src/StreamWrapper/DummyStreamWrapper.php +++ b/core/modules/file/tests/file_test/src/StreamWrapper/DummyStreamWrapper.php @@ -26,7 +26,7 @@ public function getDescription() { } public function getDirectoryPath() { - return \Drupal::service('site.path') . '/files'; + return \Drupal::getContainer()->getParameter('site.path') . '/files'; } /** diff --git a/core/modules/file/tests/src/Kernel/Migrate/d7/MigratePrivateFileTest.php b/core/modules/file/tests/src/Kernel/Migrate/d7/MigratePrivateFileTest.php index 63e284ff9849236c3efec9c5d94bc63c7b603d6e..69974381b32f01d700386d18ecfc2bec5938c61b 100644 --- a/core/modules/file/tests/src/Kernel/Migrate/d7/MigratePrivateFileTest.php +++ b/core/modules/file/tests/src/Kernel/Migrate/d7/MigratePrivateFileTest.php @@ -24,7 +24,7 @@ class MigratePrivateFileTest extends MigrateDrupal7TestBase { */ protected function setUp() { parent::setUp(); - $this->setSetting('file_private_path', $this->container->get('site.path') . '/private'); + $this->setSetting('file_private_path', $this->container->getParameter('site.path') . '/private'); $this->fileMigrationSetup(); } diff --git a/core/modules/help_topics/help_topics.services.yml b/core/modules/help_topics/help_topics.services.yml index ed6a59df0e2b422843452beb3c260ab06ca7877c..61925159f5ca72fa5f277ceda2737297b88d753f 100644 --- a/core/modules/help_topics/help_topics.services.yml +++ b/core/modules/help_topics/help_topics.services.yml @@ -7,10 +7,10 @@ services: public: false plugin.manager.help_topic: class: Drupal\help_topics\HelpTopicPluginManager - arguments: ['@module_handler', '@theme_handler', '@cache.discovery', '@app.root'] + arguments: ['@module_handler', '@theme_handler', '@cache.discovery', '%app.root%'] help.twig.loader: class: Drupal\help_topics\HelpTopicTwigLoader - arguments: ['@app.root', '@module_handler', '@theme_handler'] + arguments: ['%app.root%', '@module_handler', '@theme_handler'] # Lowest core priority because loading help topics is not the usual case. tags: - { name: twig.loader, priority: -200 } diff --git a/core/modules/help_topics/tests/src/Functional/HelpTopicsSyntaxTest.php b/core/modules/help_topics/tests/src/Functional/HelpTopicsSyntaxTest.php index 1c73aad171398ee3777d4740450fb636fb871749..f9b7a6794290993c1af5f3540779c296abdb158e 100644 --- a/core/modules/help_topics/tests/src/Functional/HelpTopicsSyntaxTest.php +++ b/core/modules/help_topics/tests/src/Functional/HelpTopicsSyntaxTest.php @@ -48,7 +48,7 @@ public function testHelpTopics() { $directories = $module_directories + $theme_directories + $this->listDirectories('profile'); - $directories['core'] = \Drupal::service('app.root') . '/core/help_topics'; + $directories['core'] = \Drupal::root() . '/core/help_topics'; $directories['bad_help_topics'] = \Drupal::service('extension.list.module')->getPath('help_topics_test') . '/bad_help_topics/syntax/'; // Filter out directories outside of core. If you want to run this test diff --git a/core/modules/jsonapi/jsonapi.services.yml b/core/modules/jsonapi/jsonapi.services.yml index 0894d3dc4de359e8a59ef4bcf6c76de7d8e9765e..c3013a460b084eda3856108b41b1ebe96a48fa5e 100644 --- a/core/modules/jsonapi/jsonapi.services.yml +++ b/core/modules/jsonapi/jsonapi.services.yml @@ -207,7 +207,7 @@ services: - { name: event_subscriber } jsonapi.resource_response_validator.subscriber: class: Drupal\jsonapi\EventSubscriber\ResourceResponseValidator - arguments: ['@logger.channel.jsonapi', '@module_handler', '@app.root'] + arguments: ['@logger.channel.jsonapi', '@module_handler', '%app.root%'] calls: - [setValidator, []] tags: diff --git a/core/modules/locale/locale.install b/core/modules/locale/locale.install index 420d3384d2d93607966092c5df6323ee8892b4af..0a7562c679456e45b142c8c87f67a66996c634ad 100644 --- a/core/modules/locale/locale.install +++ b/core/modules/locale/locale.install @@ -16,7 +16,7 @@ function locale_install() { // Create the interface translations directory and ensure it's writable. if (!$directory = \Drupal::config('locale.settings')->get('translation.path')) { - $site_path = \Drupal::service('site.path'); + $site_path = \Drupal::getContainer()->getParameter('site.path'); $directory = $site_path . '/files/translations'; \Drupal::configFactory()->getEditable('locale.settings')->set('translation.path', $directory)->save(); } diff --git a/core/modules/system/src/Controller/BatchController.php b/core/modules/system/src/Controller/BatchController.php index 2e01c5bae1232f8db5a79e543416f6e914fdfd8a..038b1333019e6f1a3b0b02b6c2d3f269ad68989e 100644 --- a/core/modules/system/src/Controller/BatchController.php +++ b/core/modules/system/src/Controller/BatchController.php @@ -35,7 +35,7 @@ public function __construct($root) { */ public static function create(ContainerInterface $container) { return new static( - $container->get('app.root') + $container->getParameter('app.root') ); } diff --git a/core/modules/system/src/Controller/DbUpdateController.php b/core/modules/system/src/Controller/DbUpdateController.php index 25a2a708918601f5720c6150924a28235c4276ac..8f29f798261d9bf49458e975da659ef33517879d 100644 --- a/core/modules/system/src/Controller/DbUpdateController.php +++ b/core/modules/system/src/Controller/DbUpdateController.php @@ -113,7 +113,7 @@ public function __construct($root, KeyValueExpirableFactoryInterface $key_value_ */ public static function create(ContainerInterface $container) { return new static( - $container->get('app.root'), + $container->getParameter('app.root'), $container->get('keyvalue.expirable'), $container->get('cache.default'), $container->get('state'), diff --git a/core/modules/system/system.install b/core/modules/system/system.install index 317304ba09b68bbba599376ff2d49143df57e47c..140de3b1aecb7086357daf89c58692db3c737f80 100644 --- a/core/modules/system/system.install +++ b/core/modules/system/system.install @@ -487,7 +487,7 @@ function system_requirements($phase) { // Find the site path. Kernel service is not always available at this point, // but is preferred, when available. if (\Drupal::hasService('kernel')) { - $site_path = \Drupal::service('site.path'); + $site_path = \Drupal::getContainer()->getParameter('site.path'); } else { $site_path = DrupalKernel::findSitePath(Request::createFromGlobals()); diff --git a/core/modules/system/tests/src/Functional/Form/ModulesListFormWebTest.php b/core/modules/system/tests/src/Functional/Form/ModulesListFormWebTest.php index 90a05e5fbd12da066b88df76352ef6b2e21c02ff..678353a583289752e25c0d72a37c88bf38e04d04 100644 --- a/core/modules/system/tests/src/Functional/Form/ModulesListFormWebTest.php +++ b/core/modules/system/tests/src/Functional/Form/ModulesListFormWebTest.php @@ -61,7 +61,7 @@ public function testModulesListFormWithInvalidInfoFile() { name: Module With Broken Info file type: module BROKEN; - $path = \Drupal::service('site.path') . "/modules/broken"; + $path = \Drupal::getContainer()->getParameter('site.path') . "/modules/broken"; mkdir($path, 0777, TRUE); file_put_contents("$path/broken.info.yml", $broken_info_yml); diff --git a/core/modules/update/src/Form/UpdateManagerInstall.php b/core/modules/update/src/Form/UpdateManagerInstall.php index 681e236ec2dc4fab4ab50fdb9dba770c1c60c14d..ca41b78d3aacd3f48e5548519c8f9bdec4cac748 100644 --- a/core/modules/update/src/Form/UpdateManagerInstall.php +++ b/core/modules/update/src/Form/UpdateManagerInstall.php @@ -80,7 +80,7 @@ public static function create(ContainerInterface $container) { return new static( $container->get('update.root'), $container->get('module_handler'), - $container->get('site.path'), + $container->getParameter('site.path'), $container->get('plugin.manager.archiver') ); } diff --git a/core/modules/update/src/Form/UpdateReady.php b/core/modules/update/src/Form/UpdateReady.php index 20f158f67b1b9374bbc47d9bb551bf8dc50eb651..d8e5fdcc6498fa2a93bfb0b4f64d20019e363d5f 100644 --- a/core/modules/update/src/Form/UpdateReady.php +++ b/core/modules/update/src/Form/UpdateReady.php @@ -80,7 +80,7 @@ public static function create(ContainerInterface $container) { $container->get('update.root'), $container->get('module_handler'), $container->get('state'), - $container->get('site.path') + $container->getParameter('site.path') ); } diff --git a/core/modules/update/update.manager.inc b/core/modules/update/update.manager.inc index 1d29342c2bc6f5cb29f2e801a97c06eab3da957b..902ff8429a4aee0b6f0b8c51d050069f9c728589 100644 --- a/core/modules/update/update.manager.inc +++ b/core/modules/update/update.manager.inc @@ -318,7 +318,7 @@ function update_manager_local_transfers_allowed() { // the configuration directory to determine if local transfers will be // allowed. $temporary_file = \Drupal::service('file_system')->tempnam('temporary://', 'update_'); - $site_path = \Drupal::service('site.path'); + $site_path = \Drupal::getContainer()->getParameter('site.path'); $local_transfers_allowed = fileowner($temporary_file) === fileowner($site_path); // Clean up. If this fails, we can ignore it (since this is just a temporary diff --git a/core/tests/Drupal/FunctionalJavascriptTests/Core/Installer/Form/SelectProfileFormTest.php b/core/tests/Drupal/FunctionalJavascriptTests/Core/Installer/Form/SelectProfileFormTest.php index 531f6708f8ca014da302e18c75d069677424be1e..11969cd8375b8f6480f567fc601a961491922df5 100644 --- a/core/tests/Drupal/FunctionalJavascriptTests/Core/Installer/Form/SelectProfileFormTest.php +++ b/core/tests/Drupal/FunctionalJavascriptTests/Core/Installer/Form/SelectProfileFormTest.php @@ -87,7 +87,7 @@ public function setUp() { ->set('http_handler_stack', $handler_stack); $this->container - ->set('app.root', DRUPAL_ROOT); + ->setParameter('app.root', DRUPAL_ROOT); \Drupal::setContainer($this->container); // Setup Mink. diff --git a/core/tests/Drupal/FunctionalTests/Installer/InstallerSkipPermissionHardeningTest.php b/core/tests/Drupal/FunctionalTests/Installer/InstallerSkipPermissionHardeningTest.php index f282de86785a7b6396a55162207aa566dda83c19..13dec4b97f63393ef93e1a2dc6bd417a9e95a610 100644 --- a/core/tests/Drupal/FunctionalTests/Installer/InstallerSkipPermissionHardeningTest.php +++ b/core/tests/Drupal/FunctionalTests/Installer/InstallerSkipPermissionHardeningTest.php @@ -26,7 +26,7 @@ protected function prepareEnvironment() { * {@inheritdoc} */ protected function setUpSite() { - $site_directory = $this->container->get('app.root') . '/' . $this->siteDirectory; + $site_directory = $this->container->getParameter('app.root') . '/' . $this->siteDirectory; $this->assertTrue(is_writable($site_directory)); $this->assertTrue(is_writable($site_directory . '/settings.php')); diff --git a/core/tests/Drupal/FunctionalTests/Installer/InstallerTest.php b/core/tests/Drupal/FunctionalTests/Installer/InstallerTest.php index 1fd54494825344c609649101870ae5d8f450bf67..ec201bae11eeebcdf6879f7c0c151d8eb2edef96 100644 --- a/core/tests/Drupal/FunctionalTests/Installer/InstallerTest.php +++ b/core/tests/Drupal/FunctionalTests/Installer/InstallerTest.php @@ -87,7 +87,7 @@ protected function setUpSite() { // Test that SiteConfigureForm::buildForm() has made the site directory and // the settings file non-writable. - $site_directory = $this->container->get('app.root') . '/' . $this->siteDirectory; + $site_directory = $this->container->getParameter('app.root') . '/' . $this->siteDirectory; $this->assertFalse(is_writable($site_directory)); $this->assertFalse(is_writable($site_directory . '/settings.php')); diff --git a/core/tests/Drupal/FunctionalTests/Installer/InstallerTestBase.php b/core/tests/Drupal/FunctionalTests/Installer/InstallerTestBase.php index 586cec6d248f763252d0cdfc7f5281d85529bda5..699f26f87dc14a2276bbfb9a98b1c8c220d48da1 100644 --- a/core/tests/Drupal/FunctionalTests/Installer/InstallerTestBase.php +++ b/core/tests/Drupal/FunctionalTests/Installer/InstallerTestBase.php @@ -137,7 +137,7 @@ protected function setUp() { ->set('http_handler_stack', $handler_stack); $this->container - ->set('app.root', DRUPAL_ROOT); + ->setParameter('app.root', DRUPAL_ROOT); \Drupal::setContainer($this->container); // Setup Mink. @@ -169,8 +169,8 @@ protected function setUp() { if ($this->isInstalled) { // Import new settings.php written by the installer. $request = Request::createFromGlobals(); - $class_loader = require $this->container->get('app.root') . '/autoload.php'; - Settings::initialize($this->container->get('app.root'), DrupalKernel::findSitePath($request), $class_loader); + $class_loader = require $this->container->getParameter('app.root') . '/autoload.php'; + Settings::initialize($this->container->getParameter('app.root'), DrupalKernel::findSitePath($request), $class_loader); // After writing settings.php, the installer removes write permissions // from the site directory. To allow drupal_generate_test_ua() to write @@ -178,7 +178,7 @@ protected function setUp() { // directory has to be writable. // BrowserTestBase::tearDown() will delete the entire test site directory. // Not using File API; a potential error must trigger a PHP warning. - chmod($this->container->get('app.root') . '/' . $this->siteDirectory, 0777); + chmod($this->container->getParameter('app.root') . '/' . $this->siteDirectory, 0777); $this->kernel = DrupalKernel::createFromRequest($request, $class_loader, 'prod', FALSE); $this->kernel->boot(); $this->kernel->preHandle($request); diff --git a/core/tests/Drupal/KernelTests/Core/File/DirectoryTest.php b/core/tests/Drupal/KernelTests/Core/File/DirectoryTest.php index 376ce1cef0e02fdc926ec86b4ca3d01cf29fd7dd..8aaddfdf1c5cceb3ae8bb342d1827fa82d788b63 100644 --- a/core/tests/Drupal/KernelTests/Core/File/DirectoryTest.php +++ b/core/tests/Drupal/KernelTests/Core/File/DirectoryTest.php @@ -33,7 +33,7 @@ protected function setUp() { * Test local directory handling functions. */ public function testFileCheckLocalDirectoryHandling() { - $site_path = $this->container->get('site.path'); + $site_path = $this->container->getParameter('site.path'); $directory = $site_path . '/files'; // Check a new recursively created local directory for correct file system diff --git a/core/tests/Drupal/KernelTests/Core/File/ReadOnlyStreamWrapperTest.php b/core/tests/Drupal/KernelTests/Core/File/ReadOnlyStreamWrapperTest.php index a57c0c7dac2d4aaaf424d9b9fb49feab463098d9..ef4e6922fa76d94d93f62ab7a7c9278d842ac720 100644 --- a/core/tests/Drupal/KernelTests/Core/File/ReadOnlyStreamWrapperTest.php +++ b/core/tests/Drupal/KernelTests/Core/File/ReadOnlyStreamWrapperTest.php @@ -38,7 +38,7 @@ public function testReadOnlyBehavior() { // Generate a test file $filename = $this->randomMachineName(); - $site_path = $this->container->get('site.path'); + $site_path = $this->container->getParameter('site.path'); $filepath = $site_path . '/files/' . $filename; file_put_contents($filepath, $filename); diff --git a/core/tests/Drupal/KernelTests/Core/LegacyServiceTest.php b/core/tests/Drupal/KernelTests/Core/LegacyServiceTest.php new file mode 100644 index 0000000000000000000000000000000000000000..8bc62715539dbdda19ccd2de821cbb9bda455177 --- /dev/null +++ b/core/tests/Drupal/KernelTests/Core/LegacyServiceTest.php @@ -0,0 +1,35 @@ +<?php + +namespace Drupal\KernelTests\Core; + +use Drupal\KernelTests\KernelTestBase; + +/** + * Tests deprecated core services. + * + * @group Core + * @group legacy + */ +class LegacyServiceTest extends KernelTestBase { + + /** + * Tests the site.path service. + * + * @expectedDeprecation The "site.path" service is deprecated in drupal:9.0.0 and is removed from drupal:10.0.0. Use the site.path parameter instead. See https://www.drupal.org/node/3080612 + * @expectedDeprecation The "site.path.factory" service is deprecated in drupal:9.0.0 and is removed from drupal:10.0.0. Use the site.path parameter instead. See https://www.drupal.org/node/3080612 + */ + public function testSitePath() { + $this->assertSame($this->container->get('site.path'), (string) $this->container->getParameter('site.path')); + } + + /** + * Tests the app.root service. + * + * @expectedDeprecation The "app.root" service is deprecated in drupal:9.0.0 and is removed from drupal:10.0.0. Use the app.root parameter instead. See https://www.drupal.org/node/3080612 + * @expectedDeprecation The "app.root.factory" service is deprecated in drupal:9.0.0 and is removed from drupal:10.0.0. Use the app.root parameter instead. See https://www.drupal.org/node/3080612 + */ + public function testAppRoot() { + $this->assertSame($this->container->get('app.root'), (string) $this->container->getParameter('app.root')); + } + +} diff --git a/core/tests/Drupal/KernelTests/Core/Site/SettingsRewriteTest.php b/core/tests/Drupal/KernelTests/Core/Site/SettingsRewriteTest.php index 05078711244ce1910a951cd31cfabac7baa3c518..c064a7ecee37d568b0ecf57dbea1d649d518a1b1 100644 --- a/core/tests/Drupal/KernelTests/Core/Site/SettingsRewriteTest.php +++ b/core/tests/Drupal/KernelTests/Core/Site/SettingsRewriteTest.php @@ -17,7 +17,7 @@ class SettingsRewriteTest extends KernelTestBase { */ public function testDrupalRewriteSettings() { include_once $this->root . '/core/includes/install.inc'; - $site_path = $this->container->get('site.path'); + $site_path = $this->container->getParameter('site.path'); $tests = [ [ 'original' => '$no_index_value_scalar = TRUE;', diff --git a/core/tests/Drupal/Tests/Core/Extension/ExtensionSerializationTest.php b/core/tests/Drupal/Tests/Core/Extension/ExtensionSerializationTest.php index 5f705d6ccad6cda309ea0127e1a95692be2326ce..60c1ce835551a626e53ba301ec9d1715302fdd5a 100644 --- a/core/tests/Drupal/Tests/Core/Extension/ExtensionSerializationTest.php +++ b/core/tests/Drupal/Tests/Core/Extension/ExtensionSerializationTest.php @@ -48,10 +48,10 @@ public function testServiceAppRouteUsage() { $this->assertFalse(defined('DRUPAL_ROOT'), 'Constant DRUPAL_ROOT is defined.'); $container = new ContainerBuilder(); // Set a dummy container app.root to test against. - $container->set('app.root', 'vfs://dummy_app_root'); + $container->setParameter('app.root', 'vfs://dummy_app_root'); \Drupal::setContainer($container); // Instantiate an Extension object for testing unserialization. - $extension = new Extension($container->get('app.root'), 'module', 'core/modules/system/system.info.yml', 'system.module'); + $extension = new Extension($container->getParameter('app.root'), 'module', 'core/modules/system/system.info.yml', 'system.module'); $extension = unserialize(serialize($extension)); $this->assertEquals('vfs://dummy_app_root', $this->readAttribute($extension, 'root')); } @@ -65,9 +65,9 @@ public function testServiceAppRouteUsage() { public function testPublicProperties() { $container = new ContainerBuilder(); // Set a dummy container app.root to test against. - $container->set('app.root', 'vfs://dummy_app_root'); + $container->setParameter('app.root', 'vfs://dummy_app_root'); \Drupal::setContainer($container); - $extension = new Extension($container->get('app.root'), 'module', 'core/modules/system/system.info.yml', 'system.module'); + $extension = new Extension($container->getParameter('app.root'), 'module', 'core/modules/system/system.info.yml', 'system.module'); // Assign a public property dynamically. $extension->test = 'foo'; $extension = unserialize(serialize($extension)); diff --git a/core/tests/Drupal/Tests/Core/Menu/LocalTaskIntegrationTestBase.php b/core/tests/Drupal/Tests/Core/Menu/LocalTaskIntegrationTestBase.php index f90f918ef2b3149d0b372825cec0a25e7e7202e2..f37e6fccceeda5b2d05e5d2a965183d236f34cd0 100644 --- a/core/tests/Drupal/Tests/Core/Menu/LocalTaskIntegrationTestBase.php +++ b/core/tests/Drupal/Tests/Core/Menu/LocalTaskIntegrationTestBase.php @@ -46,7 +46,7 @@ protected function setUp() { $container = new ContainerBuilder(); $config_factory = $this->getConfigFactoryStub([]); $container->set('config.factory', $config_factory); - $container->set('app.root', $this->root); + $container->setParameter('app.root', $this->root); \Drupal::setContainer($container); $this->container = $container; } diff --git a/core/tests/Drupal/Tests/Core/Test/TestDiscoveryTest.php b/core/tests/Drupal/Tests/Core/Test/TestDiscoveryTest.php index b37260800b48bf130c357ce0a152085bb4e03f3e..2a76f05476aa7f74347921bea4852d5c23af4f71 100644 --- a/core/tests/Drupal/Tests/Core/Test/TestDiscoveryTest.php +++ b/core/tests/Drupal/Tests/Core/Test/TestDiscoveryTest.php @@ -487,7 +487,7 @@ public function testGetTestsInProfiles() { $container = new Container(); $container->set('kernel', new DrupalKernel('prod', new ClassLoader())); - $container->set('site.path', 'sites/default'); + $container->setParameter('site.path', 'sites/default'); \Drupal::setContainer($container); $test_discovery = new TestDiscovery('vfs://drupal', $class_loader->reveal(), $module_handler->reveal()); diff --git a/core/tests/Drupal/Tests/Listeners/DeprecationListenerTrait.php b/core/tests/Drupal/Tests/Listeners/DeprecationListenerTrait.php index 85271c1ff2435524c34bceeaae2ee1f7603fd566..362f38c3c234eecc0e19665f221baa2482fed2d2 100644 --- a/core/tests/Drupal/Tests/Listeners/DeprecationListenerTrait.php +++ b/core/tests/Drupal/Tests/Listeners/DeprecationListenerTrait.php @@ -113,8 +113,6 @@ public static function isDeprecationSkipped($message) { $dynamic_skipped_deprecations = [ '%The "[^"]+" class extends "Symfony\\\\Component\\\\EventDispatcher\\\\Event" that is deprecated since Symfony 4\.3, use "Symfony\\\\Contracts\\\\EventDispatcher\\\\Event" instead\.$%', '%The "Symfony\\\\Component\\\\Validator\\\\Context\\\\ExecutionContextInterface::.*\(\)" method is considered internal Used by the validator engine. Should not be called by user\s\*\s*code\. It may change without further notice\. You should not extend it from "[^"]+".%', - '%Non-object services are deprecated since Symfony 4\.4, please fix the ".*" service which is of type ".*" right now\.%', - '%Non-object services are deprecated since Symfony 4\.4, setting the ".*" service to a value of type ".*" should be avoided\.%', '%The ".*" service relies on the deprecated "Symfony\\\\Component\\\\Debug\\\\BufferingLogger" class\. It should either be deprecated or its implementation upgraded\.%', ]; return (bool) preg_filter($dynamic_skipped_deprecations, '$0', $message); diff --git a/core/tests/Drupal/Tests/TestFileCreationTrait.php b/core/tests/Drupal/Tests/TestFileCreationTrait.php index 27ee641b50a8193bb238722e6ccf29c5a1e3a1cf..3516f2eb8f4c7ab705124572abea56112af32f4b 100644 --- a/core/tests/Drupal/Tests/TestFileCreationTrait.php +++ b/core/tests/Drupal/Tests/TestFileCreationTrait.php @@ -70,7 +70,7 @@ protected function getTestFiles($type, $size = NULL) { } // Copy other test files from fixtures. - $original = \Drupal::service('app.root') . '/core/tests/fixtures/files'; + $original = \Drupal::root() . '/core/tests/fixtures/files'; $files = $file_system->scanDirectory($original, '/(html|image|javascript|php|sql)-.*/'); foreach ($files as $file) { $file_system->copy($file->uri, PublicStream::basePath());