public function CollapseText::processRecurseTree in Collapse Text 8
Same name and namespace in other branches
- 2.0.x src/Plugin/Filter/CollapseText.php \Drupal\collapse_text\Plugin\Filter\CollapseText::processRecurseTree()
Helper function to take a nested tree and turn it into a string.
This function is recursive.
2 calls to CollapseText::processRecurseTree()
- CollapseText::process in src/
Plugin/ Filter/ CollapseText.php - Performs the filter processing.
- CollapseText::processChildItem in src/
Plugin/ Filter/ CollapseText.php - Helper function to process a child item.
File
- src/
Plugin/ Filter/ CollapseText.php, line 195
Class
- CollapseText
- Provides a filter to display Collapsible text blocks.
Namespace
Drupal\collapse_text\Plugin\FilterCode
public function processRecurseTree($tree, $options) {
$parts = [];
// We use $weight to make sure elements are displayed in the correct order.
$weight = 0;
foreach ($tree as $item) {
// Iterate over the tree.
$part = NULL;
if ($item['type'] == 'text') {
$part = $this
->processTextItem($item['value'], $options);
}
elseif ($item['type'] = 'child') {
$part = $this
->processChildItem($item, $options);
}
if (isset($part)) {
$part['#weight'] = $weight++;
$parts[] = $part;
}
}
return $parts;
}