Code:
FILE NAME: LanguageSwitcher.php same as Class name
Path : custom_module/src/Plugin/Block
<?php
namespace Drupal\custom_modulename\Plugin\Block;
use Drupal\Core\Block\BlockBase;
/**
* Provides custom block
*
* @Block(
* id = "language_switcher",
* admin_label = @Translation("LanguageSwitcher"),
* category = @Translation("Custom Plugin"),
* )
*/
class LanguageSwitcher extends BlockBase {
public function build() {
$custom_switcher = "<ul><li>Hello</li></ul>";
return array(
'#markup' => $this->t($custom_switcher),
);
}
}
FILE NAME: LanguageSwitcher.php same as Class name
Path : custom_module/src/Plugin/Block
<?php
namespace Drupal\custom_modulename\Plugin\Block;
use Drupal\Core\Block\BlockBase;
/**
* Provides custom block
*
* @Block(
* id = "language_switcher",
* admin_label = @Translation("LanguageSwitcher"),
* category = @Translation("Custom Plugin"),
* )
*/
class LanguageSwitcher extends BlockBase {
public function build() {
$custom_switcher = "<ul><li>Hello</li></ul>";
return array(
'#markup' => $this->t($custom_switcher),
);
}
}
No comments:
Post a Comment