Commit 41b6df58 authored by alexpott's avatar alexpott

Issue #1991442 by tim.plunkett, benjy: Remove 'module' from block plugin configuration.

parent bf4a5828
......@@ -178,7 +178,7 @@ function aggregator_filter_xss($value) {
* Implements hook_preprocess_HOOK() for block templates.
*/
function aggregator_preprocess_block(&$variables) {
if ($variables['configuration']['module'] == 'aggregator') {
if ($variables['configuration']['provider'] == 'aggregator') {
$variables['attributes']['role'] = 'complementary';
}
}
......@@ -330,7 +330,7 @@ function block_rebuild() {
function block_theme_suggestions_block(array $variables) {
$suggestions = array();
$suggestions[] = 'block__' . $variables['elements']['#configuration']['module'];
$suggestions[] = 'block__' . $variables['elements']['#configuration']['provider'];
// Hyphens (-) and underscores (_) play a special role in theme suggestions.
// Theme suggestions should only contain underscores, because within
// drupal_find_theme_templates(), underscores are converted to hyphens to
......@@ -392,7 +392,7 @@ function template_preprocess_block(&$variables) {
}
$variables['attributes']['class'][] = 'block';
$variables['attributes']['class'][] = drupal_html_class('block-' . $variables['configuration']['module']);
$variables['attributes']['class'][] = drupal_html_class('block-' . $variables['configuration']['provider']);
// Add default class for block content.
$variables['content_attributes']['class'][] = 'content';
......
......@@ -19,9 +19,9 @@ block.block.*:
weight:
type: integer
label: 'Weight'
module:
provider:
type: string
label: 'Module'
label: 'Provider'
status:
type: boolean
label: 'Status'
......@@ -94,9 +94,9 @@ block.block.*:
view_mode:
type: string
label: 'View mode'
module:
provider:
type: string
label: 'Module'
label: 'Provider'
langcode:
type: string
label: 'Default language'
......
......@@ -61,7 +61,7 @@ public function setConfiguration(array $configuration) {
protected function baseConfigurationDefaults() {
return array(
'label' => '',
'module' => $this->pluginDefinition['module'],
'provider' => $this->pluginDefinition['provider'],
'label_display' => BlockInterface::BLOCK_LABEL_VISIBLE,
'cache' => array(
'max_age' => 0,
......@@ -105,9 +105,9 @@ public function access(AccountInterface $account) {
*/
public function buildConfigurationForm(array $form, array &$form_state) {
$definition = $this->getPluginDefinition();
$form['module'] = array(
$form['provider'] = array(
'#type' => 'value',
'#value' => $definition['module'],
'#value' => $definition['provider'],
);
$form['admin_label'] = array(
......@@ -218,7 +218,7 @@ public function submitConfigurationForm(array &$form, array &$form_state) {
if (!form_get_errors($form_state)) {
$this->configuration['label'] = $form_state['values']['label'];
$this->configuration['label_display'] = $form_state['values']['label_display'];
$this->configuration['module'] = $form_state['values']['module'];
$this->configuration['provider'] = $form_state['values']['provider'];
$this->configuration['cache'] = $form_state['values']['cache'];
$this->blockSubmit($form, $form_state);
}
......
......@@ -63,7 +63,7 @@ protected function initializePlugin($instance_id) {
parent::initializePlugin($instance_id);
}
catch (PluginException $e) {
$module = $this->configuration['module'];
$module = $this->configuration['provider'];
// Ignore blocks belonging to disabled modules, but re-throw valid
// exceptions when the module is enabled and the plugin is misconfigured.
if (!$module || \Drupal::moduleHandler()->moduleExists($module)) {
......
......@@ -69,10 +69,6 @@ public function processDefinition(&$definition, $plugin_id) {
if (!isset($definition['category'])) {
$definition['category'] = $this->getModuleName($definition['provider']);
}
// @todo Remove any usage of 'module' from block code.
if (!isset($definition['module'])) {
$definition['module'] = $definition['provider'];
}
}
/**
......
......@@ -45,7 +45,7 @@ public function testBlockInterface() {
);
$expected_configuration = array(
'label' => 'Custom Display Message',
'module' => 'block_test',
'provider' => 'block_test',
'label_display' => BlockInterface::BLOCK_LABEL_VISIBLE,
'cache' => array(
'max_age' => 0,
......@@ -70,7 +70,7 @@ public function testBlockInterface() {
$contexts = \Drupal::service("cache_contexts")->getLabels();
unset($contexts['cache_context.theme']);
$expected_form = array(
'module' => array(
'provider' => array(
'#type' => 'value',
'#value' => 'block_test',
),
......
......@@ -100,7 +100,7 @@ protected function createTests() {
'plugin' => 'test_html',
'settings' => array(
'label' => '',
'module' => 'block_test',
'provider' => 'block_test',
'label_display' => BlockInterface::BLOCK_LABEL_VISIBLE,
'cache' => array(
'max_age' => 0,
......
......@@ -43,12 +43,12 @@ public function testGetMachineNameSuggestion() {
\Drupal::setContainer($container);
$config = array();
$definition = array('admin_label' => 'Admin label', 'module' => 'block_test');
$definition = array('admin_label' => 'Admin label', 'provider' => 'block_test');
$block_base = new TestBlockInstantiation($config, 'test_block_instantiation', $definition);
$this->assertEquals('adminlabel', $block_base->getMachineNameSuggestion());
// Test with more unicodes.
$definition = array('admin_label' =>'über åwesome', 'module' => 'block_test');
$definition = array('admin_label' =>'über åwesome', 'provider' => 'block_test');
$block_base = new TestBlockInstantiation($config, 'test_block_instantiation', $definition);
$this->assertEquals('uberawesome', $block_base->getMachineNameSuggestion());
}
......
......@@ -7,7 +7,7 @@ region: '-1'
plugin: test_html
settings:
label: 'Test HTML block'
module: block_test
provider: block_test
label_display: 'hidden'
visibility:
path:
......
......@@ -362,7 +362,7 @@ function book_form_node_delete_confirm_alter(&$form, $form_state) {
* Implements hook_preprocess_HOOK() for block templates.
*/
function book_preprocess_block(&$variables) {
if ($variables['configuration']['module'] == 'book') {
if ($variables['configuration']['provider'] == 'book') {
$variables['attributes']['role'] = 'navigation';
}
}
......
......@@ -1260,7 +1260,7 @@ function comment_preview(CommentInterface $comment, array &$form_state) {
* Implements hook_preprocess_HOOK() for block templates.
*/
function comment_preprocess_block(&$variables) {
if ($variables['configuration']['module'] == 'comment') {
if ($variables['configuration']['provider'] == 'comment') {
$variables['attributes']['role'] = 'navigation';
}
}
......
......@@ -524,7 +524,7 @@ function forum_form_node_form_alter(&$form, &$form_state, $form_id) {
* Implements hook_preprocess_HOOK() for block templates.
*/
function forum_preprocess_block(&$variables) {
if ($variables['configuration']['module'] == 'forum') {
if ($variables['configuration']['provider'] == 'forum') {
$variables['attributes']['role'] = 'navigation';
}
}
......
......@@ -641,7 +641,7 @@ function language_language_entity_delete(LanguageEntity $language) {
* Implements hook_preprocess_HOOK() for block templates.
*/
function language_preprocess_block(&$variables) {
if ($variables['configuration']['module'] == 'language') {
if ($variables['configuration']['provider'] == 'language') {
$variables['attributes']['role'] = 'navigation';
}
}
......
......@@ -52,7 +52,7 @@ public function testMenuBlock() {
'menu_name' => 'llama',
));
$menu_link->save();
$block = $this->drupalPlaceBlock('system_menu_block:llama', array('label' => 'Llama', 'module' => 'system', 'region' => 'footer'));
$block = $this->drupalPlaceBlock('system_menu_block:llama', array('label' => 'Llama', 'provider' => 'system', 'region' => 'footer'));
// Prime the page cache.
$this->verifyPageCache($path, 'MISS');
......
......@@ -464,7 +464,7 @@ function testUnpublishedNodeMenuItem() {
public function testBlockContextualLinks() {
$this->drupalLogin($this->drupalCreateUser(array('administer menu', 'access contextual links', 'administer blocks')));
$this->addMenuLink();
$block = $this->drupalPlaceBlock('system_menu_block:tools', array('label' => 'Tools', 'module' => 'system'));
$block = $this->drupalPlaceBlock('system_menu_block:tools', array('label' => 'Tools', 'provider' => 'system'));
$this->drupalGet('test-page');
$id = 'block:block=' . $block->id() . ':|menu:menu=tools:';
......
......@@ -655,7 +655,7 @@ function menu_get_menus($all = TRUE) {
* Implements hook_preprocess_HOOK() for block templates.
*/
function menu_preprocess_block(&$variables) {
if ($variables['configuration']['module'] == 'menu') {
if ($variables['configuration']['provider'] == 'menu') {
$variables['attributes']['role'] = 'navigation';
}
}
......@@ -592,7 +592,7 @@ function node_preprocess_html(&$variables) {
* Implements hook_preprocess_HOOK() for block templates.
*/
function node_preprocess_block(&$variables) {
if ($variables['configuration']['module'] == 'node') {
if ($variables['configuration']['provider'] == 'node') {
switch ($variables['elements']['#plugin_id']) {
case 'node_syndicate_block':
$variables['attributes']['role'] = 'complementary';
......
......@@ -323,7 +323,7 @@ function shortcut_renderable_links($shortcut_set = NULL) {
* Implements hook_preprocess_HOOK() for block templates.
*/
function shortcut_preprocess_block(&$variables) {
if ($variables['configuration']['module'] == 'shortcut') {
if ($variables['configuration']['provider'] == 'shortcut') {
$variables['attributes']['role'] = 'navigation';
}
}
......
......@@ -231,7 +231,7 @@ function statistics_ranking() {
* Implements hook_preprocess_HOOK() for block templates.
*/
function statistics_preprocess_block(&$variables) {
if ($variables['configuration']['module'] == 'statistics') {
if ($variables['configuration']['provider'] == 'statistics') {
$variables['attributes']['role'] = 'navigation';
}
}
......
......@@ -552,7 +552,7 @@ function user_validate_current_pass(&$form, &$form_state) {
* Implements hook_preprocess_HOOK() for block templates.
*/
function user_preprocess_block(&$variables) {
if ($variables['configuration']['module'] == 'user') {
if ($variables['configuration']['provider'] == 'user') {
switch ($variables['elements']['#plugin_id']) {
case 'user_login_block':
$variables['attributes']['role'] = 'form';
......
......@@ -55,7 +55,7 @@ protected function setUp() {
*/
public function testMachineNameSuggestion() {
$plugin_definition = array(
'module' => 'views',
'provider' => 'views',
);
$plugin_id = 'views_block:test_view_block-block_1';
$views_block = ViewsBlock::create($this->container, array(), $plugin_id, $plugin_definition);
......
......@@ -125,7 +125,8 @@ public function testBuild() {
$block_id = 'views_block:test_view-block_1';
$config = array();
$definition = array();
$definition['module'] = 'views';
$definition['provider'] = 'views';
$plugin = new ViewsBlock($config, $block_id, $definition, $this->executableFactory, $this->storage, $this->account);
$this->assertEquals($build, $plugin->build());
......@@ -146,7 +147,8 @@ public function testBuildFailed() {
$block_id = 'views_block:test_view-block_1';
$config = array();
$definition = array();
$definition['module'] = 'views';
$definition['provider'] = 'views';
$plugin = new ViewsBlock($config, $block_id, $definition, $this->executableFactory, $this->storage, $this->account);
$this->assertEquals(array(), $plugin->build());
......
......@@ -7,7 +7,7 @@ region: sidebar_first
plugin: 'system_menu_block:admin'
settings:
label: Administration
module: system
provider: system
label_display: visible
visibility:
path:
......
......@@ -7,7 +7,7 @@ region: sidebar_first
plugin: user_login_block
settings:
label: 'User login'
module: user
provider: user
label_display: visible
visibility:
path:
......
......@@ -7,7 +7,7 @@ region: sidebar_first
plugin: 'system_menu_block:tools'
settings:
label: Tools
module: system
provider: system
label_display: visible
visibility:
path:
......
......@@ -7,7 +7,7 @@ region: '-1'
plugin: system_breadcrumb_block
settings:
label: Breadcrumbs
module: system
provider: system
label_display: '0'
visibility:
path:
......
......@@ -7,7 +7,7 @@ region: content
plugin: system_main_block
settings:
label: 'Main page content'
module: system
provider: system
label_display: '0'
visibility:
path:
......
......@@ -7,7 +7,7 @@ region: footer
plugin: 'system_menu_block:footer'
settings:
label: 'Footer menu'
module: system
provider: system
label_display: visible
visibility:
path:
......
......@@ -7,7 +7,7 @@ region: help
plugin: system_help_block
settings:
label: 'System Help'
module: system
provider: system
label_display: '0'
visibility:
path:
......
......@@ -7,7 +7,7 @@ region: sidebar_first
plugin: user_login_block
settings:
label: 'User login'
module: user
provider: user
label_display: visible
visibility:
path:
......
......@@ -7,7 +7,7 @@ region: footer
plugin: system_powered_by_block
settings:
label: 'Powered by Drupal'
module: system
provider: system
label_display: '0'
visibility:
path:
......
......@@ -7,7 +7,7 @@ region: sidebar_first
plugin: search_form_block
settings:
label: Search
module: search
provider: search
label_display: visible
visibility:
path:
......
......@@ -7,7 +7,7 @@ region: sidebar_first
plugin: 'system_menu_block:tools'
settings:
label: Tools
module: system
provider: system
label_display: visible
visibility:
path:
......
......@@ -7,7 +7,7 @@ region: '-1'
plugin: system_breadcrumb_block
settings:
label: Breadcrumbs
module: system
provider: system
label_display: '0'
visibility:
path:
......
......@@ -7,7 +7,7 @@ region: content
plugin: system_main_block
settings:
label: 'Main page content'
module: system
provider: system
label_display: '0'
visibility:
path:
......
......@@ -7,7 +7,7 @@ region: help
plugin: system_help_block
settings:
label: 'System Help'
module: system
provider: system
label_display: '0'
visibility:
path:
......
......@@ -7,7 +7,7 @@ region: content
plugin: user_login_block
settings:
label: 'User login'
module: user
provider: user
label_display: visible
visibility:
path:
......
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