You are here

function views_natural_sort_get_supported_entity_properties in Views Natural Sort 7.2

Retrieve the full list of entities and properties that can be supported.

Return value

array An array of property information keyed by entity machine name. Example: array ( 'node' => array ( 'type' => array ( 'base_table' => 'node', 'schema_field' => 'type', ), 'title' => array ( 'base_table' => 'node', 'schema_field' => 'title', ), 'language' => array ( 'base_table' => 'node', 'schema_field' => 'language', ), ), 'user' => array ( 'name' => array ( 'base_table' => 'users', 'schema_field' => 'name', ), 'mail' => array ( 'base_table' => 'users', 'schema_field' => 'mail', ), 'theme' => array ( 'base_table' => 'users', 'schema_field' => 'theme', ), ), 'file' => array ( 'name' => array ( 'base_table' => 'file_managed', 'schema_field' => 'filename', ), 'mime' => array ( 'base_table' => 'file_managed', 'schema_field' => 'filemime', ), ), )

2 calls to views_natural_sort_get_supported_entity_properties()
views_natural_sort_get_views_configurable_properties in ./views_natural_sort.module
Returns a list of properties that we know views will allow us to alter.
views_natural_sort_views_data_alter in ./views_natural_sort.views.inc
Implements hook_views_data_alter().

File

./views_natural_sort.module, line 383
Views Natural Sort module.

Code

function views_natural_sort_get_supported_entity_properties() {
  $supported_properties =& drupal_static(__FUNCTION__, array());
  if (empty($supported_properties)) {
    $entity_property_info = entity_get_property_info();
    $entity_info = entity_get_info();
    foreach ($entity_property_info as $entity_type => $info) {
      if (empty($supported_properties[$entity_type])) {
        $supported_properties[$entity_type] = array();
      }
      $properties = array();
      if (!empty($info['properties']) && is_array($info['properties'])) {
        $properties = $info['properties'];
      }
      foreach ($properties as $property => $property_info) {
        $property_info += entity_property_info_defaults();
        if ($property_info['type'] != 'text' || empty($property_info['schema field'])) {
          continue;
        }
        $schema = drupal_get_schema($entity_info[$entity_type]['base table']);
        $schema_field = $property_info['schema field'];
        if (empty($schema['fields'][$schema_field]) || $schema['fields'][$schema_field]['type'] != 'varchar') {
          continue;
        }
        $supported_properties[$entity_type][$property] = array(
          'base_table' => $entity_info[$entity_type]['base table'],
          'schema_field' => $property_info['schema field'],
        );
      }
    }
  }
  return $supported_properties;
}