diff --git a/core/authorize.php b/core/authorize.php index 114dcd3..32d765c 100644 --- a/core/authorize.php +++ b/core/authorize.php @@ -80,9 +80,9 @@ function authorize_access_allowed() { // display errors via the maintenance theme. $module_list['system'] = 'core/modules/system/system.module'; $module_list['user'] = 'core/modules/user/user.module'; -drupal_container()->get('module_handler')->setModuleList($module_list); -drupal_container()->get('module_handler')->load('system'); -drupal_container()->get('module_handler')->load('user'); +Drupal::service('module_handler')->setModuleList($module_list); +Drupal::service('module_handler')->load('system'); +Drupal::service('module_handler')->load('user'); // Initialize the language system. drupal_language_initialize(); diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc index a3a0f46..5c89480 100644 --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -890,10 +890,10 @@ function drupal_get_filename($type, $name, $filename = NULL) { // Verify that we have an keyvalue service before using it. This is required // because this function is called during installation. // @todo Inject database connection into KeyValueStore\DatabaseStorage. - if (($container = drupal_container()) && $container->has('keyvalue') && function_exists('db_query')) { + if (($container = Drupal::getContainer()) && $container->has('keyvalue') && function_exists('db_query')) { if ($type == 'module') { if (empty($files[$type])) { - $files[$type] = drupal_container()->get('module_handler')->getModuleList(); + $files[$type] = Drupal::service('module_handler')->getModuleList(); } if (isset($files[$type][$name])) { return $files[$type][$name]; @@ -1141,7 +1141,7 @@ function drupal_page_is_cacheable($allow_caching = NULL) { * @see bootstrap_hooks() */ function bootstrap_invoke_all($hook) { - $module_handler = drupal_container()->get('module_handler'); + $module_handler = Drupal::service('module_handler'); foreach ($module_handler->getBootstrapModules() as $module) { $module_handler->load($module); module_invoke($module, $hook); @@ -1162,8 +1162,8 @@ function bootstrap_invoke_all($hook) { * TRUE if the item is loaded or has already been loaded. */ function drupal_load($type, $name) { - if ($type == 'module' && drupal_container()->get('module_handler')->moduleExists($name)) { - return drupal_container()->get('module_handler')->load($name); + if ($type == 'module' && Drupal::service('module_handler')->moduleExists($name)) { + return Drupal::service('module_handler')->load($name); } // Once a file is included this can't be reversed during a request so do not @@ -2305,9 +2305,9 @@ function _drupal_bootstrap_configuration() { * Initialize the kernel / service container. */ function _drupal_bootstrap_kernel() { - // Normally, index.php puts a container in drupal_container() by creating a + // Normally, index.php puts a container in Drupal::getContainer() by creating a // kernel. If there is no container yet, create one. - if (!drupal_container()) { + if (!Drupal::getContainer()) { $kernel = new DrupalKernel('prod', FALSE, drupal_classloader()); $kernel->boot(); } @@ -2411,7 +2411,7 @@ function _drupal_bootstrap_variables() { $conf = variable_initialize(isset($conf) ? $conf : array()); // Load bootstrap modules. require_once DRUPAL_ROOT . '/core/includes/module.inc'; - drupal_container()->get('module_handler')->loadBootstrapModules(); + Drupal::service('module_handler')->loadBootstrapModules(); } /** @@ -2426,29 +2426,15 @@ function drupal_get_bootstrap_phase() { } /** - * Retrieves the Drupal Container to standardize object construction. - * - * @deprecated This function has been replaced by the \Drupal class. Use that - * instead. - * - * @return Symfony\Component\DependencyInjection\ContainerInterface|bool - * The instance of the ContainerInterface used to set up and maintain - * object instances or FALSE if none exist yet. - */ -function drupal_container() { - return Drupal::getContainer(); -} - -/** * Returns the list of enabled modules. * * @deprecated as of Drupal 8.0. Use - * drupal_container()->get('module_handler')->getModuleList(). + * Drupal::service('module_handler')->getModuleList(). * * @see \Drupal\Core\Extension\ModuleHandler::getModuleList() */ function module_list() { - $modules = array_keys(drupal_container()->get('module_handler')->getModuleList()); + $modules = array_keys(Drupal::service('module_handler')->getModuleList()); return array_combine($modules, $modules); } @@ -2456,19 +2442,19 @@ function module_list() { * Determines which modules are implementing a hook. * * @deprecated as of Drupal 8.0. Use - * drupal_container()->get('module_handler')->getImplementations($hook). + * Drupal::service('module_handler')->getImplementations($hook). * * @see \Drupal\Core\Extension\ModuleHandler::getImplementations() */ function module_implements($hook) { - return drupal_container()->get('module_handler')->getImplementations($hook); + return Drupal::service('module_handler')->getImplementations($hook); } /** * Invokes a hook in a particular module. * * @deprecated as of Drupal 8.0. Use - * drupal_container()->get('module_handler')->invoke($module, $hook, $args = array()). + * Drupal::service('module_handler')->invoke($module, $hook, $args = array()). * * @see \Drupal\Core\Extension\ModuleHandler::invoke() */ @@ -2476,14 +2462,14 @@ function module_invoke($module, $hook) { $args = func_get_args(); // Remove $module and $hook from the arguments. unset($args[0], $args[1]); - return drupal_container()->get('module_handler')->invoke($module, $hook, $args); + return Drupal::service('module_handler')->invoke($module, $hook, $args); } /** * Invokes a hook in all enabled modules that implement it. * * @deprecated as of Drupal 8.0. Use - * drupal_container()->get('module_handler')->invokeAll($hook). + * Drupal::service('module_handler')->invokeAll($hook). * * @see \Drupal\Core\Extension\ModuleHandler::invokeAll() */ @@ -2491,43 +2477,43 @@ function module_invoke_all($hook) { $args = func_get_args(); // Remove $hook from the arguments. array_shift($args); - return drupal_container()->get('module_handler')->invokeAll($hook, $args); + return Drupal::service('module_handler')->invokeAll($hook, $args); } /** * Passes alterable variables to specific hook_TYPE_alter() implementations. * * @deprecated as of Drupal 8.0. Use - * drupal_container()->get('module_handler')->alter($hook). + * Drupal::service('module_handler')->alter($hook). * * @see \Drupal\Core\Extension\ModuleHandler::alter() */ function drupal_alter($type, &$data, &$context1 = NULL, &$context2 = NULL) { - return drupal_container()->get('module_handler')->alter($type, $data, $context1, $context2); + return Drupal::service('module_handler')->alter($type, $data, $context1, $context2); } /** * Determines whether a given module exists. * * @deprecated as of Drupal 8.0. Use - * drupal_container()->get('module_handler')->moduleExists($hook). + * Drupal::service('module_handler')->moduleExists($hook). * * @see \Drupal\Core\Extension\ModuleHandler::moduleExists() */ function module_exists($module) { - return drupal_container()->get('module_handler')->moduleExists($module); + return Drupal::service('module_handler')->moduleExists($module); } /** * Determines whether a module implements a hook. * * @deprecated as of Drupal 8.0. Use - * drupal_container()->get('module_handler')->implementsHook($module, $hook). + * Drupal::service('module_handler')->implementsHook($module, $hook). * * @see \Drupal\Core\Extension\ModuleHandler::implementsHook() */ function module_hook($module, $hook) { - return drupal_container()->get('module_handler')->implementsHook($module, $hook); + return Drupal::service('module_handler')->implementsHook($module, $hook); } /** @@ -2542,7 +2528,7 @@ function module_hook($module, $hook) { * @return Drupal\Core\KeyValueStore\KeyValueStoreInterface */ function state() { - return drupal_container()->get('keyvalue')->get('state'); + return Drupal::service('keyvalue')->get('state'); } /** @@ -2561,7 +2547,7 @@ function typed_data() { $drupal_static_fast['manager'] = &drupal_static(__FUNCTION__); } if (!isset($drupal_static_fast['manager'])) { - $drupal_static_fast['manager'] = drupal_container()->get('typed_data'); + $drupal_static_fast['manager'] = Drupal::service('typed_data'); } return $drupal_static_fast['manager']; } @@ -2695,7 +2681,7 @@ function get_t() { * @see language() */ function drupal_language_initialize() { - drupal_container()->get('language_manager')->init(); + Drupal::service('language_manager')->init(); } /** @@ -2707,7 +2693,7 @@ function drupal_language_initialize() { * The type of language object needed, e.g. LANGUAGE_TYPE_INTERFACE. */ function language($type) { - $container = drupal_container(); + $container = Drupal::getContainer(); if (!$container) { return language_default(); } diff --git a/core/includes/common.inc b/core/includes/common.inc index 88d6fd3..c82928b 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -2124,7 +2124,7 @@ function url($path = NULL, array $options = array()) { } elseif (!empty($path) && !$options['alias']) { $langcode = isset($options['language']) && isset($options['language']->langcode) ? $options['language']->langcode : ''; - $alias = drupal_container()->get('path.alias_manager')->getPathAlias($original_path, $langcode); + $alias = Drupal::service('path.alias_manager')->getPathAlias($original_path, $langcode); if ($alias != $original_path) { $path = $alias; } @@ -2247,7 +2247,7 @@ function l($text, $path, array $options = array()) { // (e.g., pagers). $is_active = ($path == current_path() || ($path == '' && drupal_is_front_page())); $is_active = $is_active && (empty($options['language']) || $options['language']->langcode == language(LANGUAGE_TYPE_URL)->langcode); - $is_active = $is_active && (drupal_container()->get('request')->query->all() == $options['query']); + $is_active = $is_active && (Drupal::service('request')->query->all() == $options['query']); if ($is_active) { $options['attributes']['class'][] = 'active'; } @@ -3840,7 +3840,7 @@ function drupal_get_js($scope = 'header', $javascript = NULL, $skip_alter = FALS // Don't add settings if there is no other JavaScript on the page, unless // this is an AJAX request. // @todo Clean up container call. - $container = drupal_container(); + $container = Drupal::getContainer(); if ($container->has('content_negotiation') && $container->isScopeActive('request')) { $type = $container->get('content_negotiation')->getContentType($container->get('request')); } @@ -4877,7 +4877,7 @@ function _drupal_bootstrap_code() { require_once DRUPAL_ROOT . '/core/includes/entity.inc'; // Load all enabled modules - drupal_container()->get('module_handler')->loadAll(); + Drupal::service('module_handler')->loadAll(); // Make sure all stream wrappers are registered. file_get_stream_wrappers(); @@ -6378,7 +6378,7 @@ function drupal_flush_all_caches() { // Clear all non-drupal_static() static caches. // @todo Rebuild the kernel/container. - drupal_container()->get('plugin.manager.entity')->clearCachedDefinitions(); + Drupal::service('plugin.manager.entity')->clearCachedDefinitions(); // Rebuild module and theme data. system_rebuild_module_data(); @@ -6386,7 +6386,7 @@ function drupal_flush_all_caches() { // Ensure that all modules that are currently supposed to be enabled are // actually loaded. - drupal_container()->get('module_handler')->loadAll(); + Drupal::service('module_handler')->loadAll(); // Update the list of bootstrap modules. // Allows developers to get new bootstrap hooks implementations registered @@ -6407,7 +6407,7 @@ function drupal_flush_all_caches() { // Rebuild the menu router based on all rebuilt data. // Important: This rebuild must happen last, so the menu router is guaranteed // to be based on up to date information. - drupal_container()->get('router.builder')->rebuild(); + Drupal::service('router.builder')->rebuild(); menu_router_rebuild(); // Wipe the PHP Storage caches. @@ -6684,7 +6684,7 @@ function drupal_get_filetransfer_info() { * @see Drupal\Core\Queue\QueueInterface */ function queue($name, $reliable = FALSE) { - return drupal_container()->get('queue')->get($name, $reliable); + return Drupal::service('queue')->get($name, $reliable); } /** diff --git a/core/includes/config.inc b/core/includes/config.inc index 3591263..f7708c7 100644 --- a/core/includes/config.inc +++ b/core/includes/config.inc @@ -37,7 +37,7 @@ function config_install_default_config($type, $name) { $config_dir = drupal_get_path($type, $name) . '/config'; if (is_dir($config_dir)) { $source_storage = new FileStorage($config_dir); - $target_storage = drupal_container()->get('config.storage'); + $target_storage = Drupal::service('config.storage'); // Ignore manifest files. $config_changes = config_sync_get_changes($source_storage, $target_storage, FALSE); @@ -64,7 +64,7 @@ function config_install_default_config($type, $name) { * The name of the module or theme to install default configuration for. */ function config_uninstall_default_config($type, $name) { - $storage = drupal_container()->get('config.storage'); + $storage = Drupal::service('config.storage'); $config_names = $storage->listAll($name . '.'); foreach ($config_names as $config_name) { config($config_name)->delete(); @@ -83,7 +83,7 @@ function config_uninstall_default_config($type, $name) { * @see Drupal\Core\Config\StorageInterface::listAll() */ function config_get_storage_names_with_prefix($prefix = '') { - return drupal_container()->get('config.storage')->listAll($prefix); + return Drupal::service('config.storage')->listAll($prefix); } /** @@ -102,7 +102,7 @@ function config_get_storage_names_with_prefix($prefix = '') { * A configuration object. */ function config($name) { - return drupal_container()->get('config.factory')->get($name); + return Drupal::service('config.factory')->get($name); } /** @@ -124,18 +124,18 @@ function config($name) { * The configuration context object. */ function config_context_enter($context_name) { - if (drupal_container()->has($context_name)) { - $context = drupal_container()->get($context_name); + if (Drupal::getContainer()->has($context_name)) { + $context = Drupal::getContainer()->get($context_name); } elseif (class_exists($context_name) && in_array('Drupal\Core\Config\Context\ContextInterface', class_implements($context_name))) { - $context = drupal_container() + $context = Drupal::getContainer() ->get('config.context.factory') ->get($context_name); } else { throw new ConfigException(sprintf('Unknown config context service or class: %s', $context_name)); } - drupal_container() + Drupal::getContainer() ->get('config.factory') ->enterContext($context); return $context; @@ -148,7 +148,7 @@ function config_context_enter($context_name) { * @see \Drupal\Core\Config\ConfigFactory */ function config_context_leave() { - drupal_container() + Drupal::getContainer() ->get('config.factory') ->leaveContext(); } @@ -238,8 +238,8 @@ function config_sync_get_changes(StorageInterface $source_storage, StorageInterf * The storage to synchronize configuration to. */ function config_sync_changes(array $config_changes, StorageInterface $source_storage, StorageInterface $target_storage) { - $target_context = drupal_container()->get('config.context.free'); - $factory = drupal_container()->get('config.factory'); + $target_context = Drupal::service('config.context.free'); + $factory = Drupal::service('config.factory'); foreach (array('delete', 'create', 'change') as $op) { foreach ($config_changes[$op] as $name) { $config = new Config($name, $target_storage, $target_context); @@ -265,9 +265,9 @@ function config_sync_changes(array $config_changes, StorageInterface $source_sto */ function config_import() { // Retrieve a list of differences between staging and the active configuration. - $source_storage = drupal_container()->get('config.storage.staging'); - $snapshot_storage = drupal_container()->get('config.storage.snapshot'); - $target_storage = drupal_container()->get('config.storage'); + $source_storage = Drupal::service('config.storage.staging'); + $snapshot_storage = Drupal::service('config.storage.snapshot'); + $target_storage = Drupal::service('config.storage'); $config_changes = config_sync_get_changes($source_storage, $target_storage); if (empty($config_changes)) { @@ -333,15 +333,15 @@ function config_import_create_snapshot(StorageInterface $source_storage, Storage * @todo Add support for other extension types; e.g., themes etc. */ function config_import_invoke_owner(array $config_changes, StorageInterface $source_storage, StorageInterface $target_storage) { - $factory = drupal_container()->get('config.factory'); + $factory = Drupal::service('config.factory'); // Use the admin context for config importing so that any overrides do not // change the data on import. - $free_context = drupal_container()->get('config.context.free'); + $free_context = Drupal::service('config.context.free'); // Allow modules to take over configuration change operations for // higher-level configuration data. // First pass deleted, then new, and lastly changed configuration, in order to // handle dependencies correctly. - $manager = drupal_container()->get('plugin.manager.entity'); + $manager = Drupal::service('plugin.manager.entity'); foreach (array('delete', 'create', 'change') as $op) { foreach ($config_changes[$op] as $key => $name) { // Call to the configuration entity's storage controller to handle the @@ -365,7 +365,7 @@ function config_import_invoke_owner(array $config_changes, StorageInterface $sou if (!empty($handled_by_module)) { $factory->reset($name); // Reset the manifest config object for the config entity. - $entity_info = drupal_container()->get('plugin.manager.entity')->getDefinition($entity_type); + $entity_info = Drupal::service('plugin.manager.entity')->getDefinition($entity_type); $factory->reset('manifest.' . $entity_info['config_prefix']); unset($config_changes[$op][$key]); } @@ -420,5 +420,5 @@ function config_get_entity_type_by_name($name) { * @return Drupal\Core\TypedData\TypedConfigManager */ function config_typed() { - return drupal_container()->get('config.typed'); + return Drupal::service('config.typed'); } diff --git a/core/includes/entity.inc b/core/includes/entity.inc index 708706e..26c8a44 100644 --- a/core/includes/entity.inc +++ b/core/includes/entity.inc @@ -28,10 +28,10 @@ */ function entity_get_info($entity_type = NULL) { if (empty($entity_type)) { - return drupal_container()->get('plugin.manager.entity')->getDefinitions(); + return Drupal::service('plugin.manager.entity')->getDefinitions(); } else { - return drupal_container()->get('plugin.manager.entity')->getDefinition($entity_type); + return Drupal::service('plugin.manager.entity')->getDefinition($entity_type); } } @@ -42,7 +42,7 @@ function entity_info_cache_clear() { drupal_static_reset('entity_get_view_modes'); drupal_static_reset('entity_get_bundles'); // Clear all languages. - drupal_container()->get('plugin.manager.entity')->clearCachedDefinitions(); + Drupal::service('plugin.manager.entity')->clearCachedDefinitions(); } /** @@ -167,7 +167,7 @@ function entity_load($entity_type, $id, $reset = FALSE) { * @see Drupal\Core\Entity\DatabaseStorageController */ function entity_revision_load($entity_type, $revision_id) { - return drupal_container()->get('plugin.manager.entity') + return Drupal::service('plugin.manager.entity') ->getStorageController($entity_type) ->loadRevision($revision_id); } @@ -181,7 +181,7 @@ function entity_revision_load($entity_type, $revision_id) { * The revision ID to delete. */ function entity_revision_delete($entity_type, $revision_id) { - drupal_container()->get('plugin.manager.entity') + Drupal::service('plugin.manager.entity') ->getStorageController($entity_type) ->deleteRevision($revision_id); } @@ -213,7 +213,7 @@ function entity_load_by_uuid($entity_type, $uuid, $reset = FALSE) { } $uuid_key = $entity_info['entity_keys']['uuid']; - $controller = drupal_container()->get('plugin.manager.entity')->getStorageController($entity_type); + $controller = Drupal::service('plugin.manager.entity')->getStorageController($entity_type); if ($reset) { $controller->resetCache(); } @@ -255,7 +255,7 @@ function entity_load_by_uuid($entity_type, $uuid, $reset = FALSE) { * @see Drupal\Core\Entity\Query\QueryInterface */ function entity_load_multiple($entity_type, array $ids = NULL, $reset = FALSE) { - $controller = drupal_container()->get('plugin.manager.entity')->getStorageController($entity_type); + $controller = Drupal::service('plugin.manager.entity')->getStorageController($entity_type); if ($reset) { $controller->resetCache(); } @@ -275,7 +275,7 @@ function entity_load_multiple($entity_type, array $ids = NULL, $reset = FALSE) { * An array of entity objects indexed by their ids. */ function entity_load_multiple_by_properties($entity_type, array $values) { - return drupal_container()->get('plugin.manager.entity') + return Drupal::service('plugin.manager.entity') ->getStorageController($entity_type) ->loadByProperties($values); } @@ -297,7 +297,7 @@ function entity_load_multiple_by_properties($entity_type, array $values) { * The unchanged entity, or FALSE if the entity cannot be loaded. */ function entity_load_unchanged($entity_type, $id) { - return drupal_container()->get('plugin.manager.entity') + return Drupal::service('plugin.manager.entity') ->getStorageController($entity_type) ->loadUnchanged($id); } @@ -311,7 +311,7 @@ function entity_load_unchanged($entity_type, $id) { * An array of entity IDs of the entities to delete. */ function entity_delete_multiple($entity_type, array $ids) { - $controller = drupal_container()->get('plugin.manager.entity')->getStorageController($entity_type); + $controller = Drupal::service('plugin.manager.entity')->getStorageController($entity_type); $entities = $controller->load($ids); $controller->delete($entities); } @@ -329,7 +329,7 @@ function entity_delete_multiple($entity_type, array $ids) { * A new entity object. */ function entity_create($entity_type, array $values) { - return drupal_container()->get('plugin.manager.entity') + return Drupal::service('plugin.manager.entity') ->getStorageController($entity_type) ->create($values); } @@ -342,7 +342,7 @@ function entity_create($entity_type, array $values) { * @deprecated Use \Drupal\Core\Entity\EntityManager::getStorageController(). */ function entity_get_controller($entity_type) { - return drupal_container()->get('plugin.manager.entity') + return Drupal::service('plugin.manager.entity') ->getStorageController($entity_type); } @@ -380,7 +380,7 @@ function entity_page_label(EntityInterface $entity, $langcode = NULL) { * @deprecated Use \Drupal\Core\Entity\EntityManager::getRenderController(). */ function entity_access_controller($entity_type) { - return drupal_container()->get('plugin.manager.entity') + return Drupal::service('plugin.manager.entity') ->getAccessController($entity_type); } @@ -408,7 +408,7 @@ function entity_access_controller($entity_type) { * @deprecated Use \Drupal\Core\Entity\EntityManager::getFormController(). */ function entity_form_controller($entity_type, $operation = 'default') { - return drupal_container()->get('plugin.manager.entity') + return Drupal::service('plugin.manager.entity') ->getFormController($entity_type, $operation); } @@ -449,7 +449,7 @@ function entity_form_id(EntityInterface $entity, $operation = 'default') { */ function entity_form_state_defaults(EntityInterface $entity, $operation = 'default') { $form_state = array(); - $controller = drupal_container()->get('plugin.manager.entity')->getFormController($entity->entityType(), $operation); + $controller = Drupal::service('plugin.manager.entity')->getFormController($entity->entityType(), $operation); $form_state['build_info']['callback'] = array($controller, 'build'); $form_state['build_info']['base_form_id'] = $entity->entityType() . '_form'; $form_state['build_info']['args'] = array($entity); @@ -557,7 +557,7 @@ function entity_form_submit_build_entity($entity_type, $entity, $form, &$form_st * @deprecated Use \Drupal\Core\Entity\EntityManager::getFormController(). */ function entity_list_controller($entity_type) { - return drupal_container()->get('plugin.manager.entity') + return Drupal::service('plugin.manager.entity') ->getListController($entity_type); } @@ -573,7 +573,7 @@ function entity_list_controller($entity_type) { * @deprecated Use \Drupal\Core\Entity\EntityManager::getFormController(). */ function entity_render_controller($entity_type) { - return drupal_container()->get('plugin.manager.entity') + return Drupal::service('plugin.manager.entity') ->getRenderController($entity_type); } @@ -592,7 +592,7 @@ function entity_render_controller($entity_type) { * A render array for the entity. */ function entity_view(EntityInterface $entity, $view_mode, $langcode = NULL) { - return drupal_container()->get('plugin.manager.entity') + return Drupal::service('plugin.manager.entity') ->getRenderController($entity->entityType()) ->view($entity, $view_mode, $langcode); } @@ -613,7 +613,7 @@ function entity_view(EntityInterface $entity, $view_mode, $langcode = NULL) { * entities array passed in $entities. */ function entity_view_multiple(array $entities, $view_mode, $langcode = NULL) { - return drupal_container()->get('plugin.manager.entity') + return Drupal::service('plugin.manager.entity') ->getRenderController(reset($entities)->entityType()) ->viewMultiple($entities, $view_mode, $langcode); } @@ -731,7 +731,7 @@ function entity_get_render_display(EntityInterface $entity, $view_mode) { * The query object that can query the given entity type. */ function entity_query($entity_type, $conjunction = 'AND') { - return drupal_container()->get('entity.query')->get($entity_type, $conjunction); + return Drupal::service('entity.query')->get($entity_type, $conjunction); } /** @@ -748,7 +748,7 @@ function entity_query($entity_type, $conjunction = 'AND') { * The query object that can query the given entity type. */ function entity_query_aggregate($entity_type, $conjunction = 'AND') { - return drupal_container()->get('entity.query')->getAggregate($entity_type, $conjunction); + return Drupal::service('entity.query')->getAggregate($entity_type, $conjunction); } /** @@ -779,7 +779,7 @@ function entity_page_access(EntityInterface $entity, $operation = 'view') { * TRUE if the access is granted. FALSE if access is denied. */ function entity_page_create_access($entity_type) { - $entity = drupal_container()->get('plugin.manager.entity') + $entity = Drupal::service('plugin.manager.entity') ->getStorageController($entity_type) ->create(array()); return $entity->access('create'); diff --git a/core/includes/form.inc b/core/includes/form.inc index 3ebaca1..2a6c64f 100644 --- a/core/includes/form.inc +++ b/core/includes/form.inc @@ -1323,7 +1323,7 @@ function drupal_redirect_form($form_state) { $function($form_state['redirect']); } } - drupal_goto(current_path(), array('query' => drupal_container()->get('request')->query->all())); + drupal_goto(current_path(), array('query' => Drupal::service('request')->query->all())); } } diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc index e2e8c27..2d750e3 100644 --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -304,7 +304,7 @@ function install_begin_request(&$install_state) { // If it is not, replace the configuration storage with the InstallStorage // implementation, for the following reasons: - // - The first call into drupal_container() will try to set up the regular + // - The first call into Drupal::getContainer() will try to set up the regular // runtime configuration storage, using the CachedStorage by default. It // calls config_get_config_directory() to retrieve the config directory to // use, but that throws an exception, since $config_directories is not @@ -382,7 +382,7 @@ function install_begin_request(&$install_state) { require_once DRUPAL_ROOT . '/core/includes/ajax.inc'; - $module_handler = drupal_container()->get('module_handler'); + $module_handler = Drupal::service('module_handler'); if (!$module_handler->moduleExists('system')) { // Override the module list with a minimal set of modules. $module_handler->setModuleList(array('system' => 'core/modules/system/system.module')); @@ -1510,7 +1510,7 @@ function install_retrieve_file($uri, $destination) { } try { - $request = drupal_container()->get('http_default_client')->get($uri, array('Accept' => 'text/plain')); + $request = Drupal::service('http_default_client')->get($uri, array('Accept' => 'text/plain')); $data = $request->send()->getBody(TRUE); if (empty($data)) { return FALSE; @@ -1533,7 +1533,7 @@ function install_retrieve_file($uri, $destination) { */ function install_check_localization_server($uri) { try { - $request = drupal_container()->get('http_default_client')->head($uri); + $request = Drupal::service('http_default_client')->head($uri); $response = $request->send(); return TRUE; } @@ -1863,8 +1863,8 @@ function install_finished(&$install_state) { drupal_cron_run(); // Save a snapshot of the intially installed configuration. - $active = drupal_container()->get('config.storage'); - $snapshot = drupal_container()->get('config.storage.snapshot'); + $active = Drupal::service('config.storage'); + $snapshot = Drupal::service('config.storage.snapshot'); config_import_create_snapshot($active, $snapshot); return $output; diff --git a/core/includes/install.inc b/core/includes/install.inc index 088413a..3f0ba5a 100644 --- a/core/includes/install.inc +++ b/core/includes/install.inc @@ -417,7 +417,7 @@ function drupal_install_system() { require_once DRUPAL_ROOT . '/' . $system_path . '/system.install'; $system_versions = drupal_get_schema_versions('system'); $system_version = $system_versions ? max($system_versions) : SCHEMA_INSTALLED; - drupal_container() + Drupal::getContainer() ->get('keyvalue') ->get('system.schema') ->set('system', $system_version); @@ -431,7 +431,7 @@ function drupal_install_system() { ->save(); // Update the module list to include it. - drupal_container()->get('module_handler')->setModuleList(array('system' => $system_path . '/system.module')); + Drupal::service('module_handler')->setModuleList(array('system' => $system_path . '/system.module')); config_install_default_config('module', 'system'); diff --git a/core/includes/menu.inc b/core/includes/menu.inc index d719571..90d03d4 100644 --- a/core/includes/menu.inc +++ b/core/includes/menu.inc @@ -900,7 +900,7 @@ function _menu_link_translate(&$item, $translate = FALSE) { if (!isset($item['access'])) { if ($route = $item->getRoute()) { $request = Request::create('/' . $item['path']); - $item['access'] = drupal_container()->get('access_manager')->check($route, $request); + $item['access'] = Drupal::service('access_manager')->check($route, $request); } elseif (!empty($item['load_functions']) && !_menu_load_objects($item, $map)) { // An error occurred loading an object. @@ -2047,7 +2047,7 @@ function menu_local_tasks($level = 0) { $data['tabs'] = $tabs; // Allow modules to dynamically add further tasks. - $module_handler = drupal_container()->get('module_handler'); + $module_handler = Drupal::service('module_handler'); foreach ($module_handler->getImplementations('menu_local_tasks') as $module) { $function = $module . '_menu_local_tasks'; $function($data, $router_item, $root_path); @@ -2587,7 +2587,7 @@ function menu_cache_clear_all() { * Resets the menu system static cache. */ function menu_reset_static_cache() { - drupal_container()->get('plugin.manager.entity') + Drupal::service('plugin.manager.entity') ->getStorageController('menu_link')->resetCache(); drupal_static_reset('_menu_build_tree'); drupal_static_reset('menu_tree'); @@ -2687,7 +2687,7 @@ function menu_router_build() { function _menu_router_merge_route(array $router_item, $path) { $router_item['path'] = $path; - $route_provider = drupal_container()->get('router.route_provider'); + $route_provider = Drupal::service('router.route_provider'); $route = $route_provider->getRouteByName($router_item['route_name']); $router_item['path'] = trim($route->getPattern(), '/'); @@ -2730,7 +2730,7 @@ function menu_get_router() { */ function _menu_navigation_links_rebuild($menu) { if (module_exists('menu_link')) { - $menu_link_controller = drupal_container()->get('plugin.manager.entity') + $menu_link_controller = Drupal::service('plugin.manager.entity') ->getStorageController('menu_link'); } else { diff --git a/core/includes/module.inc b/core/includes/module.inc index 99eac78..fd334d3 100644 --- a/core/includes/module.inc +++ b/core/includes/module.inc @@ -284,10 +284,10 @@ function module_enable($module_list, $enable_dependencies = TRUE) { $modules_installed = array(); $modules_enabled = array(); - $schema_store = drupal_container()->get('keyvalue')->get('system.schema'); + $schema_store = Drupal::service('keyvalue')->get('system.schema'); $module_config = config('system.module'); $disabled_config = config('system.module.disabled'); - $module_handler = drupal_container()->get('module_handler'); + $module_handler = Drupal::service('module_handler'); foreach ($module_list as $module) { // Only process modules that are not already enabled. // A module is only enabled if it is configured as enabled. Custom or @@ -352,7 +352,7 @@ function module_enable($module_list, $enable_dependencies = TRUE) { // taken over as %container.modules% parameter, which is passed to a fresh // ModuleHandler instance upon first retrieval. // @todo install_begin_request() creates a container without a kernel. - if ($kernel = drupal_container()->get('kernel', ContainerInterface::NULL_ON_INVALID_REFERENCE)) { + if ($kernel = Drupal::getContainer()->get('kernel', ContainerInterface::NULL_ON_INVALID_REFERENCE)) { $kernel->updateModules($module_filenames, $module_filenames); } @@ -463,7 +463,7 @@ function module_disable($module_list, $disable_dependents = TRUE) { $module_config = config('system.module'); $disabled_config = config('system.module.disabled'); - $module_handler = drupal_container()->get('module_handler'); + $module_handler = Drupal::service('module_handler'); foreach ($module_list as $module) { // Only process modules that are enabled. // A module is only enabled if it is configured as enabled. Custom or @@ -511,7 +511,7 @@ function module_disable($module_list, $disable_dependents = TRUE) { // Update the kernel to exclude the disabled modules. $enabled = $module_handler->getModuleList(); - drupal_container()->get('kernel')->updateModules($enabled, $enabled); + Drupal::service('kernel')->updateModules($enabled, $enabled); // Update the theme registry to remove the newly-disabled module. drupal_theme_rebuild(); @@ -566,8 +566,8 @@ function module_uninstall($module_list = array(), $uninstall_dependents = TRUE) $module_list = array_keys($module_list); } - $storage = drupal_container()->get('config.storage'); - $schema_store = drupal_container()->get('keyvalue')->get('system.schema'); + $storage = Drupal::service('config.storage'); + $schema_store = Drupal::service('keyvalue')->get('system.schema'); $disabled_config = config('system.module.disabled'); foreach ($module_list as $module) { // Uninstall the module. @@ -663,7 +663,7 @@ function module_set_weight($module, $weight) { // Prepare the new module list, sorted by weight, including filenames. // @see module_enable() - $module_handler = drupal_container()->get('module_handler'); + $module_handler = Drupal::service('module_handler'); $current_module_filenames = $module_handler->getModuleList(); $current_modules = array_fill_keys(array_keys($current_module_filenames), 0); $current_modules = module_config_sort(array_merge($current_modules, $module_config->get('enabled'))); diff --git a/core/includes/path.inc b/core/includes/path.inc index 182c0c8..be6fb12 100644 --- a/core/includes/path.inc +++ b/core/includes/path.inc @@ -86,8 +86,8 @@ function current_path() { // @todo Remove the check for whether the request service exists and the // fallback code below, once the path alias logic has been figured out in // http://drupal.org/node/1269742. - if (drupal_container()->isScopeActive('request')) { - $path = drupal_container()->get('request')->attributes->get('system_path'); + if (Drupal::getContainer()->isScopeActive('request')) { + $path = Drupal::service('request')->attributes->get('system_path'); if ($path !== NULL) { return $path; } @@ -116,7 +116,7 @@ function path_load($conditions) { elseif (!is_array($conditions)) { return FALSE; } - return drupal_container()->get('path.crud')->load($conditions); + return Drupal::service('path.crud')->load($conditions); } /** @@ -241,7 +241,7 @@ function _drupal_valid_path_new_router($path) { $request = Request::create('/' . $path); $request->attributes->set('system_path', $path); try { - $dc = drupal_container(); + $dc = Drupal::getContainer(); $route = $dc->get('router.dynamic')->matchRequest($request); if (!empty($route)) { $dc->get('access_manager')->check($route['_route_object'], $request); diff --git a/core/includes/schema.inc b/core/includes/schema.inc index e599923..1fe59b4 100644 --- a/core/includes/schema.inc +++ b/core/includes/schema.inc @@ -77,7 +77,7 @@ function drupal_get_complete_schema($rebuild = FALSE) { else { $schema = array(); // Load the .install files to get hook_schema. - drupal_container()->get('module_handler')->loadAllIncludes('install'); + Drupal::service('module_handler')->loadAllIncludes('install'); require_once DRUPAL_ROOT . '/core/includes/common.inc'; // Invoke hook_schema for all modules. @@ -121,7 +121,7 @@ function drupal_get_schema_versions($module) { $updates = &drupal_static(__FUNCTION__, NULL); if (!isset($updates[$module])) { $updates = array(); - foreach (drupal_container()->get('module_handler')->getModuleList() as $loaded_module => $filename) { + foreach (Drupal::service('module_handler')->getModuleList() as $loaded_module => $filename) { $updates[$loaded_module] = array(); } @@ -173,7 +173,7 @@ function drupal_get_installed_schema_version($module, $reset = FALSE, $array = F } if (!$versions) { - if (!$versions = drupal_container()->get('keyvalue')->get('system.schema')->getAll()) { + if (!$versions = Drupal::service('keyvalue')->get('system.schema')->getAll()) { $versions = array(); } } @@ -195,7 +195,7 @@ function drupal_get_installed_schema_version($module, $reset = FALSE, $array = F * The new schema version. */ function drupal_set_installed_schema_version($module, $version) { - drupal_container()->get('keyvalue')->get('system.schema')->set($module, $version); + Drupal::service('keyvalue')->get('system.schema')->set($module, $version); // Reset the static cache of module schema versions. drupal_get_installed_schema_version(NULL, TRUE); } diff --git a/core/includes/theme.inc b/core/includes/theme.inc index 0edb028..8b83bc1 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -368,14 +368,14 @@ function _theme_load_registry($theme, $base_theme = NULL, $theme_engine = NULL, $registry = _theme_build_registry($theme, $base_theme, $theme_engine); // Only persist this registry if all modules are loaded. This assures a // complete set of theme hooks. - if (drupal_container()->get('module_handler')->isLoaded()) { + if (Drupal::service('module_handler')->isLoaded()) { _theme_save_registry($theme, $registry); } } return $registry; } else { - return new ThemeRegistry('theme_registry:runtime:' . $theme->name, 'cache', array('theme_registry' => TRUE), drupal_container()->get('module_handler')->isLoaded()); + return new ThemeRegistry('theme_registry:runtime:' . $theme->name, 'cache', array('theme_registry' => TRUE), Drupal::service('module_handler')->isLoaded()); } } @@ -547,7 +547,7 @@ function _theme_process_registry(&$cache, $name, $type, $theme, $path) { // Add all modules so they can intervene with their own variable // processors. This allows them to provide variable processors even // if they are not the owner of the current hook. - $prefixes = array_merge($prefixes, array_keys(drupal_container()->get('module_handler')->getModuleList())); + $prefixes = array_merge($prefixes, array_keys(Drupal::service('module_handler')->getModuleList())); } elseif ($type == 'theme_engine' || $type == 'base_theme_engine') { // Theme engines get an extra set that come before the normally @@ -643,7 +643,7 @@ function _theme_build_registry($theme, $base_theme, $theme_engine) { _theme_process_registry($cache, $module, 'module', $module, drupal_get_path('module', $module)); } // Only cache this registry if all modules are loaded. - if (drupal_container()->get('module_handler')->isLoaded()) { + if (Drupal::service('module_handler')->isLoaded()) { cache()->set("theme_registry:build:modules", $cache, CacheBackendInterface::CACHE_PERMANENT, array('theme_registry' => TRUE)); } } @@ -958,7 +958,7 @@ function theme($hook, $variables = array()) { // If called before all modules are loaded, we do not necessarily have a full // theme registry to work with, and therefore cannot process the theme // request properly. See also _theme_load_registry(). - if (!drupal_container()->get('module_handler')->isLoaded() && !defined('MAINTENANCE_MODE')) { + if (!Drupal::service('module_handler')->isLoaded() && !defined('MAINTENANCE_MODE')) { throw new Exception(t('theme() may not be called until all modules are loaded.')); } diff --git a/core/includes/theme.maintenance.inc b/core/includes/theme.maintenance.inc index 37775e6..d83131e 100644 --- a/core/includes/theme.maintenance.inc +++ b/core/includes/theme.maintenance.inc @@ -56,7 +56,7 @@ function _drupal_maintenance_theme() { // Ensure that system.module is loaded. if (!function_exists('_system_rebuild_theme_data')) { $module_list['system'] = 'core/modules/system/system.module'; - $module_handler = drupal_container()->get('module_handler'); + $module_handler = Drupal::service('module_handler'); $module_handler->setModuleList($module_list); $module_handler->load('system'); } diff --git a/core/includes/update.inc b/core/includes/update.inc index bf11562..bd44d1d 100644 --- a/core/includes/update.inc +++ b/core/includes/update.inc @@ -139,7 +139,7 @@ function update_prepare_d8_bootstrap() { include_once DRUPAL_ROOT . '/core/includes/module.inc'; include_once DRUPAL_ROOT . '/core/includes/cache.inc'; - $module_handler = drupal_container()->get('module_handler'); + $module_handler = Drupal::service('module_handler'); $module_handler->setModuleList(array('system' => 'core/modules/system/system.module')); $module_handler->load('system'); // Ensure the configuration directories exist and are writable, or create @@ -343,7 +343,7 @@ function update_prepare_d8_bootstrap() { $disabled_modules = config('system.module.disabled'); $theme_config = config('system.theme'); $disabled_themes = config('system.theme.disabled'); - $schema_store = drupal_container()->get('keyvalue')->get('system.schema'); + $schema_store = Drupal::service('keyvalue')->get('system.schema'); // Load system.module, because update_prepare_d8_bootstrap() is called in // the initial minimal update.php bootstrap that performs the core @@ -365,7 +365,7 @@ function update_prepare_d8_bootstrap() { // Populate a fixed module list (again, why did it get lost?) to avoid // errors due to the drupal_alter() in _system_rebuild_module_data(). $module_list['system'] = 'core/modules/system/system.module'; - drupal_container()->get('module_handler')->setModuleList($module_list); + Drupal::service('module_handler')->setModuleList($module_list); $module_data = _system_rebuild_module_data(); // Migrate each extension into configuration, varying by the extension's @@ -395,7 +395,7 @@ function update_prepare_d8_bootstrap() { foreach (array_keys($sorted_modules) as $m) { $sorted_with_filenames[$m] = drupal_get_filename('module', $m); } - drupal_container()->get('module_handler')->setModuleList($sorted_with_filenames); + Drupal::service('module_handler')->setModuleList($sorted_with_filenames); $disabled_modules->save(); $theme_config->save(); $disabled_themes->save(); @@ -663,7 +663,7 @@ function update_fix_d8_requirements() { * if the module was not installed before. */ function update_module_enable(array $modules, $schema_version = 0) { - $schema_store = drupal_container()->get('keyvalue')->get('system.schema'); + $schema_store = Drupal::service('keyvalue')->get('system.schema'); $old_schema = array(); foreach ($modules as $module) { // Check for initial schema and install it. The schema version of a newly @@ -1237,7 +1237,7 @@ function update_retrieve_dependencies() { $return = array(); // Get a list of installed modules, arranged so that we invoke their hooks in // the same order that module_invoke_all() does. - foreach (drupal_container()->get('keyvalue')->get('system.schema')->getAll() as $module => $schema) { + foreach (Drupal::service('keyvalue')->get('system.schema')->getAll() as $module => $schema) { if ($schema == SCHEMA_UNINSTALLED) { // Nothing to upgrade. continue; diff --git a/core/lib/Drupal.php b/core/lib/Drupal.php index 5b0b502..45e9357 100644 --- a/core/lib/Drupal.php +++ b/core/lib/Drupal.php @@ -97,7 +97,7 @@ public static function setContainer(ContainerInterface $container) { * Returns the currently active global container. * * @deprecated This method is only useful for the testing environment, and as - * a BC shiv for drupal_container(). It should not be used otherwise. + * a BC shiv for Drupal::getContainer(). It should not be used otherwise. * * @return \Symfony\Component\DependencyInjection\ContainerInterface */ diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php b/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php index 92e4be3..48d822b 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php @@ -225,7 +225,7 @@ protected function buildQuery($ids, $revision_id = FALSE) { // Load all of the configuration entities. if ($ids === NULL) { - $names = drupal_container()->get('config.storage')->listAll($prefix); + $names = Drupal::service('config.storage')->listAll($prefix); $result = array(); foreach ($names as $name) { $config = config($name); @@ -369,7 +369,7 @@ public function save(EntityInterface $entity) { // - Storage controller needs to access the original object. // - The object needs to be renamed/copied in ConfigFactory and reloaded. // - All instances of the object need to be renamed. - drupal_container()->get('config.factory')->rename($prefix . $id, $prefix . $entity->id()); + Drupal::service('config.factory')->rename($prefix . $id, $prefix . $entity->id()); } if (!$is_new && !isset($entity->original)) { diff --git a/core/lib/Drupal/Core/Entity/Entity.php b/core/lib/Drupal/Core/Entity/Entity.php index fe00ef3..4eb5093 100644 --- a/core/lib/Drupal/Core/Entity/Entity.php +++ b/core/lib/Drupal/Core/Entity/Entity.php @@ -258,7 +258,7 @@ public function getIterator() { */ public function access($operation = 'view', \Drupal\user\Plugin\Core\Entity\User $account = NULL) { $method = $operation . 'Access'; - return drupal_container()->get('plugin.manager.entity') + return Drupal::service('plugin.manager.entity') ->getAccessController($this->entityType) ->$method($this, LANGUAGE_DEFAULT, $account); } @@ -331,7 +331,7 @@ public function getTranslationLanguages($include_default = TRUE) { * Implements \Drupal\Core\Entity\EntityInterface::save(). */ public function save() { - return drupal_container()->get('plugin.manager.entity')->getStorageController($this->entityType)->save($this); + return Drupal::service('plugin.manager.entity')->getStorageController($this->entityType)->save($this); } /** @@ -339,7 +339,7 @@ public function save() { */ public function delete() { if (!$this->isNew()) { - drupal_container()->get('plugin.manager.entity')->getStorageController($this->entityType)->delete(array($this->id() => $this)); + Drupal::service('plugin.manager.entity')->getStorageController($this->entityType)->delete(array($this->id() => $this)); } } diff --git a/core/lib/Drupal/Core/Entity/EntityNG.php b/core/lib/Drupal/Core/Entity/EntityNG.php index 8763f6d..acc07ed 100644 --- a/core/lib/Drupal/Core/Entity/EntityNG.php +++ b/core/lib/Drupal/Core/Entity/EntityNG.php @@ -218,7 +218,7 @@ public function getPropertyDefinition($name) { */ public function getPropertyDefinitions() { if (!isset($this->fieldDefinitions)) { - $this->fieldDefinitions = drupal_container()->get('plugin.manager.entity')->getStorageController($this->entityType)->getFieldDefinitions(array( + $this->fieldDefinitions = Drupal::service('plugin.manager.entity')->getStorageController($this->entityType)->getFieldDefinitions(array( 'EntityType' => $this->entityType, 'Bundle' => $this->bundle, )); diff --git a/core/lib/Drupal/Core/Entity/Field/Type/EntityTranslation.php b/core/lib/Drupal/Core/Entity/Field/Type/EntityTranslation.php index 97a5627..cc95e71 100644 --- a/core/lib/Drupal/Core/Entity/Field/Type/EntityTranslation.php +++ b/core/lib/Drupal/Core/Entity/Field/Type/EntityTranslation.php @@ -202,7 +202,7 @@ public function access($operation = 'view', \Drupal\user\Plugin\Core\Entity\User // @todo Add a way to set and get the langcode so that's more obvious what // we're doing here. $langcode = substr($this->getName(), 1); - return drupal_container()->get('plugin.manager.entity') + return Drupal::service('plugin.manager.entity') ->getAccessController($this->parent->entityType()) ->$method($this->parent, $langcode, $account); } diff --git a/core/lib/Drupal/Core/Entity/Field/Type/EntityWrapper.php b/core/lib/Drupal/Core/Entity/Field/Type/EntityWrapper.php index 691868d..c52c476 100644 --- a/core/lib/Drupal/Core/Entity/Field/Type/EntityWrapper.php +++ b/core/lib/Drupal/Core/Entity/Field/Type/EntityWrapper.php @@ -170,7 +170,7 @@ public function getPropertyDefinition($name) { */ public function getPropertyDefinitions() { // @todo: Support getting definitions if multiple bundles are specified. - return drupal_container()->get('plugin.manager.entity')->getStorageController($this->entityType)->getFieldDefinitions($this->definition['constraints']); + return Drupal::service('plugin.manager.entity')->getStorageController($this->entityType)->getFieldDefinitions($this->definition['constraints']); } /** diff --git a/core/modules/aggregator/aggregator.admin.inc b/core/modules/aggregator/aggregator.admin.inc index 632f1ec..67b9ff7 100644 --- a/core/modules/aggregator/aggregator.admin.inc +++ b/core/modules/aggregator/aggregator.admin.inc @@ -314,7 +314,7 @@ function aggregator_admin_refresh_feed(Feed $feed) { // @todo CSRF tokens are validated in page callbacks rather than access // callbacks, because access callbacks are also invoked during menu link // generation. Add token support to routing: http://drupal.org/node/755584. - $token = drupal_container()->get('request')->query->get('token'); + $token = Drupal::service('request')->query->get('token'); if (!isset($token) || !drupal_valid_token($token, 'aggregator/update/' . $feed->id())) { throw new AccessDeniedHttpException(); } @@ -345,7 +345,7 @@ function aggregator_admin_form($form, $form_state) { aggregator_sanitize_configuration(); // Get all available fetchers. - $fetcher_manager = drupal_container()->get('plugin.manager.aggregator.fetcher'); + $fetcher_manager = Drupal::service('plugin.manager.aggregator.fetcher'); $fetchers = array(); foreach ($fetcher_manager->getDefinitions() as $id => $definition) { $label = $definition['title'] . ' ' . $definition['description'] . ''; @@ -513,7 +513,7 @@ function aggregator_form_category_submit($form, &$form_state) { // @todo Replicate this cache invalidation when these ops are separated. // Invalidate the block cache to update aggregator category-based derivatives. if (module_exists('block')) { - drupal_container()->get('plugin.manager.block')->clearCachedDefinitions(); + Drupal::service('plugin.manager.block')->clearCachedDefinitions(); } if ($form_state['values']['op'] == t('Delete')) { $title = $form_state['values']['title']; diff --git a/core/modules/aggregator/aggregator.module b/core/modules/aggregator/aggregator.module index 6e89fde..04914c7 100644 --- a/core/modules/aggregator/aggregator.module +++ b/core/modules/aggregator/aggregator.module @@ -449,7 +449,7 @@ function aggregator_refresh(Feed $feed) { list($fetcher, $parser, $processors) = _aggregator_get_variables(); // Fetch the feed. - $fetcher_manager = drupal_container()->get('plugin.manager.aggregator.fetcher'); + $fetcher_manager = Drupal::service('plugin.manager.aggregator.fetcher'); try { $success = $fetcher_manager->createInstance($fetcher)->fetch($feed); } diff --git a/core/modules/aggregator/lib/Drupal/aggregator/FeedStorageController.php b/core/modules/aggregator/lib/Drupal/aggregator/FeedStorageController.php index d8c052c..bdf4b90 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/FeedStorageController.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/FeedStorageController.php @@ -48,7 +48,7 @@ protected function preDelete($entities) { // Invalidate the block cache to update aggregator feed-based derivatives. if (module_exists('block')) { - drupal_container()->get('plugin.manager.block')->clearCachedDefinitions(); + Drupal::service('plugin.manager.block')->clearCachedDefinitions(); } foreach ($entities as $entity) { $iids = db_query('SELECT iid FROM {aggregator_item} WHERE fid = :fid', array(':fid' => $entity->id()))->fetchCol(); @@ -84,7 +84,7 @@ protected function preSave(EntityInterface $entity) { // Invalidate the block cache to update aggregator feed-based derivatives. if (module_exists('block')) { - drupal_container()->get('plugin.manager.block')->clearCachedDefinitions(); + Drupal::service('plugin.manager.block')->clearCachedDefinitions(); } // An existing feed is being modified, delete the category listings. db_delete('aggregator_category_feed') diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Plugin/aggregator/fetcher/DefaultFetcher.php b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/aggregator/fetcher/DefaultFetcher.php index f1ae82c..09fa88a 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/Plugin/aggregator/fetcher/DefaultFetcher.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/aggregator/fetcher/DefaultFetcher.php @@ -30,7 +30,7 @@ class DefaultFetcher implements FetcherInterface { * Implements Drupal\aggregator\Plugin\FetcherInterface::fetch(). */ function fetch(Feed $feed) { - $request = drupal_container()->get('http_default_client')->get($feed->url->value); + $request = Drupal::service('http_default_client')->get($feed->url->value); $feed->source_string = FALSE; // Generate conditional GET headers. diff --git a/core/modules/block/block.admin.inc b/core/modules/block/block.admin.inc index 18b9c76..e65a91b 100644 --- a/core/modules/block/block.admin.inc +++ b/core/modules/block/block.admin.inc @@ -29,7 +29,7 @@ function block_admin_demo($theme = NULL) { * @see block_menu() */ function block_admin_display($theme) { - return drupal_container()->get('plugin.manager.entity') + return Drupal::service('plugin.manager.entity') ->getListController('block') ->render($theme); } diff --git a/core/modules/block/block.module b/core/modules/block/block.module index 18b9d27..8862ebc 100644 --- a/core/modules/block/block.module +++ b/core/modules/block/block.module @@ -156,7 +156,7 @@ function block_menu() { // hook_menu_local_tasks() to check for the untranslated tab_parent path. // @see http://drupal.org/node/1067408 $themes = list_themes(); - foreach (drupal_container()->get('plugin.manager.system.plugin_ui')->getDefinitions() as $plugin_id => $plugin) { + foreach (Drupal::service('plugin.manager.system.plugin_ui')->getDefinitions() as $plugin_id => $plugin) { list($plugin_base, $key) = explode(':', $plugin_id); if ($plugin_base == 'block_plugin_ui') { $theme = $themes[$key]; diff --git a/core/modules/block/custom_block/custom_block.admin.inc b/core/modules/block/custom_block/custom_block.admin.inc index 3451e5d..e2e9f94 100644 --- a/core/modules/block/custom_block/custom_block.admin.inc +++ b/core/modules/block/custom_block/custom_block.admin.inc @@ -16,7 +16,7 @@ * @see custom_block_menu() */ function custom_block_type_list() { - return drupal_container()->get('plugin.manager.entity')->getListController('custom_block_type')->render(); + return Drupal::service('plugin.manager.entity')->getListController('custom_block_type')->render(); } /** diff --git a/core/modules/block/custom_block/custom_block.pages.inc b/core/modules/block/custom_block/custom_block.pages.inc index 439030e..ba6b790 100644 --- a/core/modules/block/custom_block/custom_block.pages.inc +++ b/core/modules/block/custom_block/custom_block.pages.inc @@ -21,7 +21,7 @@ */ function custom_block_add_page() { $options = array(); - $request = drupal_container()->get('request'); + $request = Drupal::service('request'); if (($theme = $request->attributes->get('theme')) && in_array($theme, array_keys(list_themes()))) { // We have navigated to this page from the block library and will keep track // of the theme for redirecting the user to the configuration page for the @@ -85,7 +85,7 @@ function custom_block_add(CustomBlockType $block_type) { 'type' => $block_type->id() )); $options = array(); - $request = drupal_container()->get('request'); + $request = Drupal::service('request'); if (($theme = $request->attributes->get('theme')) && in_array($theme, array_keys(list_themes()))) { // We have navigated to this page from the block library and will keep track // of the theme for redirecting the user to the configuration page for the diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockStorageController.php b/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockStorageController.php index 87ff2d5..f6d087d 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockStorageController.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockStorageController.php @@ -69,7 +69,7 @@ protected function attachLoad(&$blocks, $load_revision = FALSE) { */ protected function postSave(EntityInterface $block, $update) { // Invalidate the block cache to update custom block-based derivatives. - drupal_container()->get('plugin.manager.block')->clearCachedDefinitions(); + Drupal::service('plugin.manager.block')->clearCachedDefinitions(); } /** diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/block/block/CustomBlockBlock.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/block/block/CustomBlockBlock.php index 9219264..ac1dc38 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/block/block/CustomBlockBlock.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/block/block/CustomBlockBlock.php @@ -68,7 +68,7 @@ public function blockForm($form, &$form_state) { public function blockSubmit($form, &$form_state) { // Invalidate the block cache to update custom block-based derivatives. if (module_exists('block')) { - drupal_container()->get('plugin.manager.block')->clearCachedDefinitions(); + Drupal::service('plugin.manager.block')->clearCachedDefinitions(); } } diff --git a/core/modules/block/lib/Drupal/block/BlockBase.php b/core/modules/block/lib/Drupal/block/BlockBase.php index 9c90a5a..6f754f6 100644 --- a/core/modules/block/lib/Drupal/block/BlockBase.php +++ b/core/modules/block/lib/Drupal/block/BlockBase.php @@ -173,7 +173,7 @@ public function access() { if ($visibility['path']['visibility'] < BLOCK_VISIBILITY_PHP) { // Compare the lowercase path alias (if any) and internal path. $path = current_path(); - $path_alias = drupal_strtolower(drupal_container()->get('path.alias_manager')->getPathAlias($path)); + $path_alias = drupal_strtolower(Drupal::service('path.alias_manager')->getPathAlias($path)); $page_match = drupal_match_path($path_alias, $pages) || (($path != $path_alias) && drupal_match_path($path, $pages)); // When $block->visibility has a value of 0 // (BLOCK_VISIBILITY_NOTLISTED), the block is displayed on all pages diff --git a/core/modules/block/lib/Drupal/block/Plugin/Core/Entity/Block.php b/core/modules/block/lib/Drupal/block/Plugin/Core/Entity/Block.php index 75d82e8..7374196 100644 --- a/core/modules/block/lib/Drupal/block/Plugin/Core/Entity/Block.php +++ b/core/modules/block/lib/Drupal/block/Plugin/Core/Entity/Block.php @@ -123,7 +123,7 @@ public function getPlugin() { // Create a plugin instance and store its configuration as settings. try { - $this->instance = drupal_container()->get('plugin.manager.block')->createInstance($this->plugin, $this->settings, $this); + $this->instance = Drupal::service('plugin.manager.block')->createInstance($this->plugin, $this->settings, $this); $this->settings += $this->instance->getConfig(); } catch (PluginException $e) { diff --git a/core/modules/block/lib/Drupal/block/Plugin/system/plugin_ui/BlockPluginUI.php b/core/modules/block/lib/Drupal/block/Plugin/system/plugin_ui/BlockPluginUI.php index 62185e9..50893a2 100644 --- a/core/modules/block/lib/Drupal/block/Plugin/system/plugin_ui/BlockPluginUI.php +++ b/core/modules/block/lib/Drupal/block/Plugin/system/plugin_ui/BlockPluginUI.php @@ -47,7 +47,7 @@ public function form($form, &$form_state, $facet = NULL) { list($plugin, $theme) = explode(':', $this->getPluginId()); $plugin_definition = $this->getDefinition(); // @todo Find out how to let the manager be injected into the class. - $manager = drupal_container()->get($plugin_definition['manager']); + $manager = Drupal::getContainer()->get($plugin_definition['manager']); $plugins = $manager->getDefinitions(); $form['#theme'] = 'system_plugin_ui_form'; $form['theme'] = array( diff --git a/core/modules/breakpoint/breakpoint.install b/core/modules/breakpoint/breakpoint.install index cba7b1b..e1f8bc7 100644 --- a/core/modules/breakpoint/breakpoint.install +++ b/core/modules/breakpoint/breakpoint.install @@ -18,5 +18,5 @@ function breakpoint_enable() { _breakpoint_theme_enabled(array_keys($themes)); // Import breakpoints from modules. - _breakpoint_modules_enabled(array_keys(drupal_container()->get('module_handler')->getModuleList())); + _breakpoint_modules_enabled(array_keys(Drupal::service('module_handler')->getModuleList())); } diff --git a/core/modules/breakpoint/breakpoint.module b/core/modules/breakpoint/breakpoint.module index b467011..f22c1c8 100644 --- a/core/modules/breakpoint/breakpoint.module +++ b/core/modules/breakpoint/breakpoint.module @@ -202,7 +202,7 @@ function _breakpoint_delete_breakpoints($list, $source_type) { $breakpoint_group->delete(); // Get all breakpoints defined by this theme/module. - $breakpoint_ids = drupal_container()->get('config.storage')->listAll('breakpoint.breakpoint.' . $source_type . '.' . $breakpoint_group->id() . '.'); + $breakpoint_ids = Drupal::service('config.storage')->listAll('breakpoint.breakpoint.' . $source_type . '.' . $breakpoint_group->id() . '.'); $entity_info = entity_get_info('breakpoint'); // Remove the breakpoint.breakpoint part of the breakpoint identifier. diff --git a/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/editor/editor/CKEditor.php b/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/editor/editor/CKEditor.php index 57b857d..88ac071 100644 --- a/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/editor/editor/CKEditor.php +++ b/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/editor/editor/CKEditor.php @@ -48,7 +48,7 @@ public function getDefaultSettings() { */ public function settingsForm(array $form, array &$form_state, Editor $editor) { $module_path = drupal_get_path('module', 'ckeditor'); - $manager = drupal_container()->get('plugin.manager.ckeditor.plugin'); + $manager = Drupal::service('plugin.manager.ckeditor.plugin'); $form['toolbar'] = array( '#type' => 'container', @@ -109,7 +109,7 @@ public function getJSSettings(Editor $editor) { $language_interface = language(LANGUAGE_TYPE_INTERFACE); $settings = array(); - $manager = drupal_container()->get('plugin.manager.ckeditor.plugin'); + $manager = Drupal::service('plugin.manager.ckeditor.plugin'); // Get the settings for all enabled plugins, even the internal ones. $enabled_plugins = array_keys($manager->getEnabledPlugins($editor, TRUE)); diff --git a/core/modules/ckeditor/lib/Drupal/ckeditor/Tests/CKEditorAdminTest.php b/core/modules/ckeditor/lib/Drupal/ckeditor/Tests/CKEditorAdminTest.php index bb17201..6250c5e 100644 --- a/core/modules/ckeditor/lib/Drupal/ckeditor/Tests/CKEditorAdminTest.php +++ b/core/modules/ckeditor/lib/Drupal/ckeditor/Tests/CKEditorAdminTest.php @@ -47,7 +47,7 @@ function setUp() { } function testAdmin() { - $manager = drupal_container()->get('plugin.manager.editor'); + $manager = Drupal::service('plugin.manager.editor'); $ckeditor = $manager->createInstance('ckeditor'); $this->drupalLogin($this->admin_user); @@ -143,7 +143,7 @@ function testAdmin() { // Now enable the ckeditor_test module, which provides one configurable // CKEditor plugin — this should not affect the Editor config entity. module_enable(array('ckeditor_test')); - drupal_container()->get('plugin.manager.ckeditor.plugin')->clearCachedDefinitions(); + Drupal::service('plugin.manager.ckeditor.plugin')->clearCachedDefinitions(); $this->drupalGet('admin/config/content/formats/filtered_html'); $ultra_llama_mode_checkbox = $this->xpath('//input[@type="checkbox" and @name="editor[settings][plugins][llama_contextual_and_button][ultra_llama_mode]" and not(@checked)]'); $this->assertTrue(count($ultra_llama_mode_checkbox) === 1, 'The "Ultra llama mode" checkbox exists and is not checked.'); diff --git a/core/modules/ckeditor/lib/Drupal/ckeditor/Tests/CKEditorLoadingTest.php b/core/modules/ckeditor/lib/Drupal/ckeditor/Tests/CKEditorLoadingTest.php index 63a816f..269b678 100644 --- a/core/modules/ckeditor/lib/Drupal/ckeditor/Tests/CKEditorLoadingTest.php +++ b/core/modules/ckeditor/lib/Drupal/ckeditor/Tests/CKEditorLoadingTest.php @@ -97,7 +97,7 @@ function testLoading() { $this->drupalLogin($this->normal_user); $this->drupalGet('node/add/article'); list($settings, $editor_settings_present, $editor_js_present, $body, $format_selector) = $this->getThingsToCheck(); - $ckeditor_plugin = drupal_container()->get('plugin.manager.editor')->createInstance('ckeditor'); + $ckeditor_plugin = Drupal::service('plugin.manager.editor')->createInstance('ckeditor'); $editor = entity_load('editor', 'filtered_html'); $expected = array('formats' => array('filtered_html' => array( 'editor' => 'ckeditor', @@ -119,7 +119,7 @@ function testLoading() { // configuration also results in modified CKEditor configuration, so we // don't test that here. module_enable(array('ckeditor_test')); - drupal_container()->get('plugin.manager.ckeditor.plugin')->clearCachedDefinitions(); + Drupal::service('plugin.manager.ckeditor.plugin')->clearCachedDefinitions(); $editor->settings['toolbar']['buttons'][0][] = 'Llama'; $editor->settings['plugins']['internal']['link_shortcut'] = 'CTRL+K'; $editor->save(); diff --git a/core/modules/ckeditor/lib/Drupal/ckeditor/Tests/CKEditorTest.php b/core/modules/ckeditor/lib/Drupal/ckeditor/Tests/CKEditorTest.php index db4dbec..c988aa0 100644 --- a/core/modules/ckeditor/lib/Drupal/ckeditor/Tests/CKEditorTest.php +++ b/core/modules/ckeditor/lib/Drupal/ckeditor/Tests/CKEditorTest.php @@ -88,7 +88,7 @@ function testGetJSSettings() { // Customize the configuration: add button, have two contextually enabled // buttons, and configure a CKEditor plugin setting. $this->enableModules(array('ckeditor_test')); - drupal_container()->get('plugin.manager.ckeditor.plugin')->clearCachedDefinitions(); + Drupal::service('plugin.manager.ckeditor.plugin')->clearCachedDefinitions(); $editor->settings['toolbar']['buttons'][0][] = 'Strike'; $editor->settings['toolbar']['buttons'][1][] = 'Format'; $editor->settings['plugins']['internal']['link_shortcut'] = 'CTRL+K'; @@ -131,7 +131,7 @@ function testBuildToolbarJSSetting() { // Enable the editor_test module, customize further. $this->enableModules(array('ckeditor_test')); - drupal_container()->get('plugin.manager.ckeditor.plugin')->clearCachedDefinitions(); + Drupal::service('plugin.manager.ckeditor.plugin')->clearCachedDefinitions(); $editor->settings['toolbar']['buttons'][0][] = 'Llama'; $editor->save(); $expected[count($expected)-2]['items'][] = 'Llama'; @@ -161,7 +161,7 @@ function testBuildContentsCssJSSetting() { */ function testInternalGetConfig() { $editor = entity_load('editor', 'filtered_html'); - $manager = drupal_container()->get('plugin.manager.ckeditor.plugin'); + $manager = Drupal::service('plugin.manager.ckeditor.plugin'); $internal_plugin = $manager->createInstance('internal'); // Default toolbar. @@ -179,7 +179,7 @@ function testInternalGetConfig() { */ function testStylesComboGetConfig() { $editor = entity_load('editor', 'filtered_html'); - $manager = drupal_container()->get('plugin.manager.ckeditor.plugin'); + $manager = Drupal::service('plugin.manager.ckeditor.plugin'); $stylescombo_plugin = $manager->createInstance('stylescombo'); // Styles dropdown/button enabled: new setting should be present. diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index 9ee6f81..977c316 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -444,12 +444,12 @@ function comment_permalink($cid) { $page = comment_get_display_page($comment->id(), $node->type); // @todo: Cleaner sub request handling. - $request = drupal_container()->get('request'); + $request = Drupal::service('request'); $subrequest = Request::create('/node/' . $node->nid, 'GET', $request->query->all(), $request->cookies->all(), array(), $request->server->all()); $subrequest->query->set('page', $page); // @todo: Convert the pager to use the request object. $_GET['page'] = $page; - return drupal_container()->get('http_kernel')->handle($subrequest, HttpKernelInterface::SUB_REQUEST); + return Drupal::service('http_kernel')->handle($subrequest, HttpKernelInterface::SUB_REQUEST); } throw new NotFoundHttpException(); } diff --git a/core/modules/comment/comment.pages.inc b/core/modules/comment/comment.pages.inc index da359a4..dfad97d 100644 --- a/core/modules/comment/comment.pages.inc +++ b/core/modules/comment/comment.pages.inc @@ -111,7 +111,7 @@ function comment_approve($cid) { // @todo CSRF tokens are validated in page callbacks rather than access // callbacks, because access callbacks are also invoked during menu link // generation. Add token support to routing: http://drupal.org/node/755584. - $token = drupal_container()->get('request')->query->get('token'); + $token = Drupal::service('request')->query->get('token'); if (!isset($token) || !drupal_valid_token($token, "comment/$cid/approve")) { throw new AccessDeniedHttpException(); } diff --git a/core/modules/comment/comment.views.inc b/core/modules/comment/comment.views.inc index e74c97c..02dffa1 100644 --- a/core/modules/comment/comment.views.inc +++ b/core/modules/comment/comment.views.inc @@ -360,7 +360,7 @@ function comment_views_data() { ), ); - if (drupal_container()->get('module_handler')->moduleExists('translation_entity')) { + if (Drupal::service('module_handler')->moduleExists('translation_entity')) { $data['comment']['translation_link'] = array( 'title' => t('Translation link'), 'help' => t('Provide a link to the translations overview for comments.'), diff --git a/core/modules/comment/lib/Drupal/comment/Plugin/views/field/NcsLastCommentName.php b/core/modules/comment/lib/Drupal/comment/Plugin/views/field/NcsLastCommentName.php index e30b7ca..6a0f1a6 100644 --- a/core/modules/comment/lib/Drupal/comment/Plugin/views/field/NcsLastCommentName.php +++ b/core/modules/comment/lib/Drupal/comment/Plugin/views/field/NcsLastCommentName.php @@ -40,7 +40,7 @@ public function query() { ) ) ); - $join = drupal_container()->get('plugin.manager.views.join')->createInstance('standard', $definition); + $join = Drupal::service('plugin.manager.views.join')->createInstance('standard', $definition); // ncs_user alias so this can work with the sort handler, below. // $this->user_table = $this->query->add_relationship(NULL, $join, 'users', $this->relationship); diff --git a/core/modules/comment/lib/Drupal/comment/Plugin/views/sort/NcsLastCommentName.php b/core/modules/comment/lib/Drupal/comment/Plugin/views/sort/NcsLastCommentName.php index c7021b9..6094648 100644 --- a/core/modules/comment/lib/Drupal/comment/Plugin/views/sort/NcsLastCommentName.php +++ b/core/modules/comment/lib/Drupal/comment/Plugin/views/sort/NcsLastCommentName.php @@ -31,7 +31,7 @@ public function query() { 'left_table' => $this->tableAlias, 'left_field' => 'last_comment_uid', ); - $join = drupal_container()->get('plugin.manager.views.join')->createInstance('standard', $definition); + $join = Drupal::service('plugin.manager.views.join')->createInstance('standard', $definition); // @todo this might be safer if we had an ensure_relationship rather than guessing // the table alias. Though if we did that we'd be guessing the relationship name diff --git a/core/modules/config/config.admin.inc b/core/modules/config/config.admin.inc index 3813885..98feaf6 100644 --- a/core/modules/config/config.admin.inc +++ b/core/modules/config/config.admin.inc @@ -78,8 +78,8 @@ function config_admin_sync_form(array &$form, array &$form_state, StorageInterfa */ function config_admin_import_form($form, &$form_state) { // Retrieve a list of differences between last known state and active store. - $source_storage = drupal_container()->get('config.storage.staging'); - $target_storage = drupal_container()->get('config.storage'); + $source_storage = Drupal::service('config.storage.staging'); + $target_storage = Drupal::service('config.storage'); $form['actions'] = array('#type' => 'actions'); $form['actions']['submit'] = array( @@ -103,7 +103,7 @@ function config_admin_import_form_submit($form, &$form_state) { // Once a sync completes, we empty the staging directory. This prevents // changes from being accidentally overwritten by stray files getting // imported later. - $source_storage = drupal_container()->get('config.storage.staging'); + $source_storage = Drupal::service('config.storage.staging'); foreach ($source_storage->listAll() as $name) { $source_storage->delete($name); } diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigLocaleOverride.php b/core/modules/config/lib/Drupal/config/Tests/ConfigLocaleOverride.php index cee642e..6453b52 100644 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigLocaleOverride.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigLocaleOverride.php @@ -110,7 +110,7 @@ function testConfigLocaleUserOverride() { 'preferred_langcode' => 'de', )); - $config_factory = drupal_container()->get('config.factory'); + $config_factory = Drupal::service('config.factory'); $config_factory->enterContext($user_config_context->setAccount($account)); // Should not have to re-initialize the configuration object to get new // overrides as the new context will have a different uuid. diff --git a/core/modules/config/tests/config_test/config_test.module b/core/modules/config/tests/config_test/config_test.module index d0d59fd..48f443b 100644 --- a/core/modules/config/tests/config_test/config_test.module +++ b/core/modules/config/tests/config_test/config_test.module @@ -83,7 +83,7 @@ function config_test_load($id) { * Page callback; Lists available ConfigTest objects. */ function config_test_list_page() { - return drupal_container()->get('plugin.manager.entity') + return Drupal::service('plugin.manager.entity') ->getListController('config_test') ->render(); } diff --git a/core/modules/contact/contact.admin.inc b/core/modules/contact/contact.admin.inc index bc706c3..6bc8ed3 100644 --- a/core/modules/contact/contact.admin.inc +++ b/core/modules/contact/contact.admin.inc @@ -17,7 +17,7 @@ */ function contact_category_list() { drupal_set_title(t('Contact form categories')); - return drupal_container()->get('plugin.manager.entity') + return Drupal::service('plugin.manager.entity') ->getListController('contact_category') ->render(); } diff --git a/core/modules/contact/contact.module b/core/modules/contact/contact.module index 4957052..62d7ef9 100644 --- a/core/modules/contact/contact.module +++ b/core/modules/contact/contact.module @@ -159,7 +159,7 @@ function _contact_personal_tab_access($account) { // If the requested user has disabled their contact form, do not allow users // to contact them. - $account_data = drupal_container()->get('user.data')->get('contact', $account->id(), 'enabled'); + $account_data = Drupal::service('user.data')->get('contact', $account->id(), 'enabled'); if (isset($account_data) && empty($account_data)) { return FALSE; } @@ -342,7 +342,7 @@ function contact_form_user_profile_form_alter(&$form, &$form_state) { '#weight' => 5, ); $account = $form_state['controller']->getEntity($form_state); - $account_data = drupal_container()->get('user.data')->get('contact', $account->id(), 'enabled'); + $account_data = Drupal::service('user.data')->get('contact', $account->id(), 'enabled'); $form['contact']['contact'] = array( '#type' => 'checkbox', '#title' => t('Personal contact form'), @@ -356,7 +356,7 @@ function contact_form_user_profile_form_alter(&$form, &$form_state) { */ function contact_user_update($account) { if (isset($account->contact)) { - drupal_container()->get('user.data')->set('contact', $account->id(), 'enabled', (int) $account->contact); + Drupal::service('user.data')->set('contact', $account->id(), 'enabled', (int) $account->contact); } } diff --git a/core/modules/contact/lib/Drupal/contact/Tests/Views/ContactFieldsTest.php b/core/modules/contact/lib/Drupal/contact/Tests/Views/ContactFieldsTest.php index 07b5308..1d301f3 100644 --- a/core/modules/contact/lib/Drupal/contact/Tests/Views/ContactFieldsTest.php +++ b/core/modules/contact/lib/Drupal/contact/Tests/Views/ContactFieldsTest.php @@ -60,7 +60,7 @@ protected function setUp() { public function testViewsData() { $field_name = $this->field['field_name']; $table_name = _field_sql_storage_tablename($this->field); - $data = drupal_container()->get('views.views_data')->get($table_name); + $data = Drupal::service('views.views_data')->get($table_name); // Test that the expected data array is returned. $expected = array('', '_value', '_format'); diff --git a/core/modules/edit/edit.module b/core/modules/edit/edit.module index e4a3f82..f29c6c5 100644 --- a/core/modules/edit/edit.module +++ b/core/modules/edit/edit.module @@ -54,7 +54,7 @@ function edit_contextual_links_view_alter(&$element, $items) { } // Include the attachments and settings for all available editors. - $attachments = drupal_container()->get('edit.editor.selector')->getAllEditorAttachments(); + $attachments = Drupal::service('edit.editor.selector')->getAllEditorAttachments(); $element['#attached'] = NestedArray::mergeDeep($element['#attached'], $attachments); } diff --git a/core/modules/editor/editor.module b/core/modules/editor/editor.module index 6db6210..edee080 100644 --- a/core/modules/editor/editor.module +++ b/core/modules/editor/editor.module @@ -93,7 +93,7 @@ function editor_form_filter_admin_overview_alter(&$form, $form_state) { $form['formats']['#header'] = array_merge($start, $form['formats']['#header']); // Then splice in the name of each text editor for each text format. - $editors = drupal_container()->get('plugin.manager.editor')->getDefinitions(); + $editors = Drupal::service('plugin.manager.editor')->getDefinitions(); foreach (element_children($form['formats']) as $format_id) { $editor = editor_load($format_id); $editor_name = ($editor && isset($editors[$editor->editor])) ? $editors[$editor->editor]['label'] : drupal_placeholder('—'); @@ -111,7 +111,7 @@ function editor_form_filter_admin_format_form_alter(&$form, &$form_state) { if (!isset($form_state['editor'])) { $format_id = $form['#format']->format; $form_state['editor'] = editor_load($format_id); - $form_state['editor_manager'] = drupal_container()->get('plugin.manager.editor'); + $form_state['editor_manager'] = Drupal::service('plugin.manager.editor'); } $editor = $form_state['editor']; $manager = $form_state['editor_manager']; @@ -284,7 +284,7 @@ function editor_pre_render_format($element) { $element['#attached']['library'][] = array('editor', 'drupal.editor'); // Attach attachments for all available editors. - $manager = drupal_container()->get('plugin.manager.editor'); + $manager = Drupal::service('plugin.manager.editor'); $element['#attached'] = NestedArray::mergeDeep($element['#attached'], $manager->getAttachments($format_ids)); return $element; diff --git a/core/modules/editor/lib/Drupal/editor/Plugin/Core/Entity/Editor.php b/core/modules/editor/lib/Drupal/editor/Plugin/Core/Entity/Editor.php index 22271ee..e683fb4 100644 --- a/core/modules/editor/lib/Drupal/editor/Plugin/Core/Entity/Editor.php +++ b/core/modules/editor/lib/Drupal/editor/Plugin/Core/Entity/Editor.php @@ -71,7 +71,7 @@ public function label($langcode = NULL) { public function __construct(array $values, $entity_type) { parent::__construct($values, $entity_type); - $manager = drupal_container()->get('plugin.manager.editor'); + $manager = Drupal::service('plugin.manager.editor'); $plugin = $manager->createInstance($this->editor); // Initialize settings, merging module-provided defaults. diff --git a/core/modules/entity/lib/Drupal/entity/Plugin/Core/Entity/EntityDisplay.php b/core/modules/entity/lib/Drupal/entity/Plugin/Core/Entity/EntityDisplay.php index d88967f..500b80a 100644 --- a/core/modules/entity/lib/Drupal/entity/Plugin/Core/Entity/EntityDisplay.php +++ b/core/modules/entity/lib/Drupal/entity/Plugin/Core/Entity/EntityDisplay.php @@ -239,7 +239,7 @@ public function setComponent($name, array $options = array()) { if ($instance = field_info_instance($this->targetEntityType, $name, $this->bundle)) { $field = field_info_field($instance['field_name']); - $options = drupal_container()->get('plugin.manager.field.formatter')->prepareConfiguration($field['type'], $options); + $options = Drupal::service('plugin.manager.field.formatter')->prepareConfiguration($field['type'], $options); // Clear the persisted formatter, if any. unset($this->formatters[$name]); @@ -325,7 +325,7 @@ public function getFormatter($field_name) { // Instantiate the formatter object from the stored display properties. if ($configuration = $this->getComponent($field_name)) { $instance = field_info_instance($this->targetEntityType, $field_name, $this->bundle); - $formatter = drupal_container()->get('plugin.manager.field.formatter')->getInstance(array( + $formatter = Drupal::service('plugin.manager.field.formatter')->getInstance(array( 'instance' => $instance, 'view_mode' => $this->originalViewMode, // No need to prepare, defaults have been merged in setComponent(). diff --git a/core/modules/entity_reference/entity_reference.module b/core/modules/entity_reference/entity_reference.module index f5e968c..aecc7b2 100644 --- a/core/modules/entity_reference/entity_reference.module +++ b/core/modules/entity_reference/entity_reference.module @@ -92,7 +92,7 @@ function entity_reference_get_selection_handler($field, $instance, EntityInterfa 'instance' => $instance, 'entity' => $entity, ); - return drupal_container()->get('plugin.manager.entity_reference.selection')->getInstance($options); + return Drupal::service('plugin.manager.entity_reference.selection')->getInstance($options); } /** @@ -241,10 +241,10 @@ function entity_reference_field_instance_settings_form($field, $instance, $form_ $settings += array('handler' => 'default'); // Get all selection plugins for this entity type. - $selection_plugins = drupal_container()->get('plugin.manager.entity_reference.selection')->getSelectionGroups($field['settings']['target_type']); + $selection_plugins = Drupal::service('plugin.manager.entity_reference.selection')->getSelectionGroups($field['settings']['target_type']); $handler_groups = array_keys($selection_plugins); - $handlers = drupal_container()->get('plugin.manager.entity_reference.selection')->getDefinitions(); + $handlers = Drupal::service('plugin.manager.entity_reference.selection')->getDefinitions(); $handlers_options = array(); foreach ($handlers as $plugin_id => $plugin) { // We only display base plugins (e.g. 'base', 'views', ..) and not entity @@ -531,7 +531,7 @@ function entity_reference_autocomplete_callback($type, $field_name, $entity_type $prefix = ''; // Get the typed string, if exists from the URL. - $tags_typed = drupal_container()->get('request')->query->get('q'); + $tags_typed = Drupal::service('request')->query->get('q'); $tags_typed = drupal_explode_tags($tags_typed); $string = drupal_strtolower(array_pop($tags_typed)); diff --git a/core/modules/field/field.crud.inc b/core/modules/field/field.crud.inc index f6ee8a2..a2b88b5 100644 --- a/core/modules/field/field.crud.inc +++ b/core/modules/field/field.crud.inc @@ -854,7 +854,7 @@ function field_purge_batch($batch_size) { // Retrieve all deleted field instances. We cannot use field_info_instances() // because that function does not return deleted instances. $instances = field_read_instances(array('deleted' => 1), array('include_deleted' => 1)); - $factory = drupal_container()->get('entity.query'); + $factory = Drupal::service('entity.query'); $info = entity_get_info(); foreach ($instances as $instance) { $entity_type = $instance['entity_type']; diff --git a/core/modules/field/field.info.inc b/core/modules/field/field.info.inc index b422b47..1816c6e 100644 --- a/core/modules/field/field.info.inc +++ b/core/modules/field/field.info.inc @@ -222,10 +222,10 @@ function field_info_field_types($field_type = NULL) { */ function field_info_widget_types($widget_type = NULL) { if ($widget_type) { - return drupal_container()->get('plugin.manager.field.widget')->getDefinition($widget_type); + return Drupal::service('plugin.manager.field.widget')->getDefinition($widget_type); } else { - return drupal_container()->get('plugin.manager.field.widget')->getDefinitions(); + return Drupal::service('plugin.manager.field.widget')->getDefinitions(); } } @@ -243,10 +243,10 @@ function field_info_widget_types($widget_type = NULL) { */ function field_info_formatter_types($formatter_type = NULL) { if ($formatter_type) { - return drupal_container()->get('plugin.manager.field.formatter')->getDefinition($formatter_type); + return Drupal::service('plugin.manager.field.formatter')->getDefinition($formatter_type); } else { - return drupal_container()->get('plugin.manager.field.formatter')->getDefinitions(); + return Drupal::service('plugin.manager.field.formatter')->getDefinitions(); } } diff --git a/core/modules/field/field.module b/core/modules/field/field.module index 6cdd628..4b0c10b 100644 --- a/core/modules/field/field.module +++ b/core/modules/field/field.module @@ -541,7 +541,7 @@ function field_modules_disabled($modules) { function field_sync_field_status() { // Refresh the 'active' and 'storage_active' columns according to the current // set of enabled modules. - $modules = array_keys(drupal_container()->get('module_handler')->getModuleList()); + $modules = array_keys(Drupal::service('module_handler')->getModuleList()); foreach ($modules as $module_name) { field_associate_fields($module_name); } @@ -932,7 +932,7 @@ function field_view_field(EntityInterface $entity, $field_name, $display_options // hook_field_attach_display_alter() needs to receive the 'prepared' // $display_options, so we cannot let preparation happen internally. $field = field_info_field($field_name); - $formatter_manager = drupal_container()->get('plugin.manager.field.formatter'); + $formatter_manager = Drupal::service('plugin.manager.field.formatter'); $display_options = $formatter_manager->prepareConfiguration($field['type'], $display_options); $formatter = $formatter_manager->getInstance(array( 'instance' => $instance, @@ -1013,7 +1013,7 @@ function field_get_items(EntityInterface $entity, $field_name, $langcode = NULL) function field_has_data($field) { $field = field_info_field_by_id($field['id']); $columns = array_keys($field['columns']); - $factory = drupal_container()->get('entity.query'); + $factory = Drupal::service('entity.query'); foreach ($field['bundles'] as $entity_type => $bundle) { // Entity Query throws an exception if there is no base table. $entity_info = entity_get_info($entity_type); diff --git a/core/modules/field/lib/Drupal/field/FieldInstance.php b/core/modules/field/lib/Drupal/field/FieldInstance.php index ba6ea44..b9b3542 100644 --- a/core/modules/field/lib/Drupal/field/FieldInstance.php +++ b/core/modules/field/lib/Drupal/field/FieldInstance.php @@ -61,7 +61,7 @@ public function getWidget() { 'settings' => $widget_properties['settings'], 'weight' => $widget_properties['weight'], ); - $this->widget = drupal_container()->get('plugin.manager.field.widget')->getInstance($options); + $this->widget = Drupal::service('plugin.manager.field.widget')->getInstance($options); } return $this->widget; diff --git a/core/modules/field/lib/Drupal/field/Plugin/views/field/Field.php b/core/modules/field/lib/Drupal/field/Plugin/views/field/Field.php index 976aa05..ad35f7a 100644 --- a/core/modules/field/lib/Drupal/field/Plugin/views/field/Field.php +++ b/core/modules/field/lib/Drupal/field/Plugin/views/field/Field.php @@ -129,7 +129,7 @@ function get_base_table() { $relationships = $this->view->display_handler->getOption('relationships'); if (!empty($relationships[$this->options['relationship']])) { $options = $relationships[$this->options['relationship']]; - $data = drupal_container()->get('views.views_data')->get($options['table']); + $data = Drupal::service('views.views_data')->get($options['table']); $this->base_table = $data[$options['field']]['relationship']['base']; } } @@ -191,7 +191,7 @@ public function query($use_groupby = FALSE) { // @see this::field_langcode() $default_langcode = language_default()->langcode; $langcode = str_replace(array('***CURRENT_LANGUAGE***', '***DEFAULT_LANGUAGE***'), - array(drupal_container()->get(LANGUAGE_TYPE_CONTENT)->langcode, $default_langcode), + array(Drupal::getContainer()->get(LANGUAGE_TYPE_CONTENT)->langcode, $default_langcode), $this->view->display_handler->options['field_langcode']); $placeholder = $this->placeholder(); $langcode_fallback_candidates = array($langcode); @@ -403,7 +403,7 @@ public function buildOptionsForm(&$form, &$form_state) { // Get the settings form. $settings_form = array('#value' => array()); - if ($formatter = drupal_container()->get('plugin.manager.field.formatter')->getInstance($options)) { + if ($formatter = Drupal::service('plugin.manager.field.formatter')->getInstance($options)) { $settings_form = $formatter->settingsForm($form, $form_state); } $form['settings'] = $settings_form; @@ -845,7 +845,7 @@ function field_langcode(EntityInterface $entity) { if (field_is_translatable($entity->entityType(), $this->field_info)) { $default_langcode = language_default()->langcode; $langcode = str_replace(array('***CURRENT_LANGUAGE***', '***DEFAULT_LANGUAGE***'), - array(drupal_container()->get(LANGUAGE_TYPE_CONTENT)->langcode, $default_langcode), + array(Drupal::getContainer()->get(LANGUAGE_TYPE_CONTENT)->langcode, $default_langcode), $this->view->display_handler->options['field_language']); // Give the Field Language API a chance to fallback to a different language diff --git a/core/modules/field/lib/Drupal/field/Plugin/views/relationship/EntityReverse.php b/core/modules/field/lib/Drupal/field/Plugin/views/relationship/EntityReverse.php index 087a2e5..67ae2bf 100644 --- a/core/modules/field/lib/Drupal/field/Plugin/views/relationship/EntityReverse.php +++ b/core/modules/field/lib/Drupal/field/Plugin/views/relationship/EntityReverse.php @@ -40,7 +40,7 @@ public function query() { $this->ensureMyTable(); // First, relate our base table to the current base table to the // field, using the base table's id field to the field's column. - $views_data = drupal_container()->get('views.views_data')->get($this->table); + $views_data = Drupal::service('views.views_data')->get($this->table); $left_field = $views_data['table']['base']['field']; $first = array( @@ -64,7 +64,7 @@ public function query() { else { $id = 'standard'; } - $first_join = drupal_container()->get('plugin.manager.views.join')->createInstance($id, $first); + $first_join = Drupal::service('plugin.manager.views.join')->createInstance($id, $first); $this->first_alias = $this->query->add_table($this->definition['field table'], $this->relationship, $first_join); @@ -89,7 +89,7 @@ public function query() { else { $id = 'standard'; } - $second_join = drupal_container()->get('plugin.manager.views.join')->createInstance($id, $second); + $second_join = Drupal::service('plugin.manager.views.join')->createInstance($id, $second); $second_join->adjusted = TRUE; // use a short alias for this: diff --git a/core/modules/field/lib/Drupal/field/Tests/BulkDeleteTest.php b/core/modules/field/lib/Drupal/field/Tests/BulkDeleteTest.php index c365961..e5d5a1b 100644 --- a/core/modules/field/lib/Drupal/field/Tests/BulkDeleteTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/BulkDeleteTest.php @@ -158,7 +158,7 @@ function testDeleteFieldInstance() { $bundle = reset($this->bundles); $field = reset($this->fields); $field_name = $field['field_name']; - $factory = drupal_container()->get('entity.query'); + $factory = Drupal::service('entity.query'); // There are 10 entities of this bundle. $found = $factory->get('test_entity') diff --git a/core/modules/field_ui/lib/Drupal/field_ui/DisplayOverview.php b/core/modules/field_ui/lib/Drupal/field_ui/DisplayOverview.php index 7ee40f4..d0bdc0d 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/DisplayOverview.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/DisplayOverview.php @@ -171,7 +171,7 @@ public function buildForm(array $form, array &$form_state) { // Get the corresponding formatter object. if ($display_options && $display_options['type'] != 'hidden') { - $formatter = drupal_container()->get('plugin.manager.field.formatter')->getInstance(array( + $formatter = Drupal::service('plugin.manager.field.formatter')->getInstance(array( 'instance' => $instance, 'view_mode' => $this->view_mode, 'configuration' => $display_options diff --git a/core/modules/file/file.module b/core/modules/file/file.module index 69fcbf3..592d3c4 100644 --- a/core/modules/file/file.module +++ b/core/modules/file/file.module @@ -144,7 +144,7 @@ function file_load($fid, $reset = FALSE) { * @return Drupal\file\FileUsage\FileUsageInterface. */ function file_usage() { - return drupal_container()->get('file.usage'); + return Drupal::service('file.usage'); } /** @@ -413,7 +413,7 @@ function file_validate_size(File $file, $file_limit = 0, $user_limit = 0) { } // Save a query by only calling spaceUsed() when a limit is provided. - if ($user_limit && (drupal_container()->get('plugin.manager.entity')->getStorageController('file')->spaceUsed($user->uid) + $file->filesize) > $user_limit) { + if ($user_limit && (Drupal::service('plugin.manager.entity')->getStorageController('file')->spaceUsed($user->uid) + $file->filesize) > $user_limit) { $errors[] = t('The file is %filesize which would exceed your disk quota of %quota.', array('%filesize' => format_size($file->filesize), '%quota' => format_size($user_limit))); } @@ -715,7 +715,7 @@ function file_file_download($uri, $field_type = 'file') { * Implements file_cron() */ function file_cron() { - $result = drupal_container()->get('plugin.manager.entity')->getStorageController('file')->retrieveTemporaryFiles(); + $result = Drupal::service('plugin.manager.entity')->getStorageController('file')->retrieveTemporaryFiles(); foreach ($result as $row) { if ($file = file_load($row->fid)) { $references = file_usage()->listUsage($file); diff --git a/core/modules/language/tests/language_test/language_test.module b/core/modules/language/tests/language_test/language_test.module index cb97937..1d307f7 100644 --- a/core/modules/language/tests/language_test/language_test.module +++ b/core/modules/language/tests/language_test/language_test.module @@ -117,5 +117,5 @@ function language_test_menu() { * Page callback. Uses a subrequest to retrieve the 'user' page. */ function language_test_subrequest() { - return drupal_container()->get('http_kernel')->handle(Request::create('/user'), HttpKernelInterface::SUB_REQUEST); + return Drupal::service('http_kernel')->handle(Request::create('/user'), HttpKernelInterface::SUB_REQUEST); } diff --git a/core/modules/layout/layout.module b/core/modules/layout/layout.module index c6ed7ae..1d47c5f 100644 --- a/core/modules/layout/layout.module +++ b/core/modules/layout/layout.module @@ -61,7 +61,7 @@ function layout_permission() { * The layout plugin manager instance. */ function layout_manager() { - return drupal_container()->get('plugin.manager.layout'); + return Drupal::service('plugin.manager.layout'); } /** diff --git a/core/modules/layout/lib/Drupal/layout/Plugin/Derivative/Layout.php b/core/modules/layout/lib/Drupal/layout/Plugin/Derivative/Layout.php index c5d0dde..c429258 100644 --- a/core/modules/layout/lib/Drupal/layout/Plugin/Derivative/Layout.php +++ b/core/modules/layout/lib/Drupal/layout/Plugin/Derivative/Layout.php @@ -59,7 +59,7 @@ public function getDerivativeDefinitions(array $base_plugin_definition) { // Add all modules as possible layout providers. // @todo Inject the module handler. - foreach (drupal_container()->get('module_handler')->getModuleList() as $module => $filename) { + foreach (Drupal::service('module_handler')->getModuleList() as $module => $filename) { $available_layout_providers[$module] = array( 'type' => 'module', 'provider' => $module, diff --git a/core/modules/layout/lib/Drupal/layout/Tests/LayoutDerivativesTest.php b/core/modules/layout/lib/Drupal/layout/Tests/LayoutDerivativesTest.php index f41460c..16199b8 100644 --- a/core/modules/layout/lib/Drupal/layout/Tests/LayoutDerivativesTest.php +++ b/core/modules/layout/lib/Drupal/layout/Tests/LayoutDerivativesTest.php @@ -33,7 +33,7 @@ public static function getInfo() { * Tests for module/theme layout derivatives. */ function testDerivatives() { - $manager = drupal_container()->get('plugin.manager.layout'); + $manager = Drupal::service('plugin.manager.layout'); $definitions = $manager->getDefinitions(); $this->assertTrue(is_array($definitions), 'Definitions found.'); diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocalePathTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocalePathTest.php index 4f49d02..15d6021 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocalePathTest.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocalePathTest.php @@ -109,13 +109,13 @@ function testPathLanguageConfiguration() { 'alias' => $custom_path, 'langcode' => LANGUAGE_NOT_SPECIFIED, ); - drupal_container()->get('path.crud')->save($edit['source'], $edit['alias'], $edit['langcode']); - $lookup_path = drupal_container()->get('path.alias_manager')->getPathAlias('node/' . $node->nid, 'en'); + Drupal::service('path.crud')->save($edit['source'], $edit['alias'], $edit['langcode']); + $lookup_path = Drupal::service('path.alias_manager')->getPathAlias('node/' . $node->nid, 'en'); $this->assertEqual($english_path, $lookup_path, t('English language alias has priority.')); // Same check for language 'xx'. - $lookup_path = drupal_container()->get('path.alias_manager')->getPathAlias('node/' . $node->nid, $prefix); + $lookup_path = Drupal::service('path.alias_manager')->getPathAlias('node/' . $node->nid, $prefix); $this->assertEqual($custom_language_path, $lookup_path, t('Custom language alias has priority.')); - drupal_container()->get('path.crud')->delete($edit); + Drupal::service('path.crud')->delete($edit); // Create language nodes to check priority of aliases. $first_node = $this->drupalCreateNode(array('type' => 'page', 'promote' => 1)); @@ -127,7 +127,7 @@ function testPathLanguageConfiguration() { 'alias' => $custom_path, 'langcode' => 'en', ); - drupal_container()->get('path.crud')->save($edit['source'], $edit['alias'], $edit['langcode']); + Drupal::service('path.crud')->save($edit['source'], $edit['alias'], $edit['langcode']); // Assign a custom path alias to second node with LANGUAGE_NOT_SPECIFIED. $edit = array( @@ -135,7 +135,7 @@ function testPathLanguageConfiguration() { 'alias' => $custom_path, 'langcode' => LANGUAGE_NOT_SPECIFIED, ); - drupal_container()->get('path.crud')->save($edit['source'], $edit['alias'], $edit['langcode']); + Drupal::service('path.crud')->save($edit['source'], $edit['alias'], $edit['langcode']); // Test that both node titles link to our path alias. $this->drupalGet(''); diff --git a/core/modules/menu/menu.admin.inc b/core/modules/menu/menu.admin.inc index 9ac32e2..1b051b1 100644 --- a/core/modules/menu/menu.admin.inc +++ b/core/modules/menu/menu.admin.inc @@ -14,7 +14,7 @@ * Menu callback which shows an overview page of all the custom menus and their descriptions. */ function menu_overview_page() { - return drupal_container()->get('plugin.manager.entity') + return Drupal::service('plugin.manager.entity') ->getListController('menu') ->render(); } @@ -327,7 +327,7 @@ function menu_delete_menu_page(Menu $menu) { function menu_delete_menu_confirm($form, &$form_state, Menu $menu) { $form['#menu'] = $menu; $caption = ''; - $num_links = drupal_container()->get('plugin.manager.entity') + $num_links = Drupal::service('plugin.manager.entity') ->getStorageController('menu_link')->countMenuLinks($menu->id()); if ($num_links) { $caption .= '

' . format_plural($num_links, 'Warning: There is currently 1 menu link in %title. It will be deleted (system-defined items will be reset).', 'Warning: There are currently @count menu links in %title. They will be deleted (system-defined links will be reset).', array('%title' => $menu->label())) . '

'; diff --git a/core/modules/menu/menu.module b/core/modules/menu/menu.module index 46d6ead..6e3c98c 100644 --- a/core/modules/menu/menu.module +++ b/core/modules/menu/menu.module @@ -194,7 +194,7 @@ function menu_theme() { * Add a link for each custom menu. */ function menu_enable() { - drupal_container()->get('router.builder')->rebuild(); + Drupal::service('router.builder')->rebuild(); menu_router_rebuild(); $system_link = entity_load_multiple_by_properties('menu_link', array('link_path' => 'admin/structure/menu', 'module' => 'system')); $system_link = reset($system_link); @@ -243,7 +243,7 @@ function menu_menu_insert(Menu $menu) { menu_cache_clear_all(); // Invalidate the block cache to update menu-based derivatives. if (module_exists('block')) { - drupal_container()->get('plugin.manager.block')->clearCachedDefinitions(); + Drupal::service('plugin.manager.block')->clearCachedDefinitions(); } // Make sure the menu is present in the active menus variable so that its // items may appear in the menu active trail. @@ -266,7 +266,7 @@ function menu_menu_update(Menu $menu) { menu_cache_clear_all(); // Invalidate the block cache to update menu-based derivatives. if (module_exists('block')) { - drupal_container()->get('plugin.manager.block')->clearCachedDefinitions(); + Drupal::service('plugin.manager.block')->clearCachedDefinitions(); } } @@ -295,7 +295,7 @@ function menu_menu_delete(Menu $menu) { // Invalidate the block cache to update menu-based derivatives. if (module_exists('block')) { - drupal_container()->get('plugin.manager.block')->clearCachedDefinitions(); + Drupal::service('plugin.manager.block')->clearCachedDefinitions(); } } diff --git a/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkFormController.php b/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkFormController.php index 9506602..a978fea 100644 --- a/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkFormController.php +++ b/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkFormController.php @@ -110,7 +110,7 @@ public function form(array $form, array &$form_state, EntityInterface $menu_link ); // Get number of items in menu so the weight selector is sized appropriately. - $delta = drupal_container()->get('plugin.manager.entity') + $delta = Drupal::service('plugin.manager.entity') ->getStorageController('menu_link')->countMenuLinks($menu_link->menu_name); $form['weight'] = array( '#type' => 'weight', @@ -148,7 +148,7 @@ protected function actions(array $form, array &$form_state) { public function validate(array $form, array &$form_state) { $menu_link = $this->buildEntity($form, $form_state); - $normal_path = drupal_container()->get('path.alias_manager.cached')->getSystemPath($menu_link->link_path); + $normal_path = Drupal::service('path.alias_manager.cached')->getSystemPath($menu_link->link_path); if ($menu_link->link_path != $normal_path) { drupal_set_message(t('The menu system stores system paths only, but will use the URL alias for display. %link_path has been stored as %normal_path', array('%link_path' => $menu_link->link_path, '%normal_path' => $normal_path))); $menu_link->link_path = $normal_path; diff --git a/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkStorageController.php b/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkStorageController.php index 5180b3e..1d684d4 100644 --- a/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkStorageController.php +++ b/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkStorageController.php @@ -79,7 +79,7 @@ protected function attachLoad(&$menu_links, $load_revision = FALSE) { // Now mass-load any routes needed and associate them. if ($routes) { - $route_objects = drupal_container()->get('router.route_provider')->getRoutesByNames($routes); + $route_objects = Drupal::service('router.route_provider')->getRoutesByNames($routes); foreach ($routes as $entity_id => $route) { $menu_links[$entity_id]->setRouteObject($route_objects[$route]); } diff --git a/core/modules/menu_link/lib/Drupal/menu_link/Plugin/Core/Entity/MenuLink.php b/core/modules/menu_link/lib/Drupal/menu_link/Plugin/Core/Entity/MenuLink.php index ce3911d..1b11428 100644 --- a/core/modules/menu_link/lib/Drupal/menu_link/Plugin/Core/Entity/MenuLink.php +++ b/core/modules/menu_link/lib/Drupal/menu_link/Plugin/Core/Entity/MenuLink.php @@ -275,7 +275,7 @@ public function getRoute() { return NULL; } if (!($this->routeObject instanceof Route)) { - $route_provider = drupal_container()->get('router.route_provider'); + $route_provider = Drupal::service('router.route_provider'); $this->routeObject = $route_provider->getRouteByName($this->route_name); } return $this->routeObject; @@ -343,7 +343,7 @@ public static function buildFromRouterItem(array $item) { 'link_path' => $item['path'], 'options' => empty($item['description']) ? array() : array('attributes' => array('title' => $item['description'])), ); - return drupal_container()->get('plugin.manager.entity') + return Drupal::service('plugin.manager.entity') ->getStorageController('menu_link')->create($item); } diff --git a/core/modules/menu_link/menu_link.module b/core/modules/menu_link/menu_link.module index ed11c78..f0a8518 100644 --- a/core/modules/menu_link/menu_link.module +++ b/core/modules/menu_link/menu_link.module @@ -86,7 +86,7 @@ function menu_link_delete_multiple(array $mlids, $force = FALSE, $prevent_repare return; } - $controller = drupal_container()->get('plugin.manager.entity') + $controller = Drupal::service('plugin.manager.entity') ->getStorageController('menu_link'); if (!$force) { $entity_query = entity_query('menu_link'); @@ -137,7 +137,7 @@ function menu_link_save(MenuLink $menu_link) { * The insert op returns the mlid of the new item. Others op return NULL. */ function menu_link_maintain($module, $op, $link_path, $link_title = NULL) { - $menu_link_controller = drupal_container()->get('plugin.manager.entity') + $menu_link_controller = Drupal::service('plugin.manager.entity') ->getStorageController('menu_link'); switch ($op) { case 'insert': diff --git a/core/modules/node/node.views.inc b/core/modules/node/node.views.inc index 5d14a38..8576b84 100644 --- a/core/modules/node/node.views.inc +++ b/core/modules/node/node.views.inc @@ -209,7 +209,7 @@ function node_views_data() { ); } - if (drupal_container()->get('module_handler')->moduleExists('translation_entity')) { + if (Drupal::service('module_handler')->moduleExists('translation_entity')) { $data['node']['translation_link'] = array( 'title' => t('Translation link'), 'help' => t('Provide a link to the translations overview for nodes.'), diff --git a/core/modules/options/options.module b/core/modules/options/options.module index 793b07e..05cbed1 100644 --- a/core/modules/options/options.module +++ b/core/modules/options/options.module @@ -389,7 +389,7 @@ function options_field_update_forbid($field, $prior_field, $has_data) { function _options_values_in_use($field, $values) { if ($values) { $field = field_info_field_by_id($field['id']); - $factory = drupal_container()->get('entity.query'); + $factory = Drupal::service('entity.query'); foreach ($field['bundles'] as $entity_type => $bundle) { $result = $factory->get($entity_type) ->condition($field['field_name'] . '.value', $values) diff --git a/core/modules/overlay/overlay.module b/core/modules/overlay/overlay.module index cc29255..33b8bc8 100644 --- a/core/modules/overlay/overlay.module +++ b/core/modules/overlay/overlay.module @@ -99,7 +99,7 @@ function overlay_field_extra_fields() { function overlay_form_user_profile_form_alter(&$form, &$form_state) { $account = $form_state['controller']->getEntity($form_state); if (user_access('access overlay', $account)) { - $account_data = drupal_container()->get('user.data')->get('overlay', $account->id(), 'enabled'); + $account_data = Drupal::service('user.data')->get('overlay', $account->id(), 'enabled'); $form['overlay_control'] = array( '#type' => 'details', '#title' => t('Administrative overlay'), @@ -119,7 +119,7 @@ function overlay_form_user_profile_form_alter(&$form, &$form_state) { */ function overlay_user_update($account) { if (isset($account->overlay)) { - drupal_container()->get('user.data')->set('overlay', $account->id(), 'enabled', (int) $account->overlay); + Drupal::service('user.data')->set('overlay', $account->id(), 'enabled', (int) $account->overlay); } } @@ -138,7 +138,7 @@ function overlay_init() { // Only act if the user has access to the overlay and a mode was not already // set. Other modules can also enable the overlay directly for other uses. - $user_data = drupal_container()->get('user.data')->get('overlay', $user->uid, 'enabled'); + $user_data = Drupal::service('user.data')->get('overlay', $user->uid, 'enabled'); $use_overlay = !isset($user_data) || $user_data; if (empty($mode) && user_access('access overlay') && $use_overlay) { $current_path = current_path(); @@ -360,12 +360,12 @@ function overlay_user_dismiss_message() { // @todo CSRF tokens are validated in page callbacks rather than access // callbacks, because access callbacks are also invoked during menu link // generation. Add token support to routing: http://drupal.org/node/755584. - $token = drupal_container()->get('request')->query->get('token'); + $token = Drupal::service('request')->query->get('token'); if (!isset($token) || !drupal_valid_token($token, 'overlay')) { throw new AccessDeniedHttpException(); } - drupal_container()->get('user.data')->set('overlay', $user->uid, 'message_dismissed', 1); + Drupal::service('user.data')->set('overlay', $user->uid, 'message_dismissed', 1); drupal_set_message(t('The message has been dismissed. You can change your overlay settings at any time by visiting your profile page.')); // Destination is normally given. Go to the user profile as a fallback. drupal_goto('user/' . $user->uid . '/edit'); @@ -392,7 +392,7 @@ function overlay_disable_message() { return $build; } - $user_data = drupal_container()->get('user.data')->get('overlay', $user->uid); + $user_data = Drupal::service('user.data')->get('overlay', $user->uid); if (empty($user_data['message_dismissed']) && (!isset($user_data['enabled']) || $user_data['enabled'])) { $build = array( '#theme' => 'overlay_disable_message', @@ -732,7 +732,7 @@ function overlay_overlay_child_initialize() { // it to the same content rendered in overlay_exit(), at the end of the page // request. This allows us to check if anything actually did change, and, if // so, trigger an immediate Ajax refresh of the parent window. - $token = drupal_container()->get('request')->query->get('token'); + $token = Drupal::service('request')->query->get('token'); if (!empty($_POST) || isset($token)) { foreach (overlay_supplemental_regions() as $region) { overlay_store_rendered_content($region, overlay_render_region($region)); diff --git a/core/modules/path/lib/Drupal/path/Tests/PathAliasTest.php b/core/modules/path/lib/Drupal/path/Tests/PathAliasTest.php index 23ff7f7..339a847 100644 --- a/core/modules/path/lib/Drupal/path/Tests/PathAliasTest.php +++ b/core/modules/path/lib/Drupal/path/Tests/PathAliasTest.php @@ -92,7 +92,7 @@ function testAdminAlias() { $this->assertText($node1->label(), 'Changed alias works.'); $this->assertResponse(200); - drupal_container()->get('path.alias_manager')->cacheClear(); + Drupal::service('path.alias_manager')->cacheClear(); // Confirm that previous alias no longer works. $this->drupalGet($previous); $this->assertNoText($node1->label(), 'Previous alias no longer works.'); diff --git a/core/modules/path/lib/Drupal/path/Tests/PathLanguageTest.php b/core/modules/path/lib/Drupal/path/Tests/PathLanguageTest.php index 455a3f6..0f8ce63 100644 --- a/core/modules/path/lib/Drupal/path/Tests/PathLanguageTest.php +++ b/core/modules/path/lib/Drupal/path/Tests/PathLanguageTest.php @@ -82,7 +82,7 @@ function testAliasTranslation() { $this->drupalPost(NULL, $edit, t('Save')); // Clear the path lookup cache. - drupal_container()->get('path.alias_manager')->cacheClear(); + Drupal::service('path.alias_manager')->cacheClear(); // Ensure the node was created. $french_node = $this->drupalGetNodeByTitle($edit["title"]); @@ -147,18 +147,18 @@ function testAliasTranslation() { // The alias manager has an internal path lookup cache. Check to see that // it has the appropriate contents at this point. - drupal_container()->get('path.alias_manager')->cacheClear(); - $french_node_path = drupal_container()->get('path.alias_manager')->getSystemPath($french_alias, $french_node->langcode); + Drupal::service('path.alias_manager')->cacheClear(); + $french_node_path = Drupal::service('path.alias_manager')->getSystemPath($french_alias, $french_node->langcode); $this->assertEqual($french_node_path, 'node/' . $french_node->nid, 'Normal path works.'); // Second call should return the same path. - $french_node_path = drupal_container()->get('path.alias_manager')->getSystemPath($french_alias, $french_node->langcode); + $french_node_path = Drupal::service('path.alias_manager')->getSystemPath($french_alias, $french_node->langcode); $this->assertEqual($french_node_path, 'node/' . $french_node->nid, 'Normal path is the same.'); // Confirm that the alias works. - $french_node_alias = drupal_container()->get('path.alias_manager')->getPathAlias('node/' . $french_node->nid, $french_node->langcode); + $french_node_alias = Drupal::service('path.alias_manager')->getPathAlias('node/' . $french_node->nid, $french_node->langcode); $this->assertEqual($french_node_alias, $french_alias, 'Alias works.'); // Second call should return the same alias. - $french_node_alias = drupal_container()->get('path.alias_manager')->getPathAlias('node/' . $french_node->nid, $french_node->langcode); + $french_node_alias = Drupal::service('path.alias_manager')->getPathAlias('node/' . $french_node->nid, $french_node->langcode); $this->assertEqual($french_node_alias, $french_alias, 'Alias is the same.'); } } diff --git a/core/modules/path/path.admin.inc b/core/modules/path/path.admin.inc index 0535454..a0ca08a 100644 --- a/core/modules/path/path.admin.inc +++ b/core/modules/path/path.admin.inc @@ -75,7 +75,7 @@ function path_admin_overview($keys = NULL) { // If the system path maps to a different URL alias, highlight this table // row to let the user know of old aliases. - if ($data->alias != drupal_container()->get('path.alias_manager')->getPathAlias($data->source, $data->langcode)) { + if ($data->alias != Drupal::service('path.alias_manager')->getPathAlias($data->source, $data->langcode)) { $row['class'] = array('warning'); } @@ -217,7 +217,7 @@ function path_admin_form_delete_submit($form, &$form_state) { */ function path_admin_form_validate($form, &$form_state) { $source = &$form_state['values']['source']; - $source = drupal_container()->get('path.alias_manager')->getSystemPath($source); + $source = Drupal::service('path.alias_manager')->getSystemPath($source); $alias = $form_state['values']['alias']; $pid = isset($form_state['values']['pid']) ? $form_state['values']['pid'] : 0; // Language is only set if language.module is enabled, otherwise save for all @@ -251,13 +251,13 @@ function path_admin_form_submit($form, &$form_state) { $pid = isset($form_state['values']['pid']) ? $form_state['values']['pid'] : 0; $source = &$form_state['values']['source']; - $source = drupal_container()->get('path.alias_manager')->getSystemPath($source); + $source = Drupal::service('path.alias_manager')->getSystemPath($source); $alias = $form_state['values']['alias']; // Language is only set if language.module is enabled, otherwise save for all // languages. $langcode = isset($form_state['values']['langcode']) ? $form_state['values']['langcode'] : LANGUAGE_NOT_SPECIFIED; - drupal_container()->get('path.crud')->save($source, $alias, $langcode, $pid); + Drupal::service('path.crud')->save($source, $alias, $langcode, $pid); drupal_set_message(t('The alias has been saved.')); $form_state['redirect'] = 'admin/config/search/path'; @@ -289,7 +289,7 @@ function path_admin_delete_confirm($form, &$form_state, $path) { */ function path_admin_delete_confirm_submit($form, &$form_state) { if ($form_state['values']['confirm']) { - drupal_container()->get('path.crud')->delete(array('pid' => $form_state['path']['pid'])); + Drupal::service('path.crud')->delete(array('pid' => $form_state['path']['pid'])); $form_state['redirect'] = 'admin/config/search/path'; } } diff --git a/core/modules/path/path.module b/core/modules/path/path.module index 6401a8b..d4c117d 100644 --- a/core/modules/path/path.module +++ b/core/modules/path/path.module @@ -106,7 +106,7 @@ function path_form_node_form_alter(&$form, $form_state) { if ($node->langcode != LANGUAGE_NOT_SPECIFIED) { $conditions['langcode'] = $node->langcode; } - $path = drupal_container()->get('path.crud')->load($conditions); + $path = Drupal::service('path.crud')->load($conditions); if ($path === FALSE) { $path = array(); } @@ -194,7 +194,7 @@ function path_node_insert(Node $node) { // Ensure fields for programmatic executions. $source = 'node/' . $node->nid; $langcode = isset($node->langcode) ? $node->langcode : LANGUAGE_NOT_SPECIFIED; - drupal_container()->get('path.crud')->save($source, $alias, $langcode); + Drupal::service('path.crud')->save($source, $alias, $langcode); } } } @@ -208,14 +208,14 @@ function path_node_update(Node $node) { $alias = trim($path['alias']); // Delete old alias if user erased it. if (!empty($path['pid']) && empty($path['alias'])) { - drupal_container()->get('path.crud')->delete(array('pid' => $path['pid'])); + Drupal::service('path.crud')->delete(array('pid' => $path['pid'])); } // Only save a non-empty alias. if (!empty($path['alias'])) { // Ensure fields for programmatic executions. $source = 'node/' . $node->nid; $langcode = isset($node->langcode) ? $node->langcode : LANGUAGE_NOT_SPECIFIED; - drupal_container()->get('path.crud')->save($source, $alias, $langcode, $path['pid']); + Drupal::service('path.crud')->save($source, $alias, $langcode, $path['pid']); } } } @@ -225,7 +225,7 @@ function path_node_update(Node $node) { */ function path_node_predelete(Node $node) { // Delete all aliases associated with this node. - drupal_container()->get('path.crud')->delete(array('source' => 'node/' . $node->nid)); + Drupal::service('path.crud')->delete(array('source' => 'node/' . $node->nid)); } /** @@ -235,7 +235,7 @@ function path_form_taxonomy_term_form_alter(&$form, $form_state) { // Make sure this does not show up on the delete confirmation form. if (empty($form_state['confirm_delete'])) { $term = $form_state['controller']->getEntity($form_state); - $path = (isset($term->tid) ? drupal_container()->get('path.crud')->load(array('source' => 'taxonomy/term/' . $term->tid)) : array()); + $path = (isset($term->tid) ? Drupal::service('path.crud')->load(array('source' => 'taxonomy/term/' . $term->tid)) : array()); if ($path === FALSE) { $path = array(); } @@ -276,7 +276,7 @@ function path_taxonomy_term_insert(Term $term) { // Ensure fields for programmatic executions. $path['source'] = 'taxonomy/term/' . $term->tid; $path['langcode'] = LANGUAGE_NOT_SPECIFIED; - drupal_container()->get('path.crud')->save($path['source'], $path['alias'], $path['langcode']); + Drupal::service('path.crud')->save($path['source'], $path['alias'], $path['langcode']); } } } @@ -290,7 +290,7 @@ function path_taxonomy_term_update(Term $term) { $path['alias'] = trim($path['alias']); // Delete old alias if user erased it. if (!empty($path['pid']) && empty($path['alias'])) { - drupal_container()->get('path.crud')->delete(array('pid' => $path['pid'])); + Drupal::service('path.crud')->delete(array('pid' => $path['pid'])); } // Only save a non-empty alias. if (!empty($path['alias'])) { @@ -298,7 +298,7 @@ function path_taxonomy_term_update(Term $term) { // Ensure fields for programmatic executions. $path['source'] = 'taxonomy/term/' . $term->tid; $path['langcode'] = LANGUAGE_NOT_SPECIFIED; - drupal_container()->get('path.crud')->save($path['source'], $path['alias'], $path['langcode'], $pid); + Drupal::service('path.crud')->save($path['source'], $path['alias'], $path['langcode'], $pid); } } } @@ -308,7 +308,7 @@ function path_taxonomy_term_update(Term $term) { */ function path_taxonomy_term_delete(Term $term) { // Delete all aliases associated with this term. - drupal_container()->get('path.crud')->delete(array('source' => 'taxonomy/term/' . $term->tid)); + Drupal::service('path.crud')->delete(array('source' => 'taxonomy/term/' . $term->tid)); } /** diff --git a/core/modules/picture/picture_mapping.admin.inc b/core/modules/picture/picture_mapping.admin.inc index a3d6ade..4cf7be7 100644 --- a/core/modules/picture/picture_mapping.admin.inc +++ b/core/modules/picture/picture_mapping.admin.inc @@ -16,7 +16,7 @@ * @see picture_menu() */ function picture_mapping_page() { - return drupal_container()->get('plugin.manager.entity') + return Drupal::service('plugin.manager.entity') ->getListController('picture_mapping') ->render(); } diff --git a/core/modules/rest/lib/Drupal/rest/Plugin/ResourceBase.php b/core/modules/rest/lib/Drupal/rest/Plugin/ResourceBase.php index 747df45..0d12270 100644 --- a/core/modules/rest/lib/Drupal/rest/Plugin/ResourceBase.php +++ b/core/modules/rest/lib/Drupal/rest/Plugin/ResourceBase.php @@ -68,7 +68,7 @@ public function routes() { case 'HEAD': // Restrict GET and HEAD requests to the media type specified in the // HTTP Accept headers. - $formats = drupal_container()->getParameter('serializer.formats'); + $formats = Drupal::getContainer()->getParameter('serializer.formats'); foreach ($formats as $format_name => $label) { // Expose one route per available format. //$format_route = new Route($route->getPattern(), $route->getDefaults(), $route->getRequirements()); diff --git a/core/modules/rest/lib/Drupal/rest/Plugin/views/display/RestExport.php b/core/modules/rest/lib/Drupal/rest/Plugin/views/display/RestExport.php index 3496ee0..db47a15 100644 --- a/core/modules/rest/lib/Drupal/rest/Plugin/views/display/RestExport.php +++ b/core/modules/rest/lib/Drupal/rest/Plugin/views/display/RestExport.php @@ -74,7 +74,7 @@ class RestExport extends PathPluginBase { public function initDisplay(ViewExecutable $view, array &$display, array &$options = NULL) { parent::initDisplay($view, $display, $options); - $container = drupal_container(); + $container = Drupal::getContainer(); $negotiation = $container->get('content_negotiation'); $request = $container->get('request'); diff --git a/core/modules/rest/lib/Drupal/rest/Plugin/views/style/Serializer.php b/core/modules/rest/lib/Drupal/rest/Plugin/views/style/Serializer.php index 1906cfa..9b14b57 100644 --- a/core/modules/rest/lib/Drupal/rest/Plugin/views/style/Serializer.php +++ b/core/modules/rest/lib/Drupal/rest/Plugin/views/style/Serializer.php @@ -52,7 +52,7 @@ public function init(ViewExecutable $view, DisplayPluginBase $display, array &$o parent::init($view, $display, $options); // Get the serializer service. - $this->serializer = drupal_container()->get('serializer'); + $this->serializer = Drupal::service('serializer'); } /** diff --git a/core/modules/rest/lib/Drupal/rest/Tests/CreateTest.php b/core/modules/rest/lib/Drupal/rest/Tests/CreateTest.php index a3a5c60..ca2847d 100644 --- a/core/modules/rest/lib/Drupal/rest/Tests/CreateTest.php +++ b/core/modules/rest/lib/Drupal/rest/Tests/CreateTest.php @@ -33,7 +33,7 @@ public static function getInfo() { * Tests several valid and invalid create requests on all entity types. */ public function testCreate() { - $serializer = drupal_container()->get('serializer'); + $serializer = Drupal::service('serializer'); // @todo once EntityNG is implemented for other entity types test all other // entity types here as well. $entity_type = 'entity_test'; diff --git a/core/modules/rest/lib/Drupal/rest/Tests/RESTTestBase.php b/core/modules/rest/lib/Drupal/rest/Tests/RESTTestBase.php index c428c86..8d669fb 100644 --- a/core/modules/rest/lib/Drupal/rest/Tests/RESTTestBase.php +++ b/core/modules/rest/lib/Drupal/rest/Tests/RESTTestBase.php @@ -177,7 +177,7 @@ protected function enableService($resource_type, $method = 'GET', $format = NULL $config->save(); // Rebuild routing cache, so that the web API paths are available. - drupal_container()->get('router.builder')->rebuild(); + Drupal::service('router.builder')->rebuild(); // Reset the Simpletest permission cache, so that the new resource // permissions get picked up. drupal_static_reset('checkPermissions'); diff --git a/core/modules/rest/lib/Drupal/rest/Tests/UpdateTest.php b/core/modules/rest/lib/Drupal/rest/Tests/UpdateTest.php index 94be2bf..97ac2a0 100644 --- a/core/modules/rest/lib/Drupal/rest/Tests/UpdateTest.php +++ b/core/modules/rest/lib/Drupal/rest/Tests/UpdateTest.php @@ -33,7 +33,7 @@ public static function getInfo() { * Tests several valid and invalid partial update requests on test entities. */ public function testPatchUpdate() { - $serializer = drupal_container()->get('serializer'); + $serializer = Drupal::service('serializer'); // @todo once EntityNG is implemented for other entity types test all other // entity types here as well. $entity_type = 'entity_test'; @@ -98,7 +98,7 @@ public function testPatchUpdate() { * Tests several valid and invalid PUT update requests on test entities. */ public function testPutUpdate() { - $serializer = drupal_container()->get('serializer'); + $serializer = Drupal::service('serializer'); // @todo once EntityNG is implemented for other entity types test all other // entity types here as well. $entity_type = 'entity_test'; diff --git a/core/modules/rest/lib/Drupal/rest/Tests/Views/StyleSerializerTest.php b/core/modules/rest/lib/Drupal/rest/Tests/Views/StyleSerializerTest.php index 4aeaaa7..da5b4de 100644 --- a/core/modules/rest/lib/Drupal/rest/Tests/Views/StyleSerializerTest.php +++ b/core/modules/rest/lib/Drupal/rest/Tests/Views/StyleSerializerTest.php @@ -113,7 +113,7 @@ public function testSerializerResponses() { $this->executeView($view); // Get the serializer service. - $serializer = drupal_container()->get('serializer'); + $serializer = Drupal::service('serializer'); $entities = array(); foreach ($view->result as $row) { diff --git a/core/modules/rest/rest.admin.inc b/core/modules/rest/rest.admin.inc index 95246ea..6b5a9a3 100644 --- a/core/modules/rest/rest.admin.inc +++ b/core/modules/rest/rest.admin.inc @@ -11,7 +11,7 @@ * @ingroup forms */ function rest_admin_form($form, &$form_state) { - $resources = drupal_container() + $resources = Drupal::getContainer() ->get('plugin.manager.rest') ->getDefinitions(); $entity_resources = array(); @@ -87,7 +87,7 @@ function rest_admin_form_submit($form, &$form_state) { $enabled_resources += array_filter($form_state['values']['other_resources']); } $resources = array(); - $plugin_manager = drupal_container()->get('plugin.manager.rest'); + $plugin_manager = Drupal::service('plugin.manager.rest'); // Enable all methods and all formats for each selected resource. foreach ($enabled_resources as $resource) { @@ -102,5 +102,5 @@ function rest_admin_form_submit($form, &$form_state) { $config->save(); // Rebuild routing cache. - drupal_container()->get('router.builder')->rebuild(); + Drupal::service('router.builder')->rebuild(); } diff --git a/core/modules/rest/rest.module b/core/modules/rest/rest.module index 233db32..66c9254 100644 --- a/core/modules/rest/rest.module +++ b/core/modules/rest/rest.module @@ -28,8 +28,8 @@ function rest_menu() { */ function rest_permission() { $permissions = array(); - if (drupal_container()->has('plugin.manager.rest')) { - $manager = drupal_container()->get('plugin.manager.rest'); + if (Drupal::getContainer()->has('plugin.manager.rest')) { + $manager = Drupal::service('plugin.manager.rest'); $resources = config('rest.settings')->get('resources'); if ($resources && $enabled = array_intersect_key($manager->getDefinitions(), $resources)) { foreach ($enabled as $key => $resource) { diff --git a/core/modules/search/lib/Drupal/search/Plugin/views/argument/Search.php b/core/modules/search/lib/Drupal/search/Plugin/views/argument/Search.php index 354b0c1..fb3e69a 100644 --- a/core/modules/search/lib/Drupal/search/Plugin/views/argument/Search.php +++ b/core/modules/search/lib/Drupal/search/Plugin/views/argument/Search.php @@ -68,7 +68,7 @@ public function query($group_by = FALSE) { 'left_table' => $search_index, 'left_field' => 'word', ); - $join = drupal_container()->get('plugin.manager.views.join')->createInstance('standard', $definition); + $join = Drupal::service('plugin.manager.views.join')->createInstance('standard', $definition); $search_total = $this->query->add_relationship('search_total', $join, $search_index); $this->search_score = $this->query->add_field('', "SUM($search_index.score * $search_total.count)", 'score', array('aggregate' => TRUE)); diff --git a/core/modules/search/lib/Drupal/search/Plugin/views/filter/Search.php b/core/modules/search/lib/Drupal/search/Plugin/views/filter/Search.php index 3c961b6..153485e 100644 --- a/core/modules/search/lib/Drupal/search/Plugin/views/filter/Search.php +++ b/core/modules/search/lib/Drupal/search/Plugin/views/filter/Search.php @@ -148,7 +148,7 @@ public function query() { 'left_table' => $search_index, 'left_field' => 'word', ); - $join = drupal_container()->get('plugin.manager.views.join')->createInstance('standard', $definition); + $join = Drupal::service('plugin.manager.views.join')->createInstance('standard', $definition); $search_total = $this->query->add_relationship('search_total', $join, $search_index); diff --git a/core/modules/search/search.module b/core/modules/search/search.module index 375c43f..7c231db 100644 --- a/core/modules/search/search.module +++ b/core/modules/search/search.module @@ -629,7 +629,7 @@ function search_index($sid, $module, $text, $langcode) { if ($tagname == 'a') { // Check if link points to a node on this site if (preg_match($node_regexp, $value, $match)) { - $path = drupal_container()->get('path.alias_manager')->getSystemPath($match[1]); + $path = Drupal::service('path.alias_manager')->getSystemPath($match[1]); if (preg_match('!(?:node|book)/(?:view/)?([0-9]+)!i', $path, $match)) { $linknid = $match[1]; if ($linknid > 0) { diff --git a/core/modules/serialization/lib/Drupal/serialization/Tests/SerializationTest.php b/core/modules/serialization/lib/Drupal/serialization/Tests/SerializationTest.php index e0c62cd..be49104 100644 --- a/core/modules/serialization/lib/Drupal/serialization/Tests/SerializationTest.php +++ b/core/modules/serialization/lib/Drupal/serialization/Tests/SerializationTest.php @@ -36,7 +36,7 @@ public static function getInfo() { protected function setUp() { parent::setUp(); - $this->serializer = drupal_container()->get('serializer'); + $this->serializer = Drupal::service('serializer'); } /** diff --git a/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutLinksTest.php b/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutLinksTest.php index ca1d88b..4dddce8 100644 --- a/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutLinksTest.php +++ b/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutLinksTest.php @@ -31,7 +31,7 @@ function testShortcutLinkAdd() { 'source' => 'node/' . $this->node->nid, 'alias' => $this->randomName(8), ); - drupal_container()->get('path.crud')->save($path['source'], $path['alias']); + Drupal::service('path.crud')->save($path['source'], $path['alias']); // Create some paths to test. $test_cases = array( @@ -54,7 +54,7 @@ function testShortcutLinkAdd() { $saved_set = shortcut_set_load($set->id()); $paths = $this->getShortcutInformation($saved_set, 'link_path'); $test_path = empty($test['path']) ? '' : $test['path']; - $this->assertTrue(in_array(drupal_container()->get('path.alias_manager')->getSystemPath($test_path), $paths), 'Shortcut created: '. $test['path']); + $this->assertTrue(in_array(Drupal::service('path.alias_manager')->getSystemPath($test_path), $paths), 'Shortcut created: '. $test['path']); $this->assertLink($title, 0, 'Shortcut link found on the page.'); } } diff --git a/core/modules/shortcut/shortcut.admin.inc b/core/modules/shortcut/shortcut.admin.inc index 0e43052..685b78a 100644 --- a/core/modules/shortcut/shortcut.admin.inc +++ b/core/modules/shortcut/shortcut.admin.inc @@ -368,7 +368,7 @@ function _shortcut_link_form_elements($shortcut_link = NULL) { )); } else { - $shortcut_link['link_path'] = ($shortcut_link['link_path'] == '') ? '' : drupal_container()->get('path.alias_manager')->getPathAlias($shortcut_link['link_path']); + $shortcut_link['link_path'] = ($shortcut_link['link_path'] == '') ? '' : Drupal::service('path.alias_manager')->getPathAlias($shortcut_link['link_path']); } $form['shortcut_link']['#tree'] = TRUE; @@ -415,7 +415,7 @@ function shortcut_link_edit_validate($form, &$form_state) { */ function shortcut_link_edit_submit($form, &$form_state) { // Normalize the path in case it is an alias. - $shortcut_path = drupal_container()->get('path.alias_manager')->getSystemPath($form_state['values']['shortcut_link']['link_path']); + $shortcut_path = Drupal::service('path.alias_manager')->getSystemPath($form_state['values']['shortcut_link']['link_path']); if (empty($shortcut_path)) { $shortcut_path = ''; } @@ -459,7 +459,7 @@ function shortcut_link_add_submit($form, &$form_state) { */ function shortcut_admin_add_link($shortcut_link, &$shortcut_set) { // Normalize the path in case it is an alias. - $shortcut_link['link_path'] = drupal_container()->get('path.alias_manager')->getSystemPath($shortcut_link['link_path']); + $shortcut_link['link_path'] = Drupal::service('path.alias_manager')->getSystemPath($shortcut_link['link_path']); if (empty($shortcut_link['link_path'])) { $shortcut_link['link_path'] = ''; } diff --git a/core/modules/shortcut/shortcut.module b/core/modules/shortcut/shortcut.module index 25a04c7..82373d4 100644 --- a/core/modules/shortcut/shortcut.module +++ b/core/modules/shortcut/shortcut.module @@ -458,7 +458,7 @@ function shortcut_set_title_exists($title) { */ function shortcut_valid_link($path) { // Do not use URL aliases. - $normal_path = drupal_container()->get('path.alias_manager')->getSystemPath($path); + $normal_path = Drupal::service('path.alias_manager')->getSystemPath($path); if ($path != $normal_path) { $path = $normal_path; } diff --git a/core/modules/simpletest/lib/Drupal/simpletest/DrupalUnitTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/DrupalUnitTestBase.php index bc472c4..a1a47c5 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/DrupalUnitTestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/DrupalUnitTestBase.php @@ -87,7 +87,7 @@ protected function setUp() { parent::setUp(); // Build a minimal, partially mocked environment for unit tests. - $this->containerBuild(drupal_container()); + $this->containerBuild(Drupal::getContainer()); // Make sure it survives kernel rebuilds. $GLOBALS['conf']['container_bundles'][] = 'Drupal\simpletest\TestBundle'; @@ -156,7 +156,7 @@ public function containerBuild($container) { $container->set('keyvalue.memory', $this->keyValueFactory); if (!$container->has('keyvalue')) { // TestBase::setUp puts a completely empty container in - // drupal_container() which is somewhat the mirror of the empty + // Drupal::getContainer() which is somewhat the mirror of the empty // environment being set up. Unit tests need not to waste time with // getting a container set up for them. Drupal Unit Tests might just get // away with a simple container holding the absolute bare minimum. When diff --git a/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php index 35af531..a00a326 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php @@ -852,7 +852,7 @@ protected function prepareEnvironment() { $this->originalConf = $conf; // Backup statics and globals. - $this->originalContainer = clone drupal_container(); + $this->originalContainer = clone Drupal::getContainer(); $this->originalLanguage = $language_interface; $this->originalConfigDirectories = $GLOBALS['config_directories']; if (isset($GLOBALS['theme_key'])) { @@ -947,7 +947,7 @@ protected function prepareConfigDirectories() { } /** - * Rebuild drupal_container(). + * Rebuild Drupal::getContainer(). * * Use this to build a new kernel and service container. For example, when the * list of enabled modules is changed via the internal browser, in which case @@ -955,7 +955,7 @@ protected function prepareConfigDirectories() { * old module list. * * @todo Fix http://drupal.org/node/1708692 so that module enable/disable - * changes are immediately reflected in drupal_container(). Until then, + * changes are immediately reflected in Drupal::getContainer(). Until then, * tests can invoke this workaround when requiring services from newly * enabled modules to be immediately available in the same request. * @@ -965,9 +965,9 @@ protected function prepareConfigDirectories() { protected function rebuildContainer() { $this->kernel = new DrupalKernel('testing', FALSE, drupal_classloader(), FALSE); $this->kernel->boot(); - // DrupalKernel replaces the container in drupal_container() with a + // DrupalKernel replaces the container in Drupal::getContainer() with a // different object, so we need to replace the instance on this test class. - $this->container = drupal_container(); + $this->container = Drupal::getContainer(); } /** @@ -1010,7 +1010,7 @@ protected function tearDown() { // In case a fatal error occurred that was not in the test process read the // log to pick up any fatal errors. simpletest_log_read($this->testId, $this->databasePrefix, get_class($this), TRUE); - if (($container = drupal_container()) && $container->has('keyvalue')) { + if (($container = Drupal::getContainer()) && $container->has('keyvalue')) { $captured_emails = state()->get('system.test_email_collector') ?: array(); $emailCount = count($captured_emails); if ($emailCount) { diff --git a/core/modules/simpletest/lib/Drupal/simpletest/Tests/DrupalUnitTestBaseTest.php b/core/modules/simpletest/lib/Drupal/simpletest/Tests/DrupalUnitTestBaseTest.php index 3aeab60..385cabe 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/Tests/DrupalUnitTestBaseTest.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/Tests/DrupalUnitTestBaseTest.php @@ -39,7 +39,7 @@ function testSetUp() { // Verify that specified $modules have been loaded. $this->assertTrue(function_exists('entity_test_permission'), "$module.module was loaded."); // Verify that there is a fixed module list. - $this->assertIdentical(array_keys(drupal_container()->get('module_handler')->getModuleList()), array($module)); + $this->assertIdentical(array_keys(Drupal::service('module_handler')->getModuleList()), array($module)); $this->assertIdentical(module_implements('permission'), array($module)); // Verify that no modules have been installed. @@ -54,7 +54,7 @@ function testEnableModulesLoad() { // Verify that the module does not exist yet. $this->assertFalse(module_exists($module), "$module module not found."); - $list = array_keys(drupal_container()->get('module_handler')->getModuleList()); + $list = array_keys(Drupal::service('module_handler')->getModuleList()); $this->assertFalse(in_array($module, $list), "$module module not found in the extension handler's module list."); $list = module_implements('permission'); $this->assertFalse(in_array($module, $list), "{$module}_permission() in module_implements() not found."); @@ -64,7 +64,7 @@ function testEnableModulesLoad() { // Verify that the module exists. $this->assertTrue(module_exists($module), "$module module found."); - $list = array_keys(drupal_container()->get('module_handler')->getModuleList()); + $list = array_keys(Drupal::service('module_handler')->getModuleList()); $this->assertTrue(in_array($module, $list), "$module module found in the extension handler's module list."); $list = module_implements('permission'); $this->assertTrue(in_array($module, $list), "{$module}_permission() in module_implements() found."); @@ -79,7 +79,7 @@ function testEnableModulesInstall() { // Verify that the module does not exist yet. $this->assertFalse(module_exists($module), "$module module not found."); - $list = array_keys(drupal_container()->get('module_handler')->getModuleList()); + $list = array_keys(Drupal::service('module_handler')->getModuleList()); $this->assertFalse(in_array($module, $list), "$module module not found in the extension handler's module list."); $list = module_implements('permission'); $this->assertFalse(in_array($module, $list), "{$module}_permission() in module_implements() not found."); @@ -93,7 +93,7 @@ function testEnableModulesInstall() { // Verify that the enabled module exists. $this->assertTrue(module_exists($module), "$module module found."); - $list = array_keys(drupal_container()->get('module_handler')->getModuleList()); + $list = array_keys(Drupal::service('module_handler')->getModuleList()); $this->assertTrue(in_array($module, $list), "$module module found in the extension handler's module list."); $list = module_implements('permission'); $this->assertTrue(in_array($module, $list), "{$module}_permission() in module_implements() found."); diff --git a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php index 44e29c2..b8eb9c2 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php @@ -177,7 +177,7 @@ function __construct($test_id = NULL) { */ function drupalGetNodeByTitle($title, $reset = FALSE) { if ($reset) { - drupal_container()->get('plugin.manager.entity')->getStorageController('node')->resetCache(); + Drupal::service('plugin.manager.entity')->getStorageController('node')->resetCache(); } $nodes = entity_load_multiple_by_properties('node', array('title' => $title)); // Load the first node returned from the database. @@ -898,7 +898,7 @@ protected function refreshVariables() { global $conf; cache('bootstrap')->delete('variables'); $conf = variable_initialize(); - drupal_container()->get('config.factory')->reset(); + Drupal::service('config.factory')->reset(); } /** diff --git a/core/modules/statistics/statistics.admin.inc b/core/modules/statistics/statistics.admin.inc index d454321c..1f6c9db 100644 --- a/core/modules/statistics/statistics.admin.inc +++ b/core/modules/statistics/statistics.admin.inc @@ -41,6 +41,6 @@ function statistics_settings_form_submit($form, &$form_state) { // The popular statistics block is dependent on these settings, so clear the // block plugin definitions cache. if (module_exists('block')) { - drupal_container()->get('plugin.manager.block')->clearCachedDefinitions(); + Drupal::service('plugin.manager.block')->clearCachedDefinitions(); } } diff --git a/core/modules/statistics/statistics.module b/core/modules/statistics/statistics.module index f6a9d48..367f29f 100644 --- a/core/modules/statistics/statistics.module +++ b/core/modules/statistics/statistics.module @@ -173,7 +173,7 @@ function statistics_get($nid) { * A string as a link, truncated to the width, linked to the given $path. */ function _statistics_link($path, $width = 35) { - $title = drupal_container()->get('path.alias_manager')->getPathAlias($path); + $title = Drupal::service('path.alias_manager')->getPathAlias($path); $title = truncate_utf8($title, $width, FALSE, TRUE); return l($title, $path); } diff --git a/core/modules/system/language.api.php b/core/modules/system/language.api.php index 7c7375f..54c664a 100644 --- a/core/modules/system/language.api.php +++ b/core/modules/system/language.api.php @@ -191,7 +191,7 @@ function hook_language_fallback_candidates_alter(array &$fallback_candidates) { * // Use the current default interface language. * $langcode = language(LANGUAGE_TYPE_INTERFACE)->langcode; * // Instantiate the transliteration class. - * $trans = drupal_container()->get('transliteration'); + * $trans = Drupal::service('transliteration'); * // Use this to transliterate some text. * $transformed = $trans->transliterate($string, $langcode); * @endcode diff --git a/core/modules/system/lib/Drupal/system/Plugin/PluginUIBase.php b/core/modules/system/lib/Drupal/system/Plugin/PluginUIBase.php index dd890fd..cc02b18 100644 --- a/core/modules/system/lib/Drupal/system/Plugin/PluginUIBase.php +++ b/core/modules/system/lib/Drupal/system/Plugin/PluginUIBase.php @@ -27,7 +27,7 @@ public function form($form, &$form_state) { $manager = new $plugin_definition['manager'](); } else { - $manager = drupal_container()->get($plugin_definition['manager']); + $manager = Drupal::getContainer()->get($plugin_definition['manager']); } $plugins = $manager->getDefinitions(); diff --git a/core/modules/system/lib/Drupal/system/Tests/Bootstrap/GetFilenameUnitTest.php b/core/modules/system/lib/Drupal/system/Tests/Bootstrap/GetFilenameUnitTest.php index d2d4cc7..a862d1d 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Bootstrap/GetFilenameUnitTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Bootstrap/GetFilenameUnitTest.php @@ -28,7 +28,7 @@ public static function getInfo() { function testDrupalGetFilename() { // Assert that the test is meaningful by making sure the keyvalue service // does not exist. - $this->assertFalse(drupal_container()->has('keyvalue'), 'The container has no keyvalue service.'); + $this->assertFalse(Drupal::getContainer()->has('keyvalue'), 'The container has no keyvalue service.'); // Retrieving the location of a module. $this->assertIdentical(drupal_get_filename('module', 'php'), 'core/modules/php/php.module', 'Retrieve module location.'); diff --git a/core/modules/system/lib/Drupal/system/Tests/Bundle/BundleTest.php b/core/modules/system/lib/Drupal/system/Tests/Bundle/BundleTest.php index 35faa3c..e286afd 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Bundle/BundleTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Bundle/BundleTest.php @@ -33,8 +33,8 @@ public static function getInfo() { * Tests that services provided by module bundles get registered to the DIC. */ function testBundleRegistration() { - $this->assertTrue(drupal_container()->getDefinition('file.usage')->getClass() == 'Drupal\\bundle_test\\TestFileUsage', 'Class has been changed'); - $this->assertTrue(drupal_container()->has('bundle_test_class'), 'The bundle_test_class service has been registered to the DIC'); + $this->assertTrue(Drupal::getContainer()->getDefinition('file.usage')->getClass() == 'Drupal\\bundle_test\\TestFileUsage', 'Class has been changed'); + $this->assertTrue(Drupal::getContainer()->has('bundle_test_class'), 'The bundle_test_class service has been registered to the DIC'); // The event subscriber method in the test class calls drupal_set_message with // a message saying it has fired. This will fire on every page request so it // should show up on the front page. @@ -48,11 +48,11 @@ function testBundleRegistration() { function testBundleRegistrationDynamic() { // Disable the module and ensure the bundle's service is not registered. module_disable(array('bundle_test')); - $this->assertFalse(drupal_container()->has('bundle_test_class'), 'The bundle_test_class service does not exist in the DIC.'); + $this->assertFalse(Drupal::getContainer()->has('bundle_test_class'), 'The bundle_test_class service does not exist in the DIC.'); // Enable the module and ensure the bundle's service is registered. module_enable(array('bundle_test')); - $this->assertTrue(drupal_container()->has('bundle_test_class'), 'The bundle_test_class service exists in the DIC.'); + $this->assertTrue(Drupal::getContainer()->has('bundle_test_class'), 'The bundle_test_class service exists in the DIC.'); } } diff --git a/core/modules/system/lib/Drupal/system/Tests/Common/JavaScriptTest.php b/core/modules/system/lib/Drupal/system/Tests/Common/JavaScriptTest.php index 3c54ad4..9140347 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Common/JavaScriptTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Common/JavaScriptTest.php @@ -200,7 +200,7 @@ function testHeaderSetting() { $this->drupalGet('common-test/query-string'); $this->assertPattern('@