LanguageFilter.php in Drupal 10
File
core/modules/views/src/Plugin/views/filter/LanguageFilter.php
View source
<?php
namespace Drupal\views\Plugin\views\filter;
use Drupal\Core\Language\LanguageInterface;
use Drupal\Core\Language\LanguageManagerInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\views\Plugin\views\PluginBase;
use Symfony\Component\DependencyInjection\ContainerInterface;
class LanguageFilter extends InOperator implements ContainerFactoryPluginInterface {
protected $languageManager;
public function __construct($configuration, $plugin_id, $plugin_definition, LanguageManagerInterface $language_manager) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->languageManager = $language_manager;
}
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container
->get('language_manager'));
}
public function getValueOptions() {
if (!isset($this->valueOptions)) {
$this->valueTitle = $this
->t('Language');
$this->valueOptions = $this
->listLanguages(LanguageInterface::STATE_ALL | LanguageInterface::STATE_SITE_DEFAULT | PluginBase::INCLUDE_NEGOTIATED, array_keys($this->value));
}
return $this->valueOptions;
}
public function query() {
if (!$this->languageManager
->isMultilingual()) {
return;
}
parent::query();
}
}