class WithArgs in DraggableViews 2.0.x
Same name and namespace in other branches
- 8 src/Plugin/views/join/WithArgs.php \Drupal\draggableviews\Plugin\views\join\WithArgs
Defines a join handler with arguments.
Plugin annotation
@ViewsJoin("draggableviews_with_args");
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\draggableviews\Plugin\views\join\WithArgs
- class \Drupal\views\Plugin\views\join\JoinPluginBase implements JoinPluginInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
Expanded class hierarchy of WithArgs
File
- src/
Plugin/ views/ join/ WithArgs.php, line 16
Namespace
Drupal\draggableviews\Plugin\views\joinView source
class WithArgs extends JoinPluginBase {
/**
* {@inheritdoc}
*/
public function buildJoin($select_query, $table, $view_query) {
/** @var ViewExecutable $view */
$view = $view_query->view;
$view_args = !empty($view_query->view->args) ? $view_query->view->args : [];
$context = [
'select_query' => &$select_query,
'table' => &$table,
'view_query' => &$view_query,
];
\Drupal::moduleHandler()
->alter('draggableviews_join_withargs', $view_args, $context);
$view_args = json_encode($view_args);
if (!isset($this->extra)) {
$this->extra = [];
}
//exclude args if arguments aren't passed
$includeArgs = true;
$sort = $view->sort ?? [];
foreach ($sort as $sortClass) {
if ($sortClass instanceof DraggableViewsSort) {
$pass = $sortClass->options['draggable_views_pass_arguments'] ?? 0;
if (empty($pass) || $pass === '0') {
$includeArgs = false;
}
}
}
if (is_array($this->extra)) {
$found = FALSE;
foreach ($this->extra as $info) {
if (empty(array_diff(array_keys($info), [
'field',
'value',
])) && $info['field'] == 'args' && $info['value'] == $view_args) {
$found = TRUE;
break;
}
}
if (!$found && $includeArgs) {
$this->extra[] = [
'field' => 'args',
'value' => $view_args,
];
}
}
parent::buildJoin($select_query, $table, $view_query);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DependencySerializationTrait:: |
protected | property | ||
DependencySerializationTrait:: |
protected | property | ||
DependencySerializationTrait:: |
public | function | 2 | |
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 |
JoinPluginBase:: |
public | function |
Constructs a Drupal\views\Plugin\views\join\JoinPluginBase object. Overrides PluginBase:: |
1 |
MessengerTrait:: |
protected | property | The messenger. | 27 |
MessengerTrait:: |
public | function | Gets the messenger. | 27 |
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:: |
2 |
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. | 4 |
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. | |
WithArgs:: |
public | function |
Builds the SQL for the join this object represents. Overrides JoinPluginBase:: |