You are here

function paragraphs_features_export_render in Paragraphs 7

Implements hook_features_export_render().

File

./paragraphs.features.inc, line 47
Holds features implementation.

Code

function paragraphs_features_export_render($module, $data, $export = NULL) {
  $elements = array(
    'name' => FALSE,
    'bundle' => FALSE,
    'label' => FALSE,
    'description' => FALSE,
    'locked' => FALSE,
  );
  $output = array();
  $output[] = '  $items = array(';
  foreach ($data as $type) {
    if ($info = paragraphs_bundle_load($type)) {
      $output[] = "    '{$type}' => array(";
      foreach ($elements as $key => $t) {
        if ($t) {
          $text = str_replace("'", "\\'", $info->{$key});
          $text = !empty($text) ? "t('{$text}')" : "''";
          $output[] = "      '{$key}' => {$text},";
        }
        else {
          $output[] = "      '{$key}' => '{$info->{$key}}',";
        }
      }
      $output[] = "    ),";
    }
  }
  $output[] = '  );';
  $output[] = '  return $items;';
  $output = implode("\n", $output);
  return array(
    'paragraphs_info' => $output,
  );
}