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