You are here

public function TotalControlDashboard::build in Total Control Admin Dashboard 3.0.x

Same name and namespace in other branches
  1. 8.2 src/Plugin/Block/TotalControlDashboard.php \Drupal\total_control\Plugin\Block\TotalControlDashboard::build()

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

src/Plugin/Block/TotalControlDashboard.php, line 61

Class

TotalControlDashboard
Provides a 'Total Control Dashboard block'.

Namespace

Drupal\total_control\Plugin\Block

Code

public function build() {
  if ($this->moduleHandler
    ->moduleExists('page_manager_ui')) {
    $welcome_message_text = $this
      ->t('Welcome to your administrative dashboard.');
    $edit_this_panel_text = $this
      ->t('Edit this panel');
    $to_do_more_text = $this
      ->t('to add more blocks here, or configure those provided by default.');
    $markup_data = '<p>' . $welcome_message_text . '&nbsp;' . '<a href="/admin/structure/page_manager/manage/total_control_dashboard/page_variant__total_control_dashboard-http_status_code-0__content?js=nojs">' . $edit_this_panel_text . '</a>&nbsp;' . $to_do_more_text . '</p>';
    return [
      '#type' => 'markup',
      '#markup' => $markup_data,
    ];
  }
  else {
    $welcome_to_dashboard_text = $this
      ->t('Welcome to your administrative dashboard.');
    $you_have_to_enable_text = $this
      ->t('You have to enable');
    $page_manager_ui_text = $this
      ->t('Page Manager UI');
    $to_edit_text = $this
      ->t('module to edit this panel.');
    $markup_data = '<p>' . $welcome_to_dashboard_text . '&nbsp;' . $you_have_to_enable_text . ' <strong>' . $page_manager_ui_text . '</strong> ' . $to_edit_text . '</p>';
    return [
      '#type' => 'markup',
      '#markup' => $markup_data,
    ];
  }
}