function sweaver_object_load in Sweaver 6
Same name and namespace in other branches
- 7 sweaver.module \sweaver_object_load()
Load one object or all objects.
Parameters
$name: The machine name of the object.
$map: Can be an array passed on by the load arguments of the menu or a string. In case of array, object_type will be index 5.
$status: Whether to return all objects or only enabled.
Return value
One object or an array of objects.
9 calls to sweaver_object_load()
- sweaver_ctools_object_list in ./
sweaver.module - Helper function to return list for CTools.
- sweaver_drush_css_to_json in drush/
sweaver.drush.inc - Convert the stylesheet back to JSON format.
- sweaver_drush_json_to_css in drush/
sweaver.drush.inc - Convert the properties which are collected by the editor.
- sweaver_object_form_validate in plugins/
sweaver_plugin_editor/ sweaver_plugin_editor.admin.inc - Object new/edit validate callback.
- sweaver_plugin_editor::sweaver_form in plugins/
sweaver_plugin_editor/ sweaver_plugin_editor.inc - Frontend form.
File
- ./
sweaver.module, line 217 - Sweaver functions.
Code
function sweaver_object_load($name = NULL, $map = NULL, $status = 'enabled') {
static $run = FALSE;
static $objects = NULL;
$object_type = is_array($map) ? $map[5] : $map;
if (!$run) {
if ($objects_cache = cache_get('sweaver')) {
$objects = $objects_cache->data;
}
else {
ctools_include('export');
$objects = new stdClass();
foreach (array(
'sweaver_selector',
'sweaver_property',
'sweaver_type',
) as $object_to_load) {
$loaded_objects = ctools_export_load_object($object_to_load);
foreach ($loaded_objects as $key => $object) {
$object_type_key = str_replace('sweaver_', '', $object->table);
if (!isset($object->disabled) || isset($object->disabled) && $object->disabled == FALSE) {
$objects->{$object_type_key}->enabled[$key] = $object;
}
$objects->{$object_type_key}->all[$key] = $object;
}
}
// Let sweaver plugins alter objects.
$sweaver = Sweaver::get_instance();
foreach (array_keys($sweaver
->get_plugins_registry(TRUE)) as $plugin_name) {
$sweaver_plugin = $sweaver
->get_plugin($plugin_name);
$sweaver_plugin
->sweaver_objects_alter($objects);
}
cache_set('sweaver', $objects);
}
$run = TRUE;
}
if ($name) {
return isset($objects->{$object_type}->all[$name]) ? $objects->{$object_type}->all[$name] : FALSE;
}
else {
return isset($objects->{$object_type}->{$status}) ? $objects->{$object_type}->{$status} : array();
}
}