public static function TBMegaMenuController::tbMegamenuAttachNumberColumns in The Better Mega Menu 8
Same name and namespace in other branches
- 2.x src/Controller/TBMegaMenuController.php \Drupal\tb_megamenu\Controller\TBMegaMenuController::tbMegamenuAttachNumberColumns()
Attach the number of columns into JS.
Throws
\Exception
File
- src/
Controller/ TBMegaMenuController.php, line 18
Class
- TBMegaMenuController
- Handler for attaching columns to MegaMenu render arrays.
Namespace
Drupal\tb_megamenu\ControllerCode
public static function tbMegamenuAttachNumberColumns($childrens, $elements) {
$number_columns =& drupal_static('column');
$render_array = [];
$render_array['#attached']['drupalSettings']['TBMegaMenu'] = [
'TBElementsCounter' => [
'column' => $number_columns,
],
];
// Can't use DI here since it's invoked by the static method below.
\Drupal::service('renderer')
->render($render_array);
return $childrens;
}