recentpopularlog in

therobyouknow : force   8

8 - How can we get Block Bundle Type for block in code? - Drupal Answers
use \Drupal\block_content\BlockContentInterface;


/**
* Implements HOOK_preprocess_block().
*
* @param $variables
*/
function mymodule_preprocess_block(&$variables) {
$content = $variables['elements']['content'];
if (isset($content['#block_content']) && $content['#block_content'] instanceof BlockContentInterface) {

if ($content['#block_content']->bundle() == 'xxx') {
// ...
}

}
}
8  drupal8  drupal  web  dev  cms  computing  module  theme  block  update  refresh  force  cache  disable  twig  specific  howto  question  answer  problem  solution  time  computed  generated  calculated 
march 2019 by therobyouknow

Copy this bookmark:





to read