ExampleEmptyBlock.php

Same filename and directory in other branches
  1. 4.0.x modules/block_example/src/Plugin/Block/ExampleEmptyBlock.php

Namespace

Drupal\block_example\Plugin\Block

File

modules/block_example/src/Plugin/Block/ExampleEmptyBlock.php

View 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

Title Deprecated Summary
ExampleEmptyBlock Provides a 'Example: empty block' block.