private function CategorizedOptionsbuttonsWidget::getTaxonomyChildren in Open Social 8.9
Same name and namespace in other branches
- 8.3 modules/social_features/social_profile/src/Plugin/Field/FieldWidget/CategorizedOptionsbuttonsWidget.php \Drupal\social_profile\Plugin\Field\FieldWidget\CategorizedOptionsbuttonsWidget::getTaxonomyChildren()
- 8.4 modules/social_features/social_profile/src/Plugin/Field/FieldWidget/CategorizedOptionsbuttonsWidget.php \Drupal\social_profile\Plugin\Field\FieldWidget\CategorizedOptionsbuttonsWidget::getTaxonomyChildren()
- 8.5 modules/social_features/social_profile/src/Plugin/Field/FieldWidget/CategorizedOptionsbuttonsWidget.php \Drupal\social_profile\Plugin\Field\FieldWidget\CategorizedOptionsbuttonsWidget::getTaxonomyChildren()
- 8.6 modules/social_features/social_profile/src/Plugin/Field/FieldWidget/CategorizedOptionsbuttonsWidget.php \Drupal\social_profile\Plugin\Field\FieldWidget\CategorizedOptionsbuttonsWidget::getTaxonomyChildren()
- 8.7 modules/social_features/social_profile/src/Plugin/Field/FieldWidget/CategorizedOptionsbuttonsWidget.php \Drupal\social_profile\Plugin\Field\FieldWidget\CategorizedOptionsbuttonsWidget::getTaxonomyChildren()
- 8.8 modules/social_features/social_profile/src/Plugin/Field/FieldWidget/CategorizedOptionsbuttonsWidget.php \Drupal\social_profile\Plugin\Field\FieldWidget\CategorizedOptionsbuttonsWidget::getTaxonomyChildren()
- 10.3.x modules/social_features/social_profile/src/Plugin/Field/FieldWidget/CategorizedOptionsbuttonsWidget.php \Drupal\social_profile\Plugin\Field\FieldWidget\CategorizedOptionsbuttonsWidget::getTaxonomyChildren()
- 10.0.x modules/social_features/social_profile/src/Plugin/Field/FieldWidget/CategorizedOptionsbuttonsWidget.php \Drupal\social_profile\Plugin\Field\FieldWidget\CategorizedOptionsbuttonsWidget::getTaxonomyChildren()
- 10.1.x modules/social_features/social_profile/src/Plugin/Field/FieldWidget/CategorizedOptionsbuttonsWidget.php \Drupal\social_profile\Plugin\Field\FieldWidget\CategorizedOptionsbuttonsWidget::getTaxonomyChildren()
- 10.2.x modules/social_features/social_profile/src/Plugin/Field/FieldWidget/CategorizedOptionsbuttonsWidget.php \Drupal\social_profile\Plugin\Field\FieldWidget\CategorizedOptionsbuttonsWidget::getTaxonomyChildren()
Reaches into all children and flattens the taxonomy.
This method is private for a reason. We don't handle extra nesting yet but could want to do this in the future. Do not rely on this method existing in the future.
Parameters
array $parent: The parent whose children to recurse through.
int $hyphens: The number of hyphens to use as a label prefix.
Return value
array[] A flattened array of children.
1 call to CategorizedOptionsbuttonsWidget::getTaxonomyChildren()
- CategorizedOptionsbuttonsWidget::formElement in modules/
social_features/ social_profile/ src/ Plugin/ Field/ FieldWidget/ CategorizedOptionsbuttonsWidget.php - Returns the form for a single field widget.
File
- modules/
social_features/ social_profile/ src/ Plugin/ Field/ FieldWidget/ CategorizedOptionsbuttonsWidget.php, line 185
Class
- CategorizedOptionsbuttonsWidget
- Plugin implementation of the 'categorized_options_buttons' widget.
Namespace
Drupal\social_profile\Plugin\Field\FieldWidgetCode
private function getTaxonomyChildren(array $parent, $hyphens = 0) {
$children = [];
$selected = [];
foreach ($parent['children'] as $tid => $child) {
$children[$tid] = str_repeat('-', $hyphens) . $child['label'];
if ($child['selected']) {
$selected[] = $tid;
}
if (!empty($child['children'])) {
$result = $this
->getTaxonomyChildren($child, $hyphens + 1);
$children += $result['children'];
$selected += $result['selected'];
}
}
return [
'children' => $children,
'selected' => $selected,
];
}