Commit 5c7c2617 authored by webchick's avatar webchick
Browse files

Issue #3045812 by vadim.hirbu, Lendude, tedbow: Add display name to Views block placeholder

parent 1c299c6d
......@@ -110,7 +110,12 @@ public function defaultConfiguration() {
* {@inheritdoc}
*/
public function getPreviewFallbackString() {
return $this->t('"@view" views block', ['@view' => $this->view->storage->label()]);
if (!empty($this->pluginDefinition["admin_label"])) {
return $this->t('"@view" views block', ['@view' => $this->pluginDefinition["admin_label"]]);
}
else {
return $this->t('"@view" views block', ['@view' => $this->view->storage->label() . '::' . $this->displayID]);
}
}
/**
......
......@@ -127,4 +127,19 @@ public function testBuildWithTitleOverride() {
$this->assertEquals('Overridden title', $build['#title']['#markup']);
}
/**
* Tests that ViewsBlock::getPreviewFallbackString() produces the right value.
*
* @see \Drupal\views\Plugin\Block\ViewsBlockBase::getPreviewFallbackString()
*/
public function testGetPreviewFallbackString() {
$plugin_definition = [
'provider' => 'views',
];
$plugin_id = 'views_block:test_view_block-block_1';
$views_block = ViewsBlock::create($this->container, [], $plugin_id, $plugin_definition);
$this->assertEqual($views_block->getPreviewFallbackString(), '"test_view_block::block_1" views block');
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment