public function MediaDirectory::query in Media Directories 8
Same name and namespace in other branches
- 3.x src/Plugin/views/filter/MediaDirectory.php \Drupal\media_directories\Plugin\views\filter\MediaDirectory::query()
- 2.x src/Plugin/views/filter/MediaDirectory.php \Drupal\media_directories\Plugin\views\filter\MediaDirectory::query()
Add this filter to the query.
Due to the nature of fapi, the value and the operator have an unintended level of indirection. You will find them in $this->operator and $this->value respectively.
Overrides InOperator::query
File
- src/
Plugin/ views/ filter/ MediaDirectory.php, line 211
Class
- MediaDirectory
- Filter media by directory.
Namespace
Drupal\media_directories\Plugin\views\filterCode
public function query() {
$this
->ensureMyTable();
$config = $this->configFactory
->get('media_directories.settings');
// If the value is 'All', then we show only elements with empty value.
if ($this->validatedExposedInput[0] === 'All') {
$this->query
->addWhereExpression(0, "{$this->tableAlias}.{$this->realField} IS NULL");
if ($config
->get('all_files_in_root')) {
// Show everything.
$this->query
->setWhereGroup('OR', 0);
$this->query
->addWhereExpression(0, "{$this->tableAlias}.{$this->realField} IS NOT NULL");
}
}
else {
parent::query();
}
}