public function CustomBlockBlock::build

Builds and returns the renderable array for this block plugin.

Return value

array A renderable array representing the content of the block.

Overrides BlockPluginInterface::build

See also

\Drupal\block\BlockRenderController

File

drupal/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Block/CustomBlockBlock.php, line 72
Contains \Drupal\custom_block\Plugin\Block\CustomBlockBlock.

Class

CustomBlockBlock
Defines a generic custom block type.

Namespace

Drupal\custom_block\Plugin\Block

Code

public function build() {

  // @todo Clean up when http://drupal.org/node/1874498 lands.
  list(, $uuid) = explode(':', $this
    ->getPluginId());
  if ($block = entity_load_by_uuid('custom_block', $uuid)) {
    return entity_view($block, $this->configuration['view_mode']);
  }
  else {
    return array(
      '#markup' => t('Block with uuid %uuid does not exist. <a href="!url">Add custom block</a>.', array(
        '%uuid' => $uuid,
        '!url' => url('block/add'),
      )),
      '#access' => user_access('administer blocks'),
    );
  }
}