Provides a 'Language switcher' block.
@Plugin(
id = "language_block",
admin_label = @Translation("Language switcher"),
module = "language",
derivative = "Drupal\language\Plugin\Derivative\LanguageBlock"
)
Expanded class hierarchy of LanguageBlock
class LanguageBlock extends BlockBase {
/**
* Overrides \Drupal\block\BlockBase::access().
*/
function access() {
return language_multilingual();
}
/**
* {@inheritdoc}
*/
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;
}
}
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
BlockBase:: |
public | function | Returns the configuration form elements specific to this block plugin. | 11 |
BlockBase:: |
public | function | Adds block type-specific submission handling for the block form. | 11 |
BlockBase:: |
public | function | Adds block type-specific validation for the block form. | |
BlockBase:: |
public | function |
Implements \Drupal\block\BlockPluginInterface::form(). Overrides BlockPluginInterface:: |
1 |
BlockBase:: |
public | function | Returns the configuration data for the block plugin. | |
BlockBase:: |
public | function | Sets a particular value in the block settings. | |
BlockBase:: |
public | function |
Returns plugin-specific settings for the block. Overrides BlockPluginInterface:: |
13 |
BlockBase:: |
public | function |
Implements \Drupal\block\BlockPluginInterface::submit(). Overrides BlockPluginInterface:: |
|
BlockBase:: |
public | function |
Implements \Drupal\block\BlockPluginInterface::validate(). Overrides BlockPluginInterface:: |
|
BlockBase:: |
public | function |
Constructs a Drupal\Component\Plugin\PluginBase object. Overrides PluginBase:: |
1 |
LanguageBlock:: |
function |
Overrides \Drupal\block\BlockBase::access(). Overrides BlockBase:: |
||
LanguageBlock:: |
public | function |
Builds and returns the renderable array for this block plugin. Overrides BlockPluginInterface:: |
|
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
public | function |
Returns the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function |
Returns the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |