function yamlform_query_alter in YAML Form 8
Implements hook_query_alter().
Append EAV sort to yamlform_submission entity query.
See also
http://stackoverflow.com/questions/12893314/sorting-eav-database
\Drupal\yamlform\YamlFormSubmissionListBuilder::getEntityIds
File
- ./
yamlform.module, line 617 - Enables the creation of forms and questionnaires.
Code
function yamlform_query_alter(AlterableInterface $query) {
/** @var \Drupal\Core\Database\Query\SelectInterface $query */
$name = $query
->getMetaData('yamlform_submission_element_name');
if (!$name) {
return;
}
$direction = $query
->getMetaData('yamlform_submission_element_direction');
$property_name = $query
->getMetaData('yamlform_submission_element_property_name');
$query
->distinct();
$query
->addJoin('INNER', 'yamlform_submission_data', NULL, 'base_table.sid = yamlform_submission_data.sid');
$query
->addField('yamlform_submission_data', 'value', 'value');
$query
->condition('name', $name);
if ($property_name) {
$query
->condition('property', $property_name);
}
$query
->orderBy('value', $direction);
}