TestAttributesBlock.php in Drupal 10
File
core/modules/layout_builder/tests/modules/layout_builder_test/src/Plugin/Block/TestAttributesBlock.php
View source
<?php
namespace Drupal\layout_builder_test\Plugin\Block;
use Drupal\Core\Block\BlockBase;
use Drupal\Core\Form\FormStateInterface;
class TestAttributesBlock extends BlockBase {
public function blockForm($form, FormStateInterface $form_state) {
return $form;
}
public function build() {
$build = [
'#attributes' => [
'class' => [
'attribute-test-class',
],
'custom-attribute' => 'test',
],
'#markup' => $this
->t('Example block providing its own attributes.'),
'#contextual_links' => [
'layout_builder_test' => [
'route_parameters' => [],
],
],
];
return $build;
}
}