Что эквивалентно Drupal.settings.базовый путь?


Я пытаюсь получить URL-адрес сайта в JavaScript. В Drupal 7 это хранится в Drupal.settings.basePath. Какой эквивалент Drupal 8?

Author: kiamlaluno, 2016-05-25

2 answers

В Drupal 8 этот параметр равен:

drupalSettings.path.baseUrl

Вы найдете больше в core/module/system/system.module:

function system_js_settings_alter(&$settings, AttachedAssetsInterface $assets) {
  ...
    $path_settings = [
    'baseUrl' => $request->getBaseUrl() . '/',
    'pathPrefix' => $pathPrefix,
    'currentPath' => $current_path,
    'currentPathIsAdmin' => $current_path_is_admin,
    'isFront' => \Drupal::service('path.matcher')->isFrontPage(),
    'currentLanguage' => \Drupal::languageManager()->getCurrentLanguage(LanguageInterface::TYPE_URL)->getId(),
  ];

  ...
 15
Author: 4k4, 2016-05-25 16:55:54

Используйте Drupal.url()

Ссылка: docroot/core/misc/drupal.js

 2
Author: nikunj, 2017-07-17 07:27:58