function paragraphs_bundle_load in Paragraphs 7
Load a specific bundle or a list of bundles.
Parameters
string|null $name: The machine name or list of bundles to load when null.
bool $rebuild: Whether to use cache or not.
Return value
array|object|bool The bundle, a list of bundles, or FALSE when not found.
13 calls to paragraphs_bundle_load()
- paragraphs_admin_bundle_overview in ./
paragraphs.admin.inc - Page callback to show the bundle overview page.
- paragraphs_bundle_delete in ./
paragraphs.module - Function to delete a bundle.
- paragraphs_bundle_permissions_permission in modules/
paragraphs_bundle_permissions/ paragraphs_bundle_permissions.module - Implements hook_permission().
- paragraphs_bundle_save in ./
paragraphs.module - Function to create or update an paragraphs bundle.
- paragraphs_entity_info in ./
paragraphs.module - Implements hook_entity_info().
2 string references to 'paragraphs_bundle_load'
- paragraphs_admin_bundle_form in ./
paragraphs.admin.inc - Form to create or edit an paragraphs bundle.
- paragraphs_bundle_copy_info in ./
paragraphs.module - Implements hook_bundle_copy_info().
File
- ./
paragraphs.module, line 925 - Paragraphs hooks and common functions.
Code
function paragraphs_bundle_load($name = NULL, $rebuild = FALSE) {
$cid = 'paragraphs_bundles';
$bundles = array();
// Load bundles from static or from Drupal cache.
$_bundles =& drupal_static($cid);
if (isset($_bundles) && !$rebuild) {
$bundles = $_bundles;
}
else {
$_bundles = cache_get($cid);
if ($_bundles && !$rebuild) {
$bundles = $_bundles->data;
}
else {
$query = db_select('paragraphs_bundle', 'pb')
->fields('pb')
->orderBy('pb.bundle', 'ASC');
foreach ($query
->execute() as $bundle_object) {
$bundles[$bundle_object->bundle] = $bundle_object;
}
cache_set($cid, $bundles);
}
$_bundles = $bundles;
}
if ($name) {
$name = strtr($name, array(
'-' => '_',
));
if (isset($bundles[$name])) {
return $bundles[$name];
}
return FALSE;
}
else {
return $bundles;
}
}