Commit ad4ca4fa authored by generalredneck's avatar generalredneck

Adding Natural sorting for all text properties on all entities.

parent 34bc4232
......@@ -4,6 +4,16 @@
* Implements hook_views_data_alter().
*/
function views_natural_sort_views_data_alter(array &$data) {
$data['node_field_data']['title']['sort']['id'] = 'natural';
function views_natural_sort_views_data_alter(array &$views_data) {
$supported_entity_properties = \Drupal::service('views_natural_sort.service')->getSupportedEntityProperties();
foreach ($supported_entity_properties as $entity => $properties) {
foreach ($properties as $property => $schema_info) {
if (!empty($views_data[$schema_info['base_table']][$schema_info['schema_field']]) &&
!empty($views_data[$schema_info['base_table']][$schema_info['schema_field']]['sort']) &&
!empty($views_data[$schema_info['base_table']][$schema_info['schema_field']]['sort']['id'] == 'standard')) {
$views_data[$schema_info['base_table']][$schema_info['schema_field']]['sort']['id'] = 'natural';
}
$schema_fields[$schema_info['base_table']][] = $schema_info['schema_field'];
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment