TBMegaMenuController.php in The Better Mega Menu 2.x
File
src/Controller/TBMegaMenuController.php
View source
<?php
namespace Drupal\tb_megamenu\Controller;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Security\TrustedCallbackInterface;
class TBMegaMenuController extends ControllerBase implements TrustedCallbackInterface {
public static function tbMegamenuAttachNumberColumns($childrens, $elements) {
$number_columns =& drupal_static('column');
$render_array = [];
$render_array['#attached']['drupalSettings']['TBMegaMenu'] = [
'TBElementsCounter' => [
'column' => $number_columns,
],
];
\Drupal::service('renderer')
->render($render_array);
return $childrens;
}
public static function trustedCallbacks() {
return [
'tbMegamenuAttachNumberColumns',
];
}
}