You are here

public static function ContentTypeGroup::fetch in Content type groups 7.2

Same name and namespace in other branches
  1. 7 content_type_groups.module \ContentTypeGroup::fetch()

Returns a list of all content type groups.

Return value

array $machine_name => ContentTypeGroup($machine_name)

2 calls to ContentTypeGroup::fetch()
content_type_groups_features_export_options in ./content_type_groups.features.inc
Implementation of hook_features_export_options().
content_type_groups_handler_filter_group::get_value_options in ./content_type_groups_handler_filter_group.inc
Child classes should be used to override this function and set the 'value options', unless 'options callback' is defined as a valid function or static public method to generate these values.

File

./content_type_groups.class.inc, line 239

Class

ContentTypeGroup
Utility class to handle content type groups

Code

public static function fetch($fetch_as_objects = FALSE) {
  if ($fetch_as_objects) {
    $result = db_select(self::$table_groups, 'g')
      ->fields('g', array(
      'type',
    ))
      ->execute();
    $data = array();
    foreach ($result as $row) {
      $data[$row->type] = new ContentTypeGroup($row->type);
    }
  }
  else {

    // We only need to do $machine_name => $display_name
    $result = db_select(self::$table_groups, 'g')
      ->fields('g', array(
      'type',
      'name',
    ))
      ->execute();
    $data = array();
    foreach ($result as $row) {
      $data[$row->type] = $row->name;
    }
  }
  return $data;
}