TestAttributesBlock.php

Same filename in other branches
  1. 9 core/modules/layout_builder/tests/modules/layout_builder_test/src/Plugin/Block/TestAttributesBlock.php
  2. 11.x core/modules/layout_builder/tests/modules/layout_builder_test/src/Plugin/Block/TestAttributesBlock.php

Namespace

Drupal\layout_builder_test\Plugin\Block

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\Attribute\Block;
use Drupal\Core\Block\BlockBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\StringTranslation\TranslatableMarkup;

/**
 * Provides a 'TestAttributes' block.
 */
class TestAttributesBlock extends BlockBase {
    
    /**
     * {@inheritdoc}
     */
    public function blockForm($form, FormStateInterface $form_state) {
        return $form;
    }
    
    /**
     * {@inheritdoc}
     */
    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;
    }

}

Classes

Title Deprecated Summary
TestAttributesBlock Provides a 'TestAttributes' block.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.