class ExampleEmptyBlock

Provides a 'Example: empty block' block.

Plugin annotation


@Block(
  id = "example_empty",
  admin_label = @Translation("Example: empty block")
)

Hierarchy

  • class \Drupal\block_example\Plugin\Block\ExampleEmptyBlock extends \Drupal\Core\Block\BlockBase

Expanded class hierarchy of ExampleEmptyBlock

File

modules/block_example/src/Plugin/Block/ExampleEmptyBlock.php, line 15

Namespace

Drupal\block_example\Plugin\Block
View source
class ExampleEmptyBlock extends BlockBase {
  
  /**
   * {@inheritdoc}
   *
   * The return value of the build() method is a renderable array. Returning an
   * empty array will result in empty block contents. The front end will not
   * display empty blocks.
   */
  public function build() {
    // We return an empty array on purpose. The block will thus not be rendered
    // on the site. See BlockExampleTest::testBlockExampleBasic().
    return [];
  }

}

Members

Title Sort descending Modifiers Object type Summary
ExampleEmptyBlock::build public function The return value of the build() method is a renderable array. Returning an
empty array will result in empty block contents. The front end will not
display empty blocks.