Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. PluginBase.php

function PluginBase::queryLanguageSubstitutions

Returns substitutions for Views queries for languages.

This is needed so that the language options returned by PluginBase::listLanguages() are able to be used in queries. It is called by the Views module implementation of hook_views_query_substitutions() to get the language-related substitutions.

Return value

array An array in the format of hook_views_query_substitutions() that gives the query substitutions needed for the special language types.

1 call to PluginBase::queryLanguageSubstitutions()
ViewsViewsExecutionHooks::viewsQuerySubstitutions in core/modules/views/src/Hook/ViewsViewsExecutionHooks.php
Implements hook_views_query_substitutions().

File

core/modules/views/src/Plugin/views/PluginBase.php, line 638

Class

PluginBase
Base class for any views plugin types.

Namespace

Drupal\views\Plugin\views

Code

public static function queryLanguageSubstitutions() {
    $changes = [];
    $manager = \Drupal::languageManager();
    // Handle default language.
    $default = $manager->getDefaultLanguage()
        ->getId();
    $changes[PluginBase::VIEWS_QUERY_LANGUAGE_SITE_DEFAULT] = $default;
    // Handle negotiated languages.
    $types = $manager->getDefinedLanguageTypesInfo();
    foreach ($types as $id => $type) {
        if (isset($type['name'])) {
            $changes['***LANGUAGE_' . $id . '***'] = $manager->getCurrentLanguage($id)
                ->getId();
        }
    }
    return $changes;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal