protected function EntityReferenceImportProcessor::applyFilters in YAML Content 8.2
Apply configured filters to the query object.
@todo Add support for `range()` operator instead of just `limit`. @todo Add support for `condition()` operators.
1 call to EntityReferenceImportProcessor::applyFilters()
- EntityReferenceImportProcessor::buildQuery in src/
Plugin/ YamlContent/ EntityReferenceImportProcessor.php - Build and prepare the the entity query with configured filters.
File
- src/
Plugin/ YamlContent/ EntityReferenceImportProcessor.php, line 95
Class
- EntityReferenceImportProcessor
- Import processor to support entity queries and references.
Namespace
Drupal\yaml_content\Plugin\YamlContentCode
protected function applyFilters() {
$context = $this
->getContextValues();
foreach ($context as $name => $value) {
// Only apply filters for populated values.
if (!is_null($value)) {
// Handle special cases.
switch ($name) {
// Entity type should be already applied at query creation and require
// nothing further.
case 'entity_type':
break;
// Specially handle a `bundle` or `type` key for convenience.
case 'bundle':
case 'type':
$this->query
->condition('type', $value);
break;
case 'limit':
// Assume starting at 0 to apply limit only.
$this->query
->range(0, $value);
break;
case 'conditions':
foreach ($value as $field => $filter) {
$op = is_array($filter) ? 'IN' : '=';
$this->query
->condition($field, $filter, $op);
}
}
}
}
}