class AnnounceBlock
Same name and namespace in other branches
- 11.x core/modules/announcements_feed/src/Plugin/Block/AnnounceBlock.php \Drupal\announcements_feed\Plugin\Block\AnnounceBlock
Provides an 'Announcements Feed' block.
@Block( id = "announce_block", admin_label = @Translation("Announcements Feed"), )
@internal
Hierarchy
- class \Drupal\announcements_feed\Plugin\Block\AnnounceBlock
Expanded class hierarchy of AnnounceBlock
File
-
core/
modules/ announcements_feed/ src/ Plugin/ Block/ AnnounceBlock.php, line 25
Namespace
Drupal\announcements_feed\Plugin\BlockView source
class AnnounceBlock extends BlockBase implements ContainerFactoryPluginInterface {
/**
* Constructs a new AnnouncementsFeedBlock instance.
*
* @param array $configuration
* A configuration array containing information about the plugin instance.
* @param string $plugin_id
* The plugin ID for the plugin instance.
* @param mixed $plugin_definition
* The plugin implementation definition.
* @param \Drupal\announcements_feed\AnnounceRenderer $announceRenderer
* The AnnounceRenderer service.
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, protected AnnounceRenderer $announceRenderer) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) : static {
return new static($configuration, $plugin_id, $plugin_definition, $container->get('announcements_feed.renderer'));
}
/**
* {@inheritdoc}
*/
public function blockAccess(AccountInterface $account) : AccessResultInterface {
return AccessResult::allowedIfHasPermission($account, 'access announcements');
}
/**
* {@inheritdoc}
*/
public function build() : array {
return $this->announceRenderer
->render();
}
}
Members
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
AnnounceBlock::blockAccess | public | function | Indicates whether the block should be shown. |
AnnounceBlock::build | public | function | Builds and returns the renderable array for this block plugin. |
AnnounceBlock::create | public static | function | Creates an instance of the plugin. |
AnnounceBlock::__construct | public | function | Constructs a new AnnouncementsFeedBlock instance. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.