SyndicateBlock.php

Same filename and directory in other branches
  1. 9 core/modules/node/src/Plugin/Block/SyndicateBlock.php
  2. 10 core/modules/node/src/Plugin/Block/SyndicateBlock.php
  3. 11.x core/modules/node/src/Plugin/Block/SyndicateBlock.php

Namespace

Drupal\node\Plugin\Block

File

core/modules/node/src/Plugin/Block/SyndicateBlock.php

View source
<?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',
        ];
    }

}

Classes

Title Deprecated Summary
SyndicateBlock Provides a 'Syndicate' block that links to the site's RSS feed.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.