BlockEventVariables.php in Hook Event Dispatcher 3.x
File
modules/preprocess_event_dispatcher/src/Variables/BlockEventVariables.php
View source
<?php
namespace Drupal\preprocess_event_dispatcher\Variables;
use Drupal\block\BlockInterface;
use Drupal\block_content\BlockContentInterface;
class BlockEventVariables extends AbstractEventVariables {
public function getBlock() : BlockInterface {
return $this->variables['block'];
}
public function getId() : string {
return $this->variables['elements']['#id'];
}
public function getContentChild(string $childName) : array {
return $this->variables['content'][$childName] ?? [];
}
public function getBlockContent() : ?BlockContentInterface {
return $this->variables['content']['#block_content'] ?? NULL;
}
}