function elysia_cron_ctools_to_hook_code in Elysia Cron 7.2
Same name and namespace in other branches
- 6.2 elysia_cron.ctools.inc \elysia_cron_ctools_to_hook_code()
- 6 elysia_cron.ctools.inc \elysia_cron_ctools_to_hook_code()
- 7 elysia_cron.ctools.inc \elysia_cron_ctools_to_hook_code()
Ctools export to hook code callback.
Original "to hook code" callback does not 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.
Parameters
array $names:
string $name:
Return value
string
1 string reference to 'elysia_cron_ctools_to_hook_code'
- elysia_cron_schema in ./
elysia_cron.install - Implements hook_schema().
File
- ./
elysia_cron.ctools.inc, line 247 - Ctools integration.
Code
function elysia_cron_ctools_to_hook_code(array $names, $name) {
$output = '';
$table = 'elysia_cron';
$schema = ctools_export_get_schema($table);
$export = $schema['export'];
$objects = elysia_cron_ctools_export_load_all();
$objects = array_intersect_key($objects, array_flip($names));
if ($objects) {
$output = '/**' . ELYSIA_CRON_CTOOLS_LINEBREAK;
$output .= " * Implementation of hook_{$export['default hook']}()" . ELYSIA_CRON_CTOOLS_LINEBREAK;
$output .= ' */' . ELYSIA_CRON_CTOOLS_LINEBREAK;
$output .= "function " . $name . "_{$export['default hook']}() {" . ELYSIA_CRON_CTOOLS_LINEBREAK;
$output .= " \${$export['identifier']}s = array();" . ELYSIA_CRON_CTOOLS_LINEBREAK . ELYSIA_CRON_CTOOLS_LINEBREAK;
foreach ($objects as $object) {
$output .= ctools_export_crud_export($table, $object, ' ');
$output .= " \${$export['identifier']}s['" . check_plain($object->{$export['key']}) . "'] = \${$export['identifier']};" . ELYSIA_CRON_CTOOLS_LINEBREAK . ELYSIA_CRON_CTOOLS_LINEBREAK;
}
$output .= " return \${$export['identifier']}s;" . ELYSIA_CRON_CTOOLS_LINEBREAK;
$output .= '}' . ELYSIA_CRON_CTOOLS_LINEBREAK;
}
return $output;
}