public function LanguageBlock::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/language/lib/Drupal/language/Plugin/Block/LanguageBlock.php, line 36
Contains \Drupal\language\Plugin\Block\LanguageBlock.

Class

LanguageBlock
Provides a 'Language switcher' block.

Namespace

Drupal\language\Plugin\Block

Code

public function build() {
  $build = array();
  $path = drupal_is_front_page() ? '<front>' : current_path();
  list($plugin_id, $type) = explode(':', $this
    ->getPluginId());
  $links = language_negotiation_get_switch_links($type, $path);
  if (isset($links->links)) {
    $build = array(
      '#theme' => 'links__language_block',
      '#links' => $links->links,
      '#attributes' => array(
        'class' => array(
          "language-switcher-{$links->method_id}",
        ),
      ),
    );
  }
  return $build;
}