You are here

public function TestRichTextBlock::build in Lingotek Translation 4.0.x

Same name and namespace in other branches
  1. 3.3.x tests/modules/lingotek_test/src/Plugin/Block/TestRichTextBlock.php \Drupal\lingotek_test\Plugin\Block\TestRichTextBlock::build()
  2. 3.4.x tests/modules/lingotek_test/src/Plugin/Block/TestRichTextBlock.php \Drupal\lingotek_test\Plugin\Block\TestRichTextBlock::build()
  3. 3.5.x tests/modules/lingotek_test/src/Plugin/Block/TestRichTextBlock.php \Drupal\lingotek_test\Plugin\Block\TestRichTextBlock::build()
  4. 3.6.x tests/modules/lingotek_test/src/Plugin/Block/TestRichTextBlock.php \Drupal\lingotek_test\Plugin\Block\TestRichTextBlock::build()
  5. 3.7.x tests/modules/lingotek_test/src/Plugin/Block/TestRichTextBlock.php \Drupal\lingotek_test\Plugin\Block\TestRichTextBlock::build()
  6. 3.8.x tests/modules/lingotek_test/src/Plugin/Block/TestRichTextBlock.php \Drupal\lingotek_test\Plugin\Block\TestRichTextBlock::build()

Builds and returns the renderable array for this block plugin.

If a block should not be rendered because it has no content, then this method must also ensure to return no content: it must then only return an empty array, or an empty array with #cache set (with cacheability metadata indicating the circumstances for it being empty).

Return value

array A renderable array representing the content of the block.

Overrides BlockPluginInterface::build

See also

\Drupal\block\BlockViewBuilder

File

tests/modules/lingotek_test/src/Plugin/Block/TestRichTextBlock.php, line 45

Class

TestRichTextBlock
Provides a 'Lingotek Test Rich Text' block.

Namespace

Drupal\lingotek_test\Plugin\Block

Code

public function build() {
  $value = isset($this->configuration['rich_text']) && isset($this->configuration['rich_text']['value']) ? $this->configuration['rich_text']['value'] : '';
  $format = isset($this->configuration['rich_text']) && isset($this->configuration['rich_text']['format']) ? $this->configuration['rich_text']['format'] : 'plain_text';
  return [
    '#type' => 'processed_text',
    '#text' => $value,
    '#format' => $format,
  ];
}