You are here

function fe_nodequeue_queue_features_export_render in Features Extra 6

Implementation of hook_features_export_render().

File

./fe_nodequeue.module, line 84

Code

function fe_nodequeue_queue_features_export_render($module_name = '', $data) {
  ctools_include('export');
  $component = 'fe_nodequeue_queue';
  $schema = ctools_export_get_schema($component);
  $objects = ctools_export_load_object($component);
  $code = array();
  $code[] = '  $export = array();';
  $code[] = '';
  foreach ($data as $machine_name) {

    // The object to be exported.
    if ($object = $objects[$machine_name]) {
      $additions = array();

      // Load nodequeue_queue.
      if (!empty($object->qid)) {
        $nodequeue_queue = nodequeue_load($object->qid);

        // sort roles and types arrays into ascending order so that we can
        // check for overridden db data without being affected by the
        // order in which this array gets stored/loaded.
        if (!empty($nodequeue_queue->roles)) {
          sort($nodequeue_queue->roles);
        }
        if (!empty($nodequeue_queue->types)) {
          sort($nodequeue_queue->types);
        }
        $additions = (array) $nodequeue_queue;
        unset($additions['qid']);

        // TODO: sub
        unset($additions['subqueues']);
      }

      // Code.
      $identifier = $schema['export']['identifier'];
      $code[] = ctools_export_object($component, $object, '  ', $identifier, $additions);
      $code[] = '  $export[\'' . $machine_name . '\'] = $' . $identifier . ';';
      $code[] = '';
    }
  }
  $code[] = '  return $export;';
  $code = implode("\n", $code);
  return array(
    $schema['export']['default hook'] => $code,
  );
}