Unverified Commit 1110b04d authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2347783 by kim.pepper, andypost, almaudoh, gumanist, aleevas,...

Issue #2347783 by kim.pepper, andypost, almaudoh, gumanist, aleevas, rodrigoaguilera, Berdir, saurabh-2k17, Spokje, dhirendra.mishra, alexpott, paulocs, izus, Wim Leers, KapilV, naveenvalecha, anmolgoyal74, subson, yo30, harsha012, mrinalini9, daffie, voleger, dww, fietserwin, tim.plunkett, joachim, larowlan: Deprecate drupal_get_path() and drupal_get_filename() and replace with ExtensionList::getPath() and ExtensionList::getPathname()
parent e8ff8ea1
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -306,7 +306,7 @@ services:
      - { name: dynamic_page_cache_response_policy }
  config.manager:
    class: Drupal\Core\Config\ConfigManager
    arguments: ['@entity_type.manager', '@config.factory', '@config.typed', '@string_translation', '@config.storage', '@event_dispatcher', '@entity.repository']
    arguments: ['@entity_type.manager', '@config.factory', '@config.typed', '@string_translation', '@config.storage', '@event_dispatcher', '@entity.repository', '@extension.path.resolver']
  config.factory:
    class: Drupal\Core\Config\ConfigFactory
    tags:
@@ -319,7 +319,7 @@ services:
      - { name: event_subscriber }
  config.installer:
    class: Drupal\Core\Config\ConfigInstaller
    arguments: ['@config.factory', '@config.storage', '@config.typed', '@config.manager', '@event_dispatcher', '%install_profile%']
    arguments: ['@config.factory', '@config.storage', '@config.typed', '@config.manager', '@event_dispatcher', '%install_profile%', '@extension.path.resolver']
    lazy: true
  config.storage:
    class: Drupal\Core\Config\CachedStorage
@@ -544,6 +544,9 @@ services:
  extension.list.theme_engine:
    class: Drupal\Core\Extension\ThemeEngineExtensionList
    arguments: ['%app.root%', 'theme_engine', '@cache.default', '@info_parser', '@module_handler', '@state', '%install_profile%']
  extension.path.resolver:
    class: Drupal\Core\Extension\ExtensionPathResolver
    arguments: ['@extension.list.module', '@extension.list.profile', '@extension.list.theme', '@extension.list.theme_engine']
  content_uninstall_validator:
    class: Drupal\Core\Entity\ContentUninstallValidator
    tags:
@@ -1517,7 +1520,7 @@ services:
    arguments: ['%app.root%', '@theme_handler', '@cache.bootstrap', '@module_handler']
  theme.registry:
    class: Drupal\Core\Theme\Registry
    arguments: ['%app.root%', '@cache.default', '@lock', '@module_handler', '@theme_handler', '@theme.initialization', null, '@cache.bootstrap']
    arguments: ['%app.root%', '@cache.default', '@lock', '@module_handler', '@theme_handler', '@theme.initialization', null, '@cache.bootstrap', '@extension.list.module']
    tags:
      - { name: needs_destruction }
    calls:
@@ -1618,7 +1621,7 @@ services:
      - { name: needs_destruction }
  library.discovery.parser:
    class: Drupal\Core\Asset\LibraryDiscoveryParser
    arguments: ['%app.root%', '@module_handler', '@theme.manager', '@stream_wrapper_manager', '@library.libraries_directory_file_finder']
    arguments: ['%app.root%', '@module_handler', '@theme.manager', '@stream_wrapper_manager', '@library.libraries_directory_file_finder', '@extension.path.resolver']
  library.libraries_directory_file_finder:
    class: Drupal\Core\Asset\LibrariesDirectoryFileFinder
    arguments: ['%app.root%', '%site.path%', '@extension.list.profile', '%install_profile%']
+16 −2
Original line number Diff line number Diff line
@@ -160,12 +160,19 @@ class_alias('Drupal\Core\Http\KernelEvent', 'Symfony\Component\HttpKernel\Event\
 *
 * @return string
 *   The filename of the requested item or NULL if the item is not found.
 *
 * @deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use
 *   \Drupal\Core\Extension\ExtensionPathResolver::getPathname() instead.
 *
 * @see https://www.drupal.org/node/2940438
 */
function drupal_get_filename($type, $name, $filename = NULL) {
  @trigger_error('drupal_get_filename() is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use \Drupal\Core\Extension\ExtensionPathResolver::getPathname() instead. See https://www.drupal.org/node/2940438', E_USER_DEPRECATED);
  // Type 'core' only exists to simplify application-level logic; it always maps
  // to the /core directory, whereas $name is ignored. It is only requested via
  // drupal_get_path(). /core/core.info.yml does not exist, but is required
  // since drupal_get_path() returns the dirname() of the returned pathname.
  // \Drupal\Core\Extension\ExtensionList::getPath(). The file
  // /core/core.info.yml does not exist, but is required since
  // ExtensionList::getPath() returns the dirname() of the returned pathname.
  if ($type === 'core') {
    return 'core/core.info.yml';
  }
@@ -209,8 +216,15 @@ function drupal_get_filename($type, $name, $filename = NULL) {
 *
 * @return string
 *   The path to the requested item or an empty string if the item is not found.
 *
 * @deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use
 *   \Drupal\Core\Extension\ExtensionPathResolver::getPath() instead.
 *
 * @see https://www.drupal.org/node/2940438
 * @see \Drupal\Core\Extension\ExtensionList::getPath()
 */
function drupal_get_path($type, $name) {
  @trigger_error('drupal_get_path() is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use \Drupal\Core\Extension\ExtensionPathResolver::getPath() instead. See https://www.drupal.org/node/2940438', E_USER_DEPRECATED);
  return dirname(drupal_get_filename($type, $name));
}

+1 −1
Original line number Diff line number Diff line
@@ -720,7 +720,7 @@ function template_preprocess_form_element_label(&$variables) {
 *   - file: Path to the file containing the definitions of the 'operations' and
 *     'finished' functions, for instance if they don't reside in the main
 *     .module file. The path should be relative to base_path(), and thus should
 *     be built using drupal_get_path().
 *     be built using ModuleExtensionList::getPath().
 *   - library: An array of batch-specific CSS and JS libraries.
 *   - url_options: options passed to the \Drupal\Core\Url object when
 *     constructing redirect URLs for the batch.
+15 −11
Original line number Diff line number Diff line
@@ -445,12 +445,17 @@ function install_begin_request($class_loader, &$install_state) {
  $listing->setProfileDirectories([]);
  $install_state['profiles'] += $listing->scan('profile');

  // Prime drupal_get_filename()'s static cache.
  /** @var \Drupal\Core\Extension\ModuleExtensionList $module_list */
  $module_list = \Drupal::service('extension.list.module');
  /** @var \Drupal\Core\Extension\ProfileExtensionList $profile_list */
  $profile_list = \Drupal::service('extension.list.profile');

  // Prime \Drupal\Core\Extension\ExtensionList::getPathname()'s static cache.
  foreach ($install_state['profiles'] as $name => $profile) {
    drupal_get_filename('profile', $name, $profile->getPathname());
    // drupal_get_filename() is called both with 'module' and 'profile', see
    // Profile path is set in both module and profile lists. See
    // \Drupal\Core\Config\ConfigInstaller::getProfileStorages for example.
    drupal_get_filename('module', $name, $profile->getPathname());
    $profile_list->setPathname($name, $profile->getPathname());
    $module_list->setPathname($name, $profile->getPathname());
  }

  if ($profile = _install_select_profile($install_state)) {
@@ -462,10 +467,10 @@ function install_begin_request($class_loader, &$install_state) {
  }

  // Before having installed the system module and being able to do a module
  // rebuild, prime the drupal_get_filename() static cache with the system
  // module's location.
  // rebuild, prime the module list static cache with the system module's
  // location.
  // @todo Remove as part of https://www.drupal.org/node/2186491
  drupal_get_filename('module', 'system', 'core/modules/system/system.info.yml');
  $module_list->setPathname('system', 'core/modules/system/system.info.yml');

  // Use the language from profile configuration if available.
  if (!empty($install_state['config_install_path']) && $install_state['config']['system.site']) {
@@ -1099,10 +1104,9 @@ function install_base_system(&$install_state) {
  // system.module in order to work.
  \Drupal::service('file.htaccess_writer')->ensure();

  // Prime the drupal_get_filename() static cache with the user module's
  // exact location.
  // Prime the module list static cache with the user module's exact location.
  // @todo Remove as part of https://www.drupal.org/node/2186491
  drupal_get_filename('module', 'user', 'core/modules/user/user.info.yml');
  \Drupal::service('extension.list.module')->setPathname('user', 'core/modules/user/user.info.yml');

  // Install the User module so that installing from configuration works and to
  // ensure the anonymous user is created with a langcode of 'en'.
@@ -1743,7 +1747,7 @@ function install_import_translations(&$install_state) {
      'progress_message' => '',
      'error_message' => t('Error importing translation files'),
      'finished' => 'locale_translation_batch_fetch_finished',
      'file' => drupal_get_path('module', 'locale') . '/locale.batch.inc',
      'file' => \Drupal::service('extension.list.module')->getPath('locale') . '/locale.batch.inc',
    ];
    return $batch;
  }
+1 −1
Original line number Diff line number Diff line
@@ -1114,7 +1114,7 @@ function install_profile_info($profile, $langcode = 'en') {
      'php' => \Drupal::MINIMUM_PHP,
      'config_install_path' => NULL,
    ];
    $profile_path = drupal_get_path('profile', $profile);
    $profile_path = \Drupal::service('extension.list.profile')->getPath($profile);
    $info = \Drupal::service('info_parser')->parse("$profile_path/$profile.info.yml");
    $info += $defaults;

Loading