You are here

function eck_entity_type_features_export_render in Entity Construction Kit (ECK) 7

Same name and namespace in other branches
  1. 7.3 eck.features.inc \eck_entity_type_features_export_render()
  2. 7.2 eck.features.inc \eck_entity_type_features_export_render()

Implementation of hook_features_export_render().

File

./eck.features.inc, line 43

Code

function eck_entity_type_features_export_render($module, $data, $export = NULL) {
  module_load_include('inc', 'eck', 'eck.entity_type');
  $elements = array(
    'name' => FALSE,
    'label' => TRUE,
    'properties' => FALSE,
    'custom_properties' => FALSE,
  );
  $output = array();
  $output[] = '  $items = array(';
  foreach ($data as $entity_type_name) {

    // Get the entity definition.
    $entity_type = eck__entity_type__load($entity_type_name);
    $output[] = "    '{$entity_type->name}' => array(";
    foreach ($elements as $key => $t) {
      if ($t) {
        $text = str_replace("'", "\\'", $entity_type->{$key});
        $text = !empty($text) ? "t('{$text}')" : "''";
        $output[] = "      '{$key}' => {$text},";
      }
      else {
        if (is_array($entity_type->{$key})) {
          $output[] = "      '{$key}' => '" . serialize($entity_type->{$key}) . "',";
        }
        else {
          $output[] = "      '{$key}' => '{$entity_type->{$key}}',";
        }
      }
    }
    $output[] = "    ),";
  }
  $output[] = '  );';
  $output[] = '  return $items;';
  return array(
    'eck_entity_type_info' => implode("\n", $output),
  );
}