function _openlayers_behaviors_process in Openlayers 6
Process Behaviors
Get full data for any behaviors and add handlers
Parameters
$behaviors: Array of behaviors to process
$map: Map array
Return value
Array of processed behaviors
1 call to _openlayers_behaviors_process()
- openlayers_render_map in ./
openlayers.module - Render Map
File
- includes/
openlayers.render.inc, line 95 - This file holds the functions the extra processing of rendering a map
Code
function _openlayers_behaviors_process($behaviors = array(), &$map = array()) {
// Check input
if (!is_array($behaviors)) {
$behaviors = array();
}
if (!is_array($map)) {
$map = array();
}
// Initialized variables
$processed = array();
// Get behavior info array
$behavior_info = openlayers_behaviors_get_info();
// Go through behaviors
foreach ($behaviors as $k => $behavior) {
// Check if array, if array, just pass on
if (is_array($behaviors)) {
$processed[$behavior['id']] = $behavior;
}
else {
$processed[$behavior] = array(
'id' => $behavior,
'type' => $behavior,
);
}
}
// Go through processed
foreach ($processed as $bkey => $behavior) {
$info = $behavior_info[$behavior['type']];
if (is_file($info['file'])) {
require_once $info['file'];
// Check for function
if (function_exists($info['callback'])) {
// Call function and give it the behavior array
$result = $info['callback']($behavior, $map);
// Check for result
if (isset($result) && is_array($result)) {
$result['js_callback'] = $info['js_callback'];
$processed[$bkey] = $result;
}
else {
unset($processed[$bkey]);
}
}
// Include JavaScript
if ($info['js_file']) {
drupal_add_js($info['js_file'], 'module');
}
}
}
// Return processed
return $processed;
}