class TranslationLanguageJoin in Translation Views 8
Special join to show all translatable langcodes per one row.
Plugin annotation
@ViewsJoin("translation_views_language_join");
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
- class \Drupal\views\Plugin\views\join\JoinPluginBase implements JoinPluginInterface
- class \Drupal\translation_views\Plugin\views\join\TranslationLanguageJoin implements ContainerFactoryPluginInterface
- class \Drupal\views\Plugin\views\join\JoinPluginBase implements JoinPluginInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
Expanded class hierarchy of TranslationLanguageJoin
File
- src/
Plugin/ views/ join/ TranslationLanguageJoin.php, line 15
Namespace
Drupal\translation_views\Plugin\views\joinView source
class TranslationLanguageJoin extends JoinPluginBase implements ContainerFactoryPluginInterface {
/**
* Database connection.
*
* @var \Drupal\Core\Database\Connection
*/
protected $database;
protected $eid;
/**
* {@inheritdoc}
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, Connection $database) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->database = $database;
$this->eid = $this->configuration['entity_id'];
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container
->get('database'));
}
/**
* {@inheritdoc}
*/
public function buildJoin($select_query, $table, $view_query) {
$query = $this->database
->select($this->table, 'efd');
$query
->fields('efd', [
$this->eid,
]);
if (!empty($this->configuration['langcodes_as_count'])) {
$query
->addExpression("COUNT(efd.langcode)", 'count_langs');
if (isset($this->configuration['include_original_language']) && $this->configuration['include_original_language'] == FALSE) {
$query
->where('efd.default_langcode != 1');
}
}
else {
$query
->addExpression("GROUP_CONCAT(efd.langcode separator ',')", 'langs');
}
$query
->groupBy('efd.' . $this->eid);
$this->configuration['table formula'] = $query;
parent::buildJoin($select_query, $table, $view_query);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | 1 | |
DependencySerializationTrait:: |
public | function | 2 | |
JoinPluginBase:: |
public | property | Defines whether a join has been adjusted. | |
JoinPluginBase:: |
public | property |
The configuration array passed by initJoin. Overrides PluginBase:: |
|
JoinPluginBase:: |
public | property | An array of extra conditions on the join. | |
JoinPluginBase:: |
public | property | How all the extras will be combined. Either AND or OR. | |
JoinPluginBase:: |
public | property | The field to join on (right field). | |
JoinPluginBase:: |
public | property | The field we join to. | |
JoinPluginBase:: |
public | property | A formula to be used instead of the left field. | |
JoinPluginBase:: |
public | property | The table we join to. | |
JoinPluginBase:: |
public | property | The table to join (right table). | |
JoinPluginBase:: |
public | property | The join type, so for example LEFT (default) or INNER. | |
JoinPluginBase:: |
protected | function | Builds a single extra condition. | |
JoinPluginBase:: |
protected | function | Adds the extras to the join condition. | 1 |
MessengerTrait:: |
protected | property | The messenger. | 29 |
MessengerTrait:: |
public | function | Gets the messenger. | 29 |
MessengerTrait:: |
public | function | Sets the messenger. | |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
3 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. | |
TranslationLanguageJoin:: |
protected | property | Database connection. | |
TranslationLanguageJoin:: |
protected | property | ||
TranslationLanguageJoin:: |
public | function |
Builds the SQL for the join this object represents. Overrides JoinPluginBase:: |
|
TranslationLanguageJoin:: |
public static | function |
Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface:: |
|
TranslationLanguageJoin:: |
public | function |
Constructs a Drupal\views\Plugin\views\join\JoinPluginBase object. Overrides JoinPluginBase:: |