You are here

public function SiteInfoBlock::build in Express 8

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

modules/custom/express_site_info/src/Plugin/Block/SiteInfoBlock.php, line 26

Class

SiteInfoBlock
Provides the Express Site Info Block.

Namespace

Drupal\express_site_info\Plugin\Block

Code

public function build() {
  global $base_url;
  $config = $this
    ->getConfiguration();
  $contact_info = Xss::filterAdmin($config['contact_info']);
  $config_site_name = \Drupal::config('system.site');
  $site_name = $config_site_name
    ->get('name');
  $link = Link::fromTextAndUrl(t($site_name), Url::fromUri($base_url, array()))
    ->toString();
  return array(
    '#markup' => $contact_info,
    '#attached' => array(
      'library' => array(
        'express_site_info/express_site_info_styles',
      ),
    ),
    '#title' => $link,
  );
}