function _xbbcode_build_tags in Extensible BBCode 8.2
Same name and namespace in other branches
- 8 xbbcode.inc \_xbbcode_build_tags()
- 7 xbbcode.inc \_xbbcode_build_tags()
Invoke all handlers to get the tags for a certain format.
Parameters
$format_id: The name of the format for which tags should be built.
Return value
An array of tag objects, keyed by name.
1 call to _xbbcode_build_tags()
- XBBCodeFilter::__construct in src/
Plugin/ Filter/ XBBCodeFilter.php - Construct a filter object from a bundle of tags, and the format ID.
File
- ./
xbbcode.inc, line 43 - General library of internal functions only called by this module.
Code
function _xbbcode_build_tags($handlers) {
// First, check if the tags are in cache.
//if ($cache = Drupal::cache()->get("xbbcode_tags:$format_id")) {
// $tags = $cache->data;
//}
// Load the preferred handlers for this text format.
$providers = array();
foreach ($handlers as $name => $handler) {
// Build a list of what modules are used, and what to get from each.
if ($handler['enabled']) {
$providers[$handler['module']][$name] = $name;
}
}
$tags = [];
$default = [
'selfclosing' => FALSE,
];
foreach ($providers as $module => $provides) {
$info = Drupal::moduleHandler()
->invoke($module, 'xbbcode_info');
foreach ($provides as $tag) {
if (isset($info[$tag])) {
if (!isset($info[$tag]['options'])) {
$info[$tag]['options'] = [];
}
$tags[$tag] = (object) array(
'name' => $tag,
'description' => $info[$tag]['description'],
'sample' => $info[$tag]['sample'],
'options' => (object) ($info[$tag]['options'] + $default),
'markup' => isset($info[$tag]['markup']) ? $info[$tag]['markup'] : NULL,
'callback' => !isset($info[$tag]['markup']) ? $info[$tag]['callback'] : NULL,
);
}
}
}
//Drupal::cache()->set("xbbcode_tags:$format_id", $tags, Cache::Permanent, ['xbbcode_tags']);
return $tags;
}