ExampleEmptyBlock.php in Examples for Developers 3.x
Namespace
Drupal\block_example\Plugin\BlockFile
modules/block_example/src/Plugin/Block/ExampleEmptyBlock.phpView source
<?php
namespace Drupal\block_example\Plugin\Block;
use Drupal\Core\Block\BlockBase;
/**
* Provides a 'Example: empty block' block.
*
* @Block(
* id = "example_empty",
* admin_label = @Translation("Example: empty block")
* )
*/
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 [];
}
}
Classes
Name | Description |
---|---|
ExampleEmptyBlock | Provides a 'Example: empty block' block. |