You are here

function elysia_cron_ctools_to_hook_code in Elysia Cron 6

Same name and namespace in other branches
  1. 6.2 elysia_cron.ctools.inc \elysia_cron_ctools_to_hook_code()
  2. 7.2 elysia_cron.ctools.inc \elysia_cron_ctools_to_hook_code()
  3. 7 elysia_cron.ctools.inc \elysia_cron_ctools_to_hook_code()

Ctools export to hook code callback Original "to hook code" callback doesn't support the replacement of "load/load all" callback (it simply ignores them, even if defined and supported elsewhere) This code is equal to the original ctools one, but uses specific load callback

1 string reference to 'elysia_cron_ctools_to_hook_code'
elysia_cron_schema in ./elysia_cron.install

File

./elysia_cron.ctools.inc, line 174

Code

function elysia_cron_ctools_to_hook_code($names, $name) {
  $table = 'elysia_cron';
  $schema = ctools_export_get_schema($table);
  $export = $schema['export'];
  $output = '';
  $objects = elysia_cron_ctools_export_load_all();
  $objects = array_intersect_key($objects, array_flip($names));
  if ($objects) {
    $output = "/**\n";
    $output .= " * Implementation of hook_{$export['default hook']}()\n";
    $output .= " */\n";
    $output .= "function " . $name . "_{$export['default hook']}() {\n";
    $output .= "  \${$export['identifier']}s = array();\n\n";
    foreach ($objects as $object) {
      $output .= ctools_export_crud_export($table, $object, '  ');
      $output .= "  \${$export['identifier']}s['" . check_plain($object->{$export}['key']) . "'] = \${$export['identifier']};\n\n";
    }
    $output .= "  return \${$export['identifier']}s;\n";
    $output .= "}\n";
  }
  return $output;
}