diff --git a/core/modules/node/src/Plugin/Block/SyndicateBlock.php b/core/modules/node/src/Plugin/Block/SyndicateBlock.php index 487700f0a9d4c6d660e2f41a313768d29d66d662..118021f9e0b7b0b82ccd8d644556190a9fe404d3 100644 --- a/core/modules/node/src/Plugin/Block/SyndicateBlock.php +++ b/core/modules/node/src/Plugin/Block/SyndicateBlock.php @@ -4,6 +4,9 @@ use Drupal\Core\Access\AccessResult; use Drupal\Core\Block\BlockBase; +use Drupal\Core\Plugin\ContainerFactoryPluginInterface; +use Symfony\Component\DependencyInjection\ContainerInterface; +use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Session\AccountInterface; use Drupal\Core\Url; @@ -16,7 +19,44 @@ * category = @Translation("System") * ) */ -class SyndicateBlock extends BlockBase { +class SyndicateBlock extends BlockBase implements ContainerFactoryPluginInterface { + + + /** + * The config factory. + * + * @var \Drupal\Core\Config\ConfigFactoryInterface + */ + protected $configFactory; + + /** + * Constructs a SyndicateBlock object. + * + * @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\Core\Config\ConfigFactoryInterface $configFactory + * The config factory. + */ + public function __construct(array $configuration, $plugin_id, $plugin_definition, ConfigFactoryInterface $configFactory) { + parent::__construct($configuration, $plugin_id, $plugin_definition); + $this->configFactory = $configFactory; + } + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { + return new static( + $configuration, + $plugin_id, + $plugin_definition, + $container->get('config.factory') + ); + } /** * {@inheritdoc} @@ -38,9 +78,11 @@ protected function blockAccess(AccountInterface $account) { * {@inheritdoc} */ public function build() { + $title = $this->configFactory->get('system.site')->get('name'); return [ '#theme' => 'feed_icon', '#url' => Url::fromUri('internal:/rss.xml'), + '#title' => $title, ]; } diff --git a/core/modules/node/tests/src/Functional/NodeSyndicateBlockTest.php b/core/modules/node/tests/src/Functional/NodeSyndicateBlockTest.php index 0a954f88452ca91b9d9046e356f68ba8f46275b7..18430e79b540c5a6366b688f0b5f7eae6950f5f1 100644 --- a/core/modules/node/tests/src/Functional/NodeSyndicateBlockTest.php +++ b/core/modules/node/tests/src/Functional/NodeSyndicateBlockTest.php @@ -37,6 +37,9 @@ public function testSyndicateBlock() { $this->drupalPlaceBlock('node_syndicate_block', ['id' => 'test_syndicate_block']); $this->drupalGet(''); $this->assertSession()->elementExists('xpath', '//div[@id="block-test-syndicate-block"]/*'); + + // Verify syndicate block title. + $this->assertSession()->pageTextContains('Subscribe to Drupal'); // Tests the syndicate block RSS link rendered at non-front pages. $this->drupalGet('user'); $this->clickLink('Subscribe to');