You are here

TestBlock.php in Page Manager 8.4

Same filename and directory in other branches
  1. 8 tests/modules/page_manager_test/src/Plugin/Block/TestBlock.php

File

tests/modules/page_manager_test/src/Plugin/Block/TestBlock.php
View source
<?php

namespace Drupal\page_manager_test\Plugin\Block;

use Drupal\Core\Block\BlockBase;
use Drupal\Core\Form\FormStateInterface;

/**
 * Provides a block to test page_manager.
 *
 * @Block(
 *   id = "page_manager_test_block",
 *   admin_label = @Translation("Page Manager Test Block")
 * )
 */
class TestBlock extends BlockBase {

  /**
   * {@inheritdoc}
   */
  public function build() {
    $build['#markup'] = $this
      ->t('Example output');
    return $build;
  }

  /**
   * {@inheritdoc}
   */
  public function blockForm($form, FormStateInterface $form_state) {
    $form['example'] = [
      '#type' => 'textfield',
      '#title' => $this
        ->t('Example'),
      '#ajax' => [
        'callback' => [
          $this,
          'exampleAjaxCallback',
        ],
      ],
    ];
    return $form;
  }

  /**
   * Example ajax callback.
   */
  public function exampleAjaxCallback($form, FormStateInterface $form_state) {
  }

}

Classes

Namesort descending Description
TestBlock Provides a block to test page_manager.