Mercurial > hg > isophonics-drupal-site
diff core/modules/node/src/Plugin/Block/SyndicateBlock.php @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/core/modules/node/src/Plugin/Block/SyndicateBlock.php Wed Nov 29 16:09:58 2017 +0000 @@ -0,0 +1,46 @@ +<?php + +namespace Drupal\node\Plugin\Block; + +use Drupal\Core\Access\AccessResult; +use Drupal\Core\Block\BlockBase; +use Drupal\Core\Session\AccountInterface; + +/** + * Provides a 'Syndicate' block that links to the site's RSS feed. + * + * @Block( + * id = "node_syndicate_block", + * admin_label = @Translation("Syndicate"), + * category = @Translation("System") + * ) + */ +class SyndicateBlock extends BlockBase { + + /** + * {@inheritdoc} + */ + public function defaultConfiguration() { + return [ + 'block_count' => 10, + ]; + } + + /** + * {@inheritdoc} + */ + protected function blockAccess(AccountInterface $account) { + return AccessResult::allowedIfHasPermission($account, 'access content'); + } + + /** + * {@inheritdoc} + */ + public function build() { + return [ + '#theme' => 'feed_icon', + '#url' => 'rss.xml', + ]; + } + +}