You are here

ContextBlock.php in Core Context 8

File

tests/modules/core_context_test/src/Plugin/Block/ContextBlock.php
View source
<?php

namespace Drupal\core_context_test\Plugin\Block;

use Drupal\Core\Block\BlockBase;

/**
 * @Block(
 *   id = "context_block",
 *   admin_label = @Translation("Context block"),
 *   context_definitions = {
 *     "value" = @ContextDefinition("any"),
 *     "letter" = @ContextDefinition("string"),
 *   },
 * )
 */
class ContextBlock extends BlockBase {

  /**
   * {@inheritdoc}
   */
  public function build() {
    return [
      '#markup' => $this
        ->t('The context value is %value, brought to you by the letter %letter.', [
        '%value' => $this
          ->getContextValue('value'),
        '%letter' => $this
          ->getContextValue('letter'),
      ]),
    ];
  }

}

Classes

Namesort descending Description
ContextBlock Plugin annotation @Block( id = "context_block", admin_label = @Translation("Context block"), context_definitions = { "value" = @ContextDefinition("any"), "letter" = @ContextDefinition("string"), }, )