diff --git a/core/modules/aggregator/aggregator.module b/core/modules/aggregator/aggregator.module index a2ba059..e2894e6 100644 --- a/core/modules/aggregator/aggregator.module +++ b/core/modules/aggregator/aggregator.module @@ -554,7 +554,7 @@ function aggregator_filter_xss($value) { * Implements hook_preprocess_HOOK() for block.tpl.php. */ function aggregator_preprocess_block(&$variables) { - if ($variables['block']->module == 'aggregator') { + if ($variables['configuration']['module'] == 'aggregator') { $variables['attributes']['role'] = 'complementary'; } } diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorRenderingTest.php b/core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorRenderingTest.php index 1c6056d..b60dde4 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorRenderingTest.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorRenderingTest.php @@ -50,7 +50,7 @@ public function testBlockLinks() { )); $this->drupalLogin($admin_user); - $block = $this->drupalPlaceBlock("aggregator_feed_block:{$feed->id()}", array('label' => 'feed-' . $feed->label()), array('block_count' => 2)); + $block = $this->drupalPlaceBlock("aggregator_feed_block:{$feed->id()}", array('label' => 'feed-' . $feed->label(), 'block_count' => 2)); // Confirm that the block is now being displayed on pages. $this->drupalGet('test-page'); diff --git a/core/modules/block/block.api.php b/core/modules/block/block.api.php index c9b3b1f..f85a625 100644 --- a/core/modules/block/block.api.php +++ b/core/modules/block/block.api.php @@ -99,14 +99,20 @@ function hook_block_view_NAME_alter(array &$build, \Drupal\block\BlockInterface } /** - * Define access for a specific block instance. + * Define access for a block entity. * * This hook is invoked by the access methods of the block plugin system and * should be used to alter the block access rules defined by a module from * another module. * * @param \Drupal\block\Plugin\Core\Entity\Block $block - * The block instance. + * The block entity. + * @param string $operation + * The operation to be performed, e.g., 'view', 'create', 'delete', 'update'. + * @param \Drupal\user\Plugin\Core\Entity\User $account + * The user object to perform the access check operation on. + * @param string $langcode + * The language code to perform the access check operation on. * * @return bool * TRUE will allow access whereas FALSE will deny access to the block. @@ -114,7 +120,7 @@ function hook_block_view_NAME_alter(array &$build, \Drupal\block\BlockInterface * @see \Drupal\block\BlockBase::access() * @see \Drupal\block\BlockBase::blockAccess() */ -function hook_block_access(\Drupal\block\Plugin\Core\Entity\Block $block) { +function hook_block_access(\Drupal\block\Plugin\Core\Entity\Block $block, $operation, \Drupal\user\Plugin\Core\Entity\User $account, $langcode) { // Example code that would prevent displaying the 'Powered by Drupal' block in // a region different than the footer. if ($block->get('plugin') == 'system_powered_by_block' && $block->get('region') != 'footer') { @@ -123,5 +129,20 @@ function hook_block_access(\Drupal\block\Plugin\Core\Entity\Block $block) { } /** + * Allow or deny access to a specific block plugin. + * + * @param \Drupal\block\BlockInterface $block + * The block plugin. + * + * @return bool + * TRUE will allow access whereas FALSE will deny access to the block. + */ +function hook_block_plugin_access(\Drupal\block\BlockInterface $block) { + if ($block->getPluginID() == 'my_plugin_id') { + return FALSE; + } +} + +/** * @} End of "addtogroup hooks". */ diff --git a/core/modules/block/block.module b/core/modules/block/block.module index fe5642a..a74fabe 100644 --- a/core/modules/block/block.module +++ b/core/modules/block/block.module @@ -6,6 +6,7 @@ */ use Drupal\Component\Plugin\Exception\PluginException; +use Drupal\Component\Utility\NestedArray; /** * Denotes that a block is not enabled in any region and should not be shown. @@ -334,10 +335,9 @@ function _block_get_renderable_region($list = array()) { $build[$key] = array( '#block' => $block, '#weight' => $block->get('weight'), - '#theme_wrappers' => array('block'), '#pre_render' => array('_block_get_renderable_block'), '#cache' => array( - 'keys' => array($id, $block->get('module')), + 'keys' => array($id, $settings['module']), 'granularity' => $settings['cache'], 'bin' => 'block', 'tags' => array('content' => TRUE), @@ -502,7 +502,7 @@ function _block_get_renderable_block($element) { $block = $element['#block']; // Don't bother to build blocks that aren't accessible. if ($element['#access'] = $block->access()) { - $element += entity_view($block, 'block'); + $element = NestedArray::mergeDeep($element, entity_view($block, 'block')); } return $element; } @@ -538,22 +538,17 @@ function block_rebuild() { function template_preprocess_block(&$variables) { $block_counter = &drupal_static(__FUNCTION__, array()); - $variables['block'] = (object) $variables['elements']['#block_config']; - // If the block title is configured to be hidden, set it to an empty string. - if (empty($variables['elements']['#block']->label_display)) { - $variables['block']->label_hidden = $variables['block']->label; - $variables['block']->label = ''; - } - - // Create the $content variable that templates expect. - $variables['content'] = $variables['elements']['#children']; + $variables['configuration'] = $variables['elements']['#configuration']; + $variables['plugin_id'] = $variables['elements']['#plugin_id']; + $variables['title'] = !empty($variables['configuration']['label_display']) ? $variables['configuration']['label'] : ''; + $variables['content'] = $variables['elements']['content']; - $variables['attributes']['class'][] = drupal_html_class('block-' . $variables['block']->module); + $variables['attributes']['class'][] = drupal_html_class('block-' . $variables['configuration']['module']); // Add default class for block content. $variables['content_attributes']['class'][] = 'content'; - $variables['theme_hook_suggestions'][] = 'block__' . $variables['block']->module; + $variables['theme_hook_suggestions'][] = 'block__' . $variables['configuration']['module']; // 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 @@ -565,7 +560,7 @@ function template_preprocess_block(&$variables) { // We can safely explode on : because we know the Block plugin type manager // enforces that delimiter for all derivatives. - $parts = explode(':', $variables['elements']['#block']->get('plugin')); + $parts = explode(':', $variables['plugin_id']); $suggestion = 'block'; while ($part = array_shift($parts)) { $variables['theme_hook_suggestions'][] = $suggestion .= '__' . strtr($part, '-', '_'); @@ -586,10 +581,11 @@ function template_preprocess_block(&$variables) { */ function block_user_role_delete($role) { foreach (entity_load_multiple('block') as $block_id => $block) { - $visibility = $block->get('visibility'); + $settings = $block->get('settings'); + $visibility = $settings['visibility']; if (isset($visibility['roles']['roles'][$role->id()])) { unset($visibility['roles']['roles'][$role->id()]); - $block->set('visibility', $visibility); + $block->getPlugin()->setConfig('visibility', $visibility); $block->save(); } } @@ -626,10 +622,11 @@ function block_admin_paths() { function block_language_delete($language) { // Remove the block visibility settings for the deleted language. foreach (entity_load_multiple('block') as $block_id => $block) { - $visibility = $block->get('visibility'); + $settings = $block->get('settings'); + $visibility = $settings['visibility']; if (isset($visibility['language']['langcodes'][$language->langcode])) { unset($visibility['language']['langcodes'][$language->langcode]); - $block->set('visibility', $visibility); + $block->getPlugin()->setConfig('visibility', $visibility); $block->save(); } } diff --git a/core/modules/block/custom_block/custom_block.module b/core/modules/block/custom_block/custom_block.module index 4a1cbcb..4244f02 100644 --- a/core/modules/block/custom_block/custom_block.module +++ b/core/modules/block/custom_block/custom_block.module @@ -8,7 +8,7 @@ use Drupal\custom_block\Plugin\Core\Entity\CustomBlockType; use Drupal\custom_block\Plugin\Core\Entity\CustomBlock; use Drupal\custom_block\Plugin\block\block\CustomBlockBlock; -use Drupal\block\Plugin\Core\Entity\Block; +use Drupal\block\BlockInterface; /** * Implements hook_menu_local_tasks(). diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Derivative/CustomBlock.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Derivative/CustomBlock.php index 592f150..71a50bd 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Derivative/CustomBlock.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Derivative/CustomBlock.php @@ -43,9 +43,6 @@ public function getDerivativeDefinitions(array $base_plugin_definition) { $custom_blocks = entity_load_multiple('custom_block'); foreach ($custom_blocks as $custom_block) { $this->derivatives[$custom_block->uuid->value] = $base_plugin_definition; - $this->derivatives[$custom_block->uuid->value]['settings'] = array( - 'info' => $custom_block->info->value, - ) + $base_plugin_definition['settings']; $this->derivatives[$custom_block->uuid->value]['admin_label'] = $custom_block->info->value; } return $this->derivatives; diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/block/block/CustomBlockBlock.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/block/block/CustomBlockBlock.php index ab8c65e..3ed308f 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/block/block/CustomBlockBlock.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/block/block/CustomBlockBlock.php @@ -18,26 +18,20 @@ * id = "custom_block", * admin_label = @Translation("Custom block"), * module = "custom_block", - * derivative = "Drupal\custom_block\Plugin\Derivative\CustomBlock", - * settings = { - * "status" = TRUE, - * "info" = "", - * "view_mode" = "full" - * } + * derivative = "Drupal\custom_block\Plugin\Derivative\CustomBlock" * ) */ class CustomBlockBlock extends BlockBase { /** - * Overrides \Drupal\block\BlockBase::getConfig(). + * Overrides \Drupal\block\BlockBase::settings(). */ - public function getConfig() { - $definition = $this->getDefinition(); - $this->configuration = parent::getConfig(); - $this->configuration['status'] = $definition['settings']['status']; - $this->configuration['info'] = $definition['settings']['info']; - $this->configuration['view_mode'] = $definition['settings']['view_mode']; - return $this->configuration; + public function settings() { + return array( + 'status' => TRUE, + 'info' => '', + 'view_mode' => 'full', + ); } /** diff --git a/core/modules/block/lib/Drupal/block/BlockAccessController.php b/core/modules/block/lib/Drupal/block/BlockAccessController.php index 8e8a563..7761f4b 100644 --- a/core/modules/block/lib/Drupal/block/BlockAccessController.php +++ b/core/modules/block/lib/Drupal/block/BlockAccessController.php @@ -20,7 +20,78 @@ class BlockAccessController extends EntityAccessController { * Overrides \Drupal\Core\Entity\EntityAccessController::viewAccess(). */ public function viewAccess(EntityInterface $entity, $langcode = LANGUAGE_DEFAULT, User $account = NULL) { - return $entity->getPlugin()->access(); + // @todo \Drupal\Core\Entity\EntityAccessController::viewAccess() casts to a + // Boolean, which incorrectly implies that access was always explicitly + // granted or denied. To work around this call + // \Drupal\Core\Entity\EntityAccessController::access() directly and check + // the return type. + $access = $this->access($entity, 'view', $langcode, $account); + if ($access !== FALSE) { + // If entity access did not explicitly deny access, consult the plugin. + if ($entity->getPlugin()->access()) { + // Otherwise, check for other access restrictions. + global $user; + + // User role access handling. + // If a block has no roles associated, it is displayed for every role. + // For blocks with roles associated, if none of the user's roles matches + // the settings from this block, access is denied. + $visibility = $entity->get('visibility'); + if (!empty($visibility['role']['roles']) && !array_intersect(array_filter($visibility['role']['roles']), array_keys($user->roles))) { + // No match. + return FALSE; + } + + // Page path handling. + // Limited visibility blocks must list at least one page. + if (!empty($visibility['path']['visibility']) && $visibility['path']['visibility'] == BLOCK_VISIBILITY_LISTED && empty($visibility['path']['pages'])) { + return FALSE; + } + + // Match path if necessary. + if (!empty($visibility['path']['pages'])) { + // Assume there are no matches until one is found. + $page_match = FALSE; + + // Convert path to lowercase. This allows comparison of the same path + // with different case. Ex: /Page, /page, /PAGE. + $pages = drupal_strtolower($visibility['path']['pages']); + if ($visibility['path']['visibility'] < BLOCK_VISIBILITY_PHP) { + // Compare the lowercase path alias (if any) and internal path. + $path = current_path(); + $path_alias = drupal_strtolower(drupal_container()->get('path.alias_manager')->getPathAlias($path)); + $page_match = drupal_match_path($path_alias, $pages) || (($path != $path_alias) && drupal_match_path($path, $pages)); + // When $block->visibility has a value of 0 + // (BLOCK_VISIBILITY_NOTLISTED), the block is displayed on all pages + // except those listed in $block->pages. When set to 1 + // (BLOCK_VISIBILITY_LISTED), it is displayed only on those pages + // listed in $block->pages. + $page_match = !($visibility['path']['visibility'] xor $page_match); + } + elseif (module_exists('php')) { + $page_match = php_eval($visibility['path']['pages']); + } + + // If there are page visibility restrictions and this page does not + // match, deny access. + if (!$page_match) { + return FALSE; + } + } + + // Language visibility settings. + if (!empty($visibility['language']['langcodes']) && array_filter($visibility['language']['langcodes'])) { + if (empty($visibility['language']['langcodes'][language($visibility['language']['language_type'])->langcode])) { + return FALSE; + } + } + return TRUE; + } + else { + return FALSE; + } + } + return $access; } } diff --git a/core/modules/block/lib/Drupal/block/BlockBase.php b/core/modules/block/lib/Drupal/block/BlockBase.php index 0909345..e31ff82 100644 --- a/core/modules/block/lib/Drupal/block/BlockBase.php +++ b/core/modules/block/lib/Drupal/block/BlockBase.php @@ -8,7 +8,6 @@ namespace Drupal\block; use Drupal\Component\Plugin\PluginBase; -use Drupal\block\Plugin\Core\Entity\Block; use Drupal\Component\Plugin\Discovery\DiscoveryInterface; /** @@ -20,20 +19,17 @@ */ abstract class BlockBase extends PluginBase implements BlockInterface { - /** - * The entity using this plugin. - * - * @var \Drupal\block\Plugin\Core\Entity\Block - */ - protected $entity; - - /** - * Overrides \Drupal\Component\Plugin\PluginBase::__construct(). - */ - public function __construct(array $configuration, $plugin_id, array $plugin_definition, Block $entity) { + public function __construct(array $configuration, $plugin_id, array $plugin_definition) { parent::__construct($configuration, $plugin_id, $plugin_definition); - $this->entity = $entity; + $this->configuration += $this->settings() + array( + 'label' => $plugin_definition['admin_label'], + 'weight' => '', + 'module' => $plugin_definition['module'], + 'label_display' => BLOCK_LABEL_VISIBLE, + 'cache' => DRUPAL_NO_CACHE, + 'status' => TRUE, + ); } /** @@ -65,18 +61,6 @@ public function settings() { * @see \Drupal\Component\Plugin\PluginBase::$configuration */ public function getConfig() { - if (empty($this->configuration)) { - // If the plugin configuration is not already set, initialize it with the - // default settings for the block plugin. - $this->configuration = $this->settings(); - - $definition = $this->getDefinition(); - if (isset($definition['admin_label'])) { - $this->configuration += array('admin_label' => $definition['admin_label']); - } - } - // Ensure that the default cache mode is set. - $this->configuration += array('cache' => DRUPAL_NO_CACHE); return $this->configuration; } @@ -138,71 +122,14 @@ public function access() { return FALSE; } - // Otherwise, check for other access restrictions. - global $user; - // Deny access to disabled blocks. - if (!$this->entity->get('status')) { - return FALSE; - } - - // User role access handling. - // If a block has no roles associated, it is displayed for every role. - // For blocks with roles associated, if none of the user's roles matches - // the settings from this block, access is denied. - $visibility = $this->entity->get('visibility'); - if (!empty($visibility['role']['roles']) && !array_intersect(array_filter($visibility['role']['roles']), array_keys($user->roles))) { - // No match. - return FALSE; - } - - // Page path handling. - // Limited visibility blocks must list at least one page. - if (!empty($visibility['path']['visibility']) && $visibility['path']['visibility'] == BLOCK_VISIBILITY_LISTED && empty($visibility['path']['pages'])) { + if (!$this->configuration['status']) { return FALSE; } - // Match path if necessary. - if (!empty($visibility['path']['pages'])) { - // Assume there are no matches until one is found. - $page_match = FALSE; - - // Convert path to lowercase. This allows comparison of the same path - // with different case. Ex: /Page, /page, /PAGE. - $pages = drupal_strtolower($visibility['path']['pages']); - if ($visibility['path']['visibility'] < BLOCK_VISIBILITY_PHP) { - // Compare the lowercase path alias (if any) and internal path. - $path = current_path(); - $path_alias = drupal_strtolower(drupal_container()->get('path.alias_manager')->getPathAlias($path)); - $page_match = drupal_match_path($path_alias, $pages) || (($path != $path_alias) && drupal_match_path($path, $pages)); - // When $block->visibility has a value of 0 - // (BLOCK_VISIBILITY_NOTLISTED), the block is displayed on all pages - // except those listed in $block->pages. When set to 1 - // (BLOCK_VISIBILITY_LISTED), it is displayed only on those pages - // listed in $block->pages. - $page_match = !($visibility['path']['visibility'] xor $page_match); - } - elseif (module_exists('php')) { - $page_match = php_eval($visibility['path']['pages']); - } - - // If there are page visibility restrictions and this page does not - // match, deny access. - if (!$page_match) { - return FALSE; - } - } - - // Language visibility settings. - if (!empty($visibility['language']['langcodes']) && array_filter($visibility['language']['langcodes'])) { - if (empty($visibility['language']['langcodes'][language($visibility['language']['language_type'])->langcode])) { - return FALSE; - } - } - // Check other modules for block access rules. - foreach (module_implements('block_access') as $module) { - if (module_invoke($module, 'block_access', $this->entity) === FALSE) { + foreach (module_implements('block_plugin_access') as $module) { + if (module_invoke($module, 'block_plugin_access', $this) === FALSE) { return FALSE; } } @@ -222,12 +149,7 @@ public function access() { * @see \Drupal\block\BlockBase::blockForm() */ public function form($form, &$form_state) { - $entity = $form_state['entity']; $definition = $this->getDefinition(); - $form['id'] = array( - '#type' => 'value', - '#value' => $entity->id(), - ); $form['module'] = array( '#type' => 'value', '#value' => $definition['module'], @@ -237,164 +159,18 @@ public function form($form, &$form_state) { '#type' => 'textfield', '#title' => t('Title'), '#maxlength' => 255, - '#default_value' => !$entity->isNew() ? $entity->label() : $definition['admin_label'], + '#default_value' => $this->configuration['label'], '#required' => TRUE, ); $form['label_display'] = array( '#type' => 'checkbox', '#title' => t('Display title'), - '#default_value' => $entity->label_display == BLOCK_LABEL_VISIBLE ? TRUE : FALSE, + '#default_value' => $this->configuration['label_display'] == BLOCK_LABEL_VISIBLE, '#return_value' => BLOCK_LABEL_VISIBLE, ); - $form['machine_name'] = array( - '#type' => 'machine_name', - '#title' => t('Machine name'), - '#maxlength' => 64, - '#description' => t('A unique name to save this block configuration. Must be alpha-numeric and be underscore separated.'), - '#default_value' => $entity->id(), - '#machine_name' => array( - 'exists' => 'block_load', - 'replace_pattern' => '[^a-z0-9_.]+', - ), - '#required' => TRUE, - '#disabled' => !$entity->isNew(), - ); - - // Region settings. - $form['region'] = array( - '#type' => 'select', - '#title' => t('Region'), - '#description' => t('Select the region where this block should be displayed.'), - '#default_value' => $entity->get('region'), - '#empty_value' => BLOCK_REGION_NONE, - '#options' => system_region_list($entity->get('theme'), REGIONS_VISIBLE), - ); - - // Visibility settings. - $form['visibility'] = array( - '#type' => 'vertical_tabs', - '#title' => t('Visibility settings'), - '#attached' => array( - 'js' => array(drupal_get_path('module', 'block') . '/block.js'), - ), - '#tree' => TRUE, - '#weight' => 10, - ); - - // Per-path visibility. - $form['visibility']['path'] = array( - '#type' => 'details', - '#title' => t('Pages'), - '#collapsed' => TRUE, - '#group' => 'visibility', - '#weight' => 0, - ); - - // @todo remove this access check and inject it in some other way. In fact - // this entire visibility settings section probably needs a separate user - // interface in the near future. - $visibility = $entity->get('visibility'); - $access = user_access('use PHP for settings'); - if (!empty($visibility['path']['visibility']) && $visibility['path']['visibility'] == BLOCK_VISIBILITY_PHP && !$access) { - $form['visibility']['path']['visibility'] = array( - '#type' => 'value', - '#value' => BLOCK_VISIBILITY_PHP, - ); - $form['visibility']['path']['pages'] = array( - '#type' => 'value', - '#value' => !empty($visibility['path']['pages']) ? $visibility['path']['pages'] : '', - ); - } - else { - $options = array( - BLOCK_VISIBILITY_NOTLISTED => t('All pages except those listed'), - BLOCK_VISIBILITY_LISTED => t('Only the listed pages'), - ); - $description = t("Specify pages by using their paths. Enter one path per line. The '*' character is a wildcard. Example paths are %user for the current user's page and %user-wildcard for every user page. %front is the front page.", array('%user' => 'user', '%user-wildcard' => 'user/*', '%front' => '')); - - if (module_exists('php') && $access) { - $options += array(BLOCK_VISIBILITY_PHP => t('Pages on which this PHP code returns TRUE (experts only)')); - $title = t('Pages or PHP code'); - $description .= ' ' . t('If the PHP option is chosen, enter PHP code between %php. Note that executing incorrect PHP code can break your Drupal site.', array('%php' => '')); - } - else { - $title = t('Pages'); - } - $form['visibility']['path']['visibility'] = array( - '#type' => 'radios', - '#title' => t('Show block on specific pages'), - '#options' => $options, - '#default_value' => !empty($visibility['path']['visibility']) ? $visibility['path']['visibility'] : BLOCK_VISIBILITY_NOTLISTED, - ); - $form['visibility']['path']['pages'] = array( - '#type' => 'textarea', - '#title' => '' . $title . '', - '#default_value' => !empty($visibility['path']['pages']) ? $visibility['path']['pages'] : '', - '#description' => $description, - ); - } - - // Configure the block visibility per language. - if (module_exists('language') && language_multilingual()) { - $configurable_language_types = language_types_get_configurable(); - - // Fetch languages. - $languages = language_list(LANGUAGE_ALL); - foreach ($languages as $language) { - // @todo $language->name is not wrapped with t(), it should be replaced - // by CMI translation implementation. - $langcodes_options[$language->langcode] = $language->name; - } - $form['visibility']['language'] = array( - '#type' => 'details', - '#title' => t('Languages'), - '#collapsed' => TRUE, - '#group' => 'visibility', - '#weight' => 5, - ); - // If there are multiple configurable language types, let the user pick - // which one should be applied to this visibility setting. This way users - // can limit blocks by interface language or content language for exmaple. - $language_types = language_types_info(); - $language_type_options = array(); - foreach ($configurable_language_types as $type_key) { - $language_type_options[$type_key] = $language_types[$type_key]['name']; - } - $form['visibility']['language']['language_type'] = array( - '#type' => 'radios', - '#title' => t('Language type'), - '#options' => $language_type_options, - '#default_value' => !empty($visibility['language']['language_type']) ? $visibility['language']['language_type'] : $configurable_language_types[0], - '#access' => count($language_type_options) > 1, - ); - $form['visibility']['language']['langcodes'] = array( - '#type' => 'checkboxes', - '#title' => t('Show this block only for specific languages'), - '#default_value' => !empty($visibility['language']['langcodes']) ? $visibility['language']['langcodes'] : array(), - '#options' => $langcodes_options, - '#description' => t('Show this block only for the selected language(s). If you select no languages, the block will be visibile in all languages.'), - ); - } - - // Per-role visibility. - $role_options = array_map('check_plain', user_role_names()); - $form['visibility']['role'] = array( - '#type' => 'details', - '#title' => t('Roles'), - '#collapsed' => TRUE, - '#group' => 'visibility', - '#weight' => 10, - ); - $form['visibility']['role']['roles'] = array( - '#type' => 'checkboxes', - '#title' => t('Show block for specific roles'), - '#default_value' => !empty($visibility['role']['roles']) ? $visibility['role']['roles'] : array(), - '#options' => $role_options, - '#description' => t('Show this block only for the selected role(s). If you select no roles, the block will be visible to all users.'), - ); // Add plugin-specific settings for this block type. - $form['settings'] = $this->blockForm(array(), $form_state); + $form += $this->blockForm($form, $form_state); return $form; } @@ -429,14 +205,6 @@ public function blockForm($form, &$form_state) { * @see \Drupal\block\BlockBase::blockValidate() */ public function validate($form, &$form_state) { - if (!empty($form['machine_name']['#disabled'])) { - $config_id = explode('.', $form_state['values']['machine_name']); - $form_state['values']['machine_name'] = array_pop($config_id); - } - $form_state['values']['visibility']['role']['roles'] = array_filter($form_state['values']['visibility']['role']['roles']); - if ($form_state['entity']->isNew()) { - form_set_value($form['id'], $form_state['entity']->get('theme') . '.' . $form_state['values']['machine_name'], $form_state); - } $this->blockValidate($form, $form_state); } @@ -470,11 +238,10 @@ public function blockValidate($form, &$form_state) {} */ public function submit($form, &$form_state) { if (!form_get_errors()) { + $this->configuration['label'] = $form_state['values']['label']; + $this->configuration['label_display'] = $form_state['values']['label_display']; + $this->configuration['module'] = $form_state['values']['module']; $this->blockSubmit($form, $form_state); - - drupal_set_message(t('The block configuration has been saved.')); - cache_invalidate_tags(array('content' => TRUE)); - $form_state['redirect'] = 'admin/structure/block/list/block_plugin_ui:' . $form_state['entity']->get('theme'); } } @@ -500,9 +267,20 @@ public function blockSubmit($form, &$form_state) {} * Implements \Drupal\block\BlockInterface::build(). */ public function build() { - // @todo Move block rendering code common to all blocks from - // BlockRenderController to here: http://drupal.org/node/1927608. - return $this->blockBuild(); + $build = array(); + $plugin_id = $this->getPluginId(); + if ($content = $this->blockBuild()) { + $build = array( + '#theme' => 'block', + 'content' => $content, + '#configuration' => $this->configuration, + '#plugin_id' => $plugin_id, + ); + $build['#configuration']['label'] = check_plain($this->configuration['label']); + } + list($name) = explode(':', $plugin_id . ':'); + drupal_alter(array('block_view', "block_view_$name"), $build, $this); + return $build; } /** diff --git a/core/modules/block/lib/Drupal/block/BlockFormController.php b/core/modules/block/lib/Drupal/block/BlockFormController.php index 8e95248..9f3a13a 100644 --- a/core/modules/block/lib/Drupal/block/BlockFormController.php +++ b/core/modules/block/lib/Drupal/block/BlockFormController.php @@ -19,7 +19,162 @@ class BlockFormController extends EntityFormController { * Overrides \Drupal\Core\Entity\EntityFormController::form(). */ public function form(array $form, array &$form_state, EntityInterface $entity) { - return $entity->getPlugin()->form($form, $form_state); + $form['#tree'] = TRUE; + $form['id'] = array( + '#type' => 'value', + '#value' => $entity->id(), + ); + $form['settings'] = $entity->getPlugin()->form(array(), $form_state); + + $form['machine_name'] = array( + '#type' => 'machine_name', + '#title' => t('Machine name'), + '#maxlength' => 64, + '#description' => t('A unique name to save this block configuration. Must be alpha-numeric and be underscore separated.'), + '#default_value' => $entity->id(), + '#machine_name' => array( + 'exists' => 'block_load', + 'replace_pattern' => '[^a-z0-9_.]+', + 'source' => array('settings', 'label'), + ), + '#required' => TRUE, + '#disabled' => !$entity->isNew(), + ); + + // Visibility settings. + $form['visibility'] = array( + '#type' => 'vertical_tabs', + '#title' => t('Visibility settings'), + '#attached' => array( + 'js' => array(drupal_get_path('module', 'block') . '/block.js'), + ), + '#tree' => TRUE, + '#weight' => 10, + '#parents' => array('visibility'), + ); + + // Per-path visibility. + $form['visibility']['path'] = array( + '#type' => 'details', + '#title' => t('Pages'), + '#collapsed' => TRUE, + '#group' => 'visibility', + '#weight' => 0, + ); + + // @todo remove this access check and inject it in some other way. In fact + // this entire visibility settings section probably needs a separate user + // interface in the near future. + $visibility = $entity->get('visibility'); + $access = user_access('use PHP for settings'); + if (!empty($visibility['path']['visibility']) && $visibility['path']['visibility'] == BLOCK_VISIBILITY_PHP && !$access) { + $form['visibility']['path']['visibility'] = array( + '#type' => 'value', + '#value' => BLOCK_VISIBILITY_PHP, + ); + $form['visibility']['path']['pages'] = array( + '#type' => 'value', + '#value' => !empty($visibility['path']['pages']) ? $visibility['path']['pages'] : '', + ); + } + else { + $options = array( + BLOCK_VISIBILITY_NOTLISTED => t('All pages except those listed'), + BLOCK_VISIBILITY_LISTED => t('Only the listed pages'), + ); + $description = t("Specify pages by using their paths. Enter one path per line. The '*' character is a wildcard. Example paths are %user for the current user's page and %user-wildcard for every user page. %front is the front page.", array('%user' => 'user', '%user-wildcard' => 'user/*', '%front' => '')); + + if (module_exists('php') && $access) { + $options += array(BLOCK_VISIBILITY_PHP => t('Pages on which this PHP code returns TRUE (experts only)')); + $title = t('Pages or PHP code'); + $description .= ' ' . t('If the PHP option is chosen, enter PHP code between %php. Note that executing incorrect PHP code can break your Drupal site.', array('%php' => '')); + } + else { + $title = t('Pages'); + } + $form['visibility']['path']['visibility'] = array( + '#type' => 'radios', + '#title' => t('Show block on specific pages'), + '#options' => $options, + '#default_value' => !empty($visibility['path']['visibility']) ? $visibility['path']['visibility'] : BLOCK_VISIBILITY_NOTLISTED, + ); + $form['visibility']['path']['pages'] = array( + '#type' => 'textarea', + '#title' => '' . $title . '', + '#default_value' => !empty($visibility['path']['pages']) ? $visibility['path']['pages'] : '', + '#description' => $description, + ); + } + + // Configure the block visibility per language. + if (module_exists('language') && language_multilingual()) { + $configurable_language_types = language_types_get_configurable(); + + // Fetch languages. + $languages = language_list(LANGUAGE_ALL); + foreach ($languages as $language) { + // @todo $language->name is not wrapped with t(), it should be replaced + // by CMI translation implementation. + $langcodes_options[$language->langcode] = $language->name; + } + $form['visibility']['language'] = array( + '#type' => 'details', + '#title' => t('Languages'), + '#collapsed' => TRUE, + '#group' => 'visibility', + '#weight' => 5, + ); + // If there are multiple configurable language types, let the user pick + // which one should be applied to this visibility setting. This way users + // can limit blocks by interface language or content language for exmaple. + $language_types = language_types_info(); + $language_type_options = array(); + foreach ($configurable_language_types as $type_key) { + $language_type_options[$type_key] = $language_types[$type_key]['name']; + } + $form['visibility']['language']['language_type'] = array( + '#type' => 'radios', + '#title' => t('Language type'), + '#options' => $language_type_options, + '#default_value' => !empty($visibility['language']['language_type']) ? $visibility['language']['language_type'] : $configurable_language_types[0], + '#access' => count($language_type_options) > 1, + ); + $form['visibility']['language']['langcodes'] = array( + '#type' => 'checkboxes', + '#title' => t('Show this block only for specific languages'), + '#default_value' => !empty($visibility['language']['langcodes']) ? $visibility['language']['langcodes'] : array(), + '#options' => $langcodes_options, + '#description' => t('Show this block only for the selected language(s). If you select no languages, the block will be visibile in all languages.'), + ); + } + + // Per-role visibility. + $role_options = array_map('check_plain', user_role_names()); + $form['visibility']['role'] = array( + '#type' => 'details', + '#title' => t('Roles'), + '#collapsed' => TRUE, + '#group' => 'visibility', + '#weight' => 10, + ); + $form['visibility']['role']['roles'] = array( + '#type' => 'checkboxes', + '#title' => t('Show block for specific roles'), + '#default_value' => !empty($visibility['role']['roles']) ? $visibility['role']['roles'] : array(), + '#options' => $role_options, + '#description' => t('Show this block only for the selected role(s). If you select no roles, the block will be visible to all users.'), + ); + + // Region settings. + $form['region'] = array( + '#type' => 'select', + '#title' => t('Region'), + '#description' => t('Select the region where this block should be displayed.'), + '#default_value' => $entity->get('region'), + '#empty_value' => BLOCK_REGION_NONE, + '#options' => system_region_list($entity->get('theme'), REGIONS_VISIBLE), + ); + return $form; } /** @@ -38,7 +193,17 @@ public function validate(array $form, array &$form_state) { parent::validate($form, $form_state); $entity = $this->getEntity($form_state); - $entity->getPlugin()->validate($form, $form_state); + if ($entity->isNew()) { + form_set_value($form['id'], $entity->get('theme') . '.' . $form_state['values']['machine_name'], $form_state); + } + if (!empty($form['machine_name']['#disabled'])) { + $config_id = explode('.', $form_state['values']['machine_name']); + $form_state['values']['machine_name'] = array_pop($config_id); + } + $form_state['values']['visibility']['role']['roles'] = array_filter($form_state['values']['visibility']['role']['roles']); + $settings = array(); + $settings['values'] = &$form_state['values']['settings']; + $entity->getPlugin()->validate($form, $settings); } /** @@ -49,11 +214,16 @@ public function submit(array $form, array &$form_state) { $entity = $this->getEntity($form_state); // Call the plugin submit handler. - $entity->getPlugin()->submit($form, $form_state); + $settings = array(); + $settings['values'] = &$form_state['values']['settings']; + $entity->getPlugin()->submit($form, $settings); // Save the settings of the plugin. - $entity->set('settings', $entity->getPlugin()->getConfig()); $entity->save(); + + drupal_set_message(t('The block configuration has been saved.')); + cache_invalidate_tags(array('content' => TRUE)); + $form_state['redirect'] = 'admin/structure/block/list/block_plugin_ui:' . $entity->get('theme'); } } diff --git a/core/modules/block/lib/Drupal/block/BlockPluginBag.php b/core/modules/block/lib/Drupal/block/BlockPluginBag.php new file mode 100644 index 0000000..73d50c0 --- /dev/null +++ b/core/modules/block/lib/Drupal/block/BlockPluginBag.php @@ -0,0 +1,69 @@ +manager = $manager; + $this->entity = $entity; + + $this->instanceIDs = drupal_map_assoc($instance_ids); + } + + /** + * Overrides \Drupal\Component\Plugin\PluginBag::initializePlugin(). + */ + protected function initializePlugin($instance_id) { + if (!$instance_id) { + throw new PluginException(format_string("The block '@block' did not specify a plugin.", array('@block' => $this->entity->id()))); + } + if (isset($this->pluginInstances[$instance_id])) { + return; + } + + $settings = $this->entity->get('settings'); + try { + $this->pluginInstances[$instance_id] = $this->manager->createInstance($instance_id, $settings); + } + catch (PluginException $e) { + $module = $settings['module']; + // Ignore blocks belonging to disabled modules, but re-throw valid + // exceptions when the module is enabled and the plugin is misconfigured. + if (!$module || module_exists($module)) { + throw $e; + } + } + } + +} diff --git a/core/modules/block/lib/Drupal/block/BlockRenderController.php b/core/modules/block/lib/Drupal/block/BlockRenderController.php index e1c560e..735d0c0 100644 --- a/core/modules/block/lib/Drupal/block/BlockRenderController.php +++ b/core/modules/block/lib/Drupal/block/BlockRenderController.php @@ -23,42 +23,6 @@ public function buildContent(array $entities, array $displays, $view_mode, $lang } /** - * Provides entity-specific defaults to the build process. - * - * @param Drupal\Core\Entity\EntityInterface $entity - * The entity for which the defaults should be provided. - * @param string $view_mode - * The view mode that should be used. - * @param string $langcode - * (optional) For which language the entity should be prepared, defaults to - * the current content language. - * - * @return array - * An array of defaults to add into the entity render array. - */ - protected function getBuildDefaults(EntityInterface $entity, $view_mode, $langcode) { - // @todo \Drupal\block\Tests\BlockTest::testCustomBlock() assuemes that a - // block can be rendered without any of its wrappers. To do so, it uses a - // custom view mode, and we choose to only add the wrappers on the default - // view mode, 'block'. - if ($view_mode != 'block') { - return array(); - } - - return array( - '#block' => $entity, - '#weight' => $entity->get('weight'), - '#theme_wrappers' => array('block'), - '#block_config' => array( - 'id' => $entity->get('plugin'), - 'region' => $entity->get('region'), - 'module' => $entity->get('module'), - 'label' => check_plain($entity->label()), - ), - ); - } - - /** * Implements Drupal\Core\Entity\EntityRenderControllerInterface::view(). */ public function view(EntityInterface $entity, $view_mode = 'full', $langcode = NULL) { @@ -72,17 +36,9 @@ public function view(EntityInterface $entity, $view_mode = 'full', $langcode = N public function viewMultiple(array $entities = array(), $view_mode = 'full', $langcode = NULL) { $build = array(); foreach ($entities as $entity_id => $entity) { - // Allow blocks to be empty, do not add in the defaults. - if ($content = $entity->getPlugin()->build()) { - $build[$entity_id] = $this->getBuildDefaults($entity, $view_mode, $langcode); - } - $build[$entity_id]['content'] = $content; - - // All blocks, even when empty, should be available for altering. - $id = str_replace(':', '__', $entity->get('plugin')); - list(, $name) = $entity->id(); - drupal_alter(array('block_view', "block_view_$id", "block_view_$name"), $build[$entity_id], $entity); - + $build[$entity_id] = $entity->getPlugin()->build(); + // @todo Remove after fixing moving access check logic to the plugin. + $build[$entity_id]['#block'] = $entity; } return $build; } diff --git a/core/modules/block/lib/Drupal/block/BlockStorageController.php b/core/modules/block/lib/Drupal/block/BlockStorageController.php index a873c5d..a59854c 100644 --- a/core/modules/block/lib/Drupal/block/BlockStorageController.php +++ b/core/modules/block/lib/Drupal/block/BlockStorageController.php @@ -16,20 +16,6 @@ class BlockStorageController extends ConfigStorageController { /** - * Overrides \Drupal\Core\Config\Entity\ConfigStorageController::create(). - */ - public function create(array $values) { - $entity = parent::create($values); - - if (!$entity->get('module')) { - $definition = $entity->getPlugin()->getDefinition(); - $entity->set('module', $definition['module']); - } - - return $entity; - } - - /** * Overrides \Drupal\Core\Config\Entity\ConfigStorageController::load(). */ public function load(array $ids = NULL) { @@ -53,4 +39,13 @@ public function loadByProperties(array $values = array()) { return $blocks; } + /** + * Overrides \Drupal\Core\Config\Entity\ConfigStorageController::preSave(). + */ + protected function preSave(EntityInterface $entity) { + parent::preSave($entity); + + $entity->set('settings', $entity->getPlugin()->getConfig()); + } + } diff --git a/core/modules/block/lib/Drupal/block/Plugin/Core/Entity/Block.php b/core/modules/block/lib/Drupal/block/Plugin/Core/Entity/Block.php index 2d8c638..3c4033a 100644 --- a/core/modules/block/lib/Drupal/block/Plugin/Core/Entity/Block.php +++ b/core/modules/block/lib/Drupal/block/Plugin/Core/Entity/Block.php @@ -10,7 +10,7 @@ use Drupal\Core\Config\Entity\ConfigEntityBase; use Drupal\Core\Entity\Annotation\EntityType; use Drupal\Core\Annotation\Translation; -use Drupal\Component\Plugin\Exception\PluginException; +use Drupal\block\BlockPluginBag; /** * Defines a Block configuration entity class. @@ -53,17 +53,6 @@ class Block extends ConfigEntityBase { public $label; /** - * Whether the block label is displayed to end users. - * - * When this is set to BLOCK_LABEL_VISIBLE (the default value), the label is - * rendered as header in the block markup. Otherwise, the label is passed - * to the block template as a separate $label_hidden variable. - * - * @var string - */ - public $label_display = BLOCK_LABEL_VISIBLE; - - /** * The block UUID. * * @var string @@ -78,13 +67,6 @@ class Block extends ConfigEntityBase { protected $settings = array(); /** - * The plugin instance. - * - * @var \Drupal\block\BlockInterface - */ - protected $instance; - - /** * The region this block is placed in. * * @var string @@ -92,32 +74,34 @@ class Block extends ConfigEntityBase { protected $region = BLOCK_REGION_NONE; /** - * Settings to control the block visibility. + * The plugin instance ID. * - * @var array + * @var string */ - protected $visibility = array(); + protected $plugin; /** - * The weight of the block. + * The plugin bag that holds the block plugin for this entity. * - * @var int + * @var \Drupal\block\BlockPluginBag */ - protected $weight; + protected $pluginBag; /** - * The module owning this plugin. + * The visibility settings. * - * @var string + * @var array */ - protected $module; + protected $visibility; /** - * The plugin instance ID. - * - * @var string + * Overrides \Drupal\Core\Config\Entity\ConfigEntityBase::__construct(); */ - protected $plugin; + public function __construct(array $values, $entity_type) { + parent::__construct($values, $entity_type); + + $this->pluginBag = new BlockPluginBag(\Drupal::service('plugin.manager.block'), array($this->plugin), $this); + } /** * Returns the plugin instance. @@ -126,26 +110,7 @@ class Block extends ConfigEntityBase { * The plugin instance for this block. */ public function getPlugin() { - if (!$this->instance) { - // Throw an exception if no plugin string was provided. - if (!$this->plugin) { - throw new PluginException(format_string("The block '@block' did not specify a plugin.", array('@block' => $this->id()))); - } - - // Create a plugin instance and store its configuration as settings. - try { - $this->instance = drupal_container()->get('plugin.manager.block')->createInstance($this->plugin, $this->settings, $this); - $this->settings += $this->instance->getConfig(); - } - catch (PluginException $e) { - // Ignore blocks belonging to disabled modules, but re-throw valid - // exceptions when the module is enabled and the plugin is misconfigured. - if (empty($this->module) || module_exists($this->module)) { - throw $e; - } - } - } - return $this->instance; + return $this->pluginBag->get($this->plugin); } /** @@ -162,6 +127,14 @@ public function uri() { } /** + * Overrides \Drupal\Core\Entity\Entity::label(); + */ + public function label($langcode = NULL) { + $settings = $this->get('settings'); + return $settings['label']; + } + + /** * Overrides \Drupal\Core\Config\Entity\ConfigEntityBase::get(); */ public function get($property_name, $langcode = NULL) { @@ -177,21 +150,13 @@ public function get($property_name, $langcode = NULL) { * Overrides \Drupal\Core\Config\Entity\ConfigEntityBase::getExportProperties(); */ public function getExportProperties() { + $properties = parent::getExportProperties(); $names = array( - 'id', - 'label', - 'label_display', - 'uuid', 'region', - 'weight', - 'module', - 'status', - 'visibility', 'plugin', 'settings', - 'langcode', + 'visibility', ); - $properties = array(); foreach ($names as $name) { $properties[$name] = $this->get($name); } diff --git a/core/modules/block/lib/Drupal/block/Plugin/Type/BlockManager.php b/core/modules/block/lib/Drupal/block/Plugin/Type/BlockManager.php index b102d4b..9ff342b 100644 --- a/core/modules/block/lib/Drupal/block/Plugin/Type/BlockManager.php +++ b/core/modules/block/lib/Drupal/block/Plugin/Type/BlockManager.php @@ -13,7 +13,6 @@ use Drupal\Core\Plugin\Discovery\AlterDecorator; use Drupal\Core\Plugin\Discovery\CacheDecorator; use Drupal\Component\Plugin\Factory\DefaultFactory; -use Drupal\block\Plugin\Core\Entity\Block; /** * Manages discovery and instantiation of block plugins. @@ -35,15 +34,8 @@ public function __construct(array $namespaces) { $this->discovery = new DerivativeDiscoveryDecorator($this->discovery); $this->discovery = new AlterDecorator($this->discovery, 'block'); $this->discovery = new CacheDecorator($this->discovery, 'block_plugins:' . language(LANGUAGE_TYPE_INTERFACE)->langcode, 'block', CacheBackendInterface::CACHE_PERMANENT, array('block')); - } - /** - * Overrides \Drupal\Component\Plugin\PluginManagerBase::createInstance(). - */ - public function createInstance($plugin_id, array $configuration = array(), Block $entity = NULL) { - $plugin_definition = $this->discovery->getDefinition($plugin_id); - $plugin_class = DefaultFactory::getPluginClass($plugin_id, $plugin_definition); - return new $plugin_class($configuration, $plugin_id, $plugin_definition, $entity); + $this->factory = new DefaultFactory($this->discovery); } } diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockCacheTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockCacheTest.php index 96f9343..46454a6 100644 --- a/core/modules/block/lib/Drupal/block/Tests/BlockCacheTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/BlockCacheTest.php @@ -192,9 +192,7 @@ function testCachePerPage() { * Private helper method to set the test block's cache mode. */ private function setCacheMode($cache_mode) { - $settings = $this->block->get('settings'); - $settings['cache'] = $cache_mode; - $this->block->set('settings', $settings); + $this->block->getPlugin()->setConfig('cache', $cache_mode); $this->block->save(); } diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockInterfaceTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockInterfaceTest.php new file mode 100644 index 0000000..19e7d0f --- /dev/null +++ b/core/modules/block/lib/Drupal/block/Tests/BlockInterfaceTest.php @@ -0,0 +1,115 @@ + 'Block Plugins Tests', + 'description' => 'Tests that the block plugin can work properly without a supporting entity.', + 'group' => 'Block', + ); + } + + protected function setUp() { + parent::setUp(); + $this->installSchema('user', 'role_permission'); + } + + /** + * Test configuration and subsequent form() and build() method calls. + * + * This test is attempting to test the existing block plugin api and all + * functionality that is expected to remain consistent. The arrays that are + * used for comparison can change, but only to include elements that are + * contained within BlockBase or the plugin being tested. Likely these + * comparison arrays should get smaller, not larger, as more form/build + * elements are moved into a more suitably responsible class. + * + * Instantiation of the plugin is the primary element being tested here. The + * subsequent method calls are just attempting to cause a failure if a + * dependency outside of the plugin configuration is required. + */ + public function testBlockInterface() { + $manager = \Drupal::service('plugin.manager.block'); + $configuration = array( + 'label' => 'Custom Display Message', + ); + $expected_configuration = array( + 'label' => 'Custom Display Message', + 'display_message' => 'no message set', + 'weight' => '', + 'module' => 'block_test', + 'label_display' => BLOCK_LABEL_VISIBLE, + 'cache' => DRUPAL_NO_CACHE, + 'status' => TRUE, + ); + // Initial configuration of the block at construction time. + $display_block = $manager->createInstance('test_block_instantiation', $configuration); + $this->assertIdentical($display_block->getConfig(), $expected_configuration, 'The block was configured correctly.'); + + // Updating an element of the configuration. + $display_block->setConfig('display_message', 'My custom display message.'); + $expected_configuration['display_message'] = 'My custom display message.'; + $this->assertIdentical($display_block->getConfig(), $expected_configuration, 'The block configuration was updated correctly.'); + + $expected_form = array( + 'module' => array( + '#type' => 'value', + '#value' => 'block_test', + ), + 'label' => array( + '#type' => 'textfield', + '#title' => 'Title', + '#maxlength' => 255, + '#default_value' => 'Custom Display Message', + '#required' => TRUE, + ), + 'label_display' => array( + '#type' => 'checkbox', + '#title' => 'Display title', + '#default_value' => TRUE, + '#return_value' => 'visible', + ), + 'display_message' => array( + '#type' => 'textfield', + '#title' => t('Display message'), + '#default_value' => 'My custom display message.', + ), + ); + $form_state = array(); + // Ensure there are no form elements that do not belong to the plugin. + $this->assertIdentical($display_block->form(array(), $form_state), $expected_form, 'Only the expected form elements were present.'); + + $expected_build = array( + '#theme' => 'block', + 'content' => array( + '#children' => 'My custom display message.', + ), + '#configuration' => array( + 'label' => 'Custom Display Message', + 'display_message' => 'My custom display message.', + 'weight' => '', + 'module' => 'block_test', + 'label_display' => BLOCK_LABEL_VISIBLE, + 'cache' => DRUPAL_NO_CACHE, + 'status' => TRUE, + ), + '#plugin_id' => 'test_block_instantiation', + ); + // Ensure the build array is proper. + $this->assertIdentical($display_block->build(), $expected_build, 'The plugin returned the appropriate build array.'); + } +} diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockLanguageTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockLanguageTest.php index f247648..685448d 100644 --- a/core/modules/block/lib/Drupal/block/Tests/BlockLanguageTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/BlockLanguageTest.php @@ -104,8 +104,8 @@ public function testLanguageBlockVisibilityLanguageDelete() { $block = $this->drupalPlaceBlock('system_powered_by_block', $edit); // Check that we have the language in config after saving the setting. - $visibility = $block->get('visibility'); - $setting = $visibility['language']['langcodes']['fr']; + $settings = $block->get('settings'); + $setting = $settings['visibility']['language']['langcodes']['fr']; $this->assertTrue('fr' === $setting, 'Language is set in the block configuration.'); // Delete the language. @@ -114,8 +114,8 @@ public function testLanguageBlockVisibilityLanguageDelete() { // Check that the language is no longer stored in the configuration after // it is deleted. $block = entity_load('block', $block->id()); - $visibility = $block->get('visibility'); - $this->assertTrue(empty($visibility['language']['langcodes']['fr']), 'Language is no longer not set in the block configuration after deleting the block.'); + $settings = $block->get('settings'); + $this->assertTrue(empty($settings['visibility']['language']['langcodes']['fr']), 'Language is no longer not set in the block configuration after deleting the block.'); } } diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockStorageUnitTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockStorageUnitTest.php index 207f20b..b18c9ba 100644 --- a/core/modules/block/lib/Drupal/block/Tests/BlockStorageUnitTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/BlockStorageUnitTest.php @@ -69,6 +69,7 @@ protected function createTests() { // Attempt to create a block without a plugin. try { $entity = $this->controller->create(array()); + $entity->getPlugin(); $this->fail('A block without a plugin was created with no exception thrown.'); } catch (PluginException $e) { @@ -93,18 +94,19 @@ protected function createTests() { $expected_properties = array( 'id' => 'stark.test_block', 'label' => '', - 'label_display' => BLOCK_LABEL_VISIBLE, - 'region' => '-1', - 'weight' => '', - 'module' => 'block_test', 'status' => '1', - 'visibility' => array(), + 'langcode' => language_default()->langcode, + 'region' => '-1', 'plugin' => 'test_html_id', 'settings' => array( 'cache' => '1', - 'admin_label' => t('Test block html id'), + 'label' => t('Test block html id'), + 'weight' => '', + 'module' => 'block_test', + 'label_display' => BLOCK_LABEL_VISIBLE, + 'status' => '1', ), - 'langcode' => language_default()->langcode, + 'visibility' => '', ); $this->assertIdentical($actual_properties, $expected_properties, 'The block properties are exported correctly.'); @@ -124,7 +126,6 @@ protected function loadTests() { $this->assertEqual($entity->get('region'), '-1'); $this->assertTrue($entity->get('status')); $this->assertEqual($entity->get('theme'), 'stark'); - $this->assertEqual($entity->get('module'), 'block_test'); $this->assertTrue($entity->uuid()); } @@ -132,17 +133,14 @@ protected function loadTests() { * Tests the rendering of blocks. */ protected function renderTests() { - $entity = $this->controller->create(array( - 'id' => 'stark.test_block', - 'plugin' => 'test_html_id', - )); - // Test the rendering of a block. + $entity = entity_load('block', 'stark.test_block'); $output = entity_view($entity, 'block'); $expected = array(); $expected[] = '
'; $expected[] = ''; - $expected[] = ' '; + $expected[] = '

Test block html id

'; + $expected[] = ' '; $expected[] = '
'; $expected[] = '
'; $expected[] = '
'; @@ -154,10 +152,17 @@ protected function renderTests() { drupal_static_reset('drupal_html_id'); // Test the rendering of a block with a given title. - $entity->set('label', 'Powered by Bananas'); + $entity = $this->controller->create(array( + 'id' => 'stark.test_block2', + 'plugin' => 'test_html_id', + 'settings' => array( + 'label' => 'Powered by Bananas', + ), + )); + $entity->save(); $output = entity_view($entity, 'block'); $expected = array(); - $expected[] = '
'; + $expected[] = '
'; $expected[] = ''; $expected[] = '

Powered by Bananas

'; $expected[] = ' '; @@ -167,6 +172,8 @@ protected function renderTests() { $expected[] = ''; $expected_output = implode("\n", $expected); $this->assertEqual(drupal_render($output), $expected_output, 'The block rendered correctly.'); + // Clean up this entity. + $entity->delete(); } /** diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockTemplateSuggestionsUnitTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockTemplateSuggestionsUnitTest.php index 95f2cf1..4fa1dc7 100644 --- a/core/modules/block/lib/Drupal/block/Tests/BlockTemplateSuggestionsUnitTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/BlockTemplateSuggestionsUnitTest.php @@ -45,12 +45,9 @@ function testBlockThemeHookSuggestions() { $variables = array(); $variables['elements']['#block'] = $block; - $variables['elements']['#block_config'] = $block->getPlugin()->getConfig() + array( - 'id' => $block->get('plugin'), - 'region' => $block->get('region'), - 'module' => $block->get('module'), - ); - $variables['elements']['#children'] = ''; + $variables['elements']['#configuration'] = $block->getPlugin()->getConfig(); + $variables['elements']['#plugin_id'] = $block->get('plugin'); + $variables['elements']['content']['#children'] = ''; // Test adding a class to the block content. $variables['content_attributes']['class'][] = 'test-class'; template_preprocess_block($variables); diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockTest.php index 9020087..75bcb39 100644 --- a/core/modules/block/lib/Drupal/block/Tests/BlockTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/BlockTest.php @@ -34,7 +34,7 @@ function testBlockVisibility() { $edit = array( 'machine_name' => strtolower($this->randomName(8)), 'region' => 'sidebar_first', - 'label' => $title, + 'settings[label]' => $title, ); // Set the block to be hidden on any user path, and to be shown only to // authenticated users. @@ -75,7 +75,7 @@ function testBlockVisibilityListedEmpty() { $edit = array( 'machine_name' => strtolower($this->randomName(8)), 'region' => 'sidebar_first', - 'label' => $title, + 'settings[label]' => $title, 'visibility[path][visibility]' => BLOCK_VISIBILITY_LISTED, ); // Set the block to be hidden on any user path, and to be shown only to @@ -102,18 +102,18 @@ function testBlock() { // Select the 'Powered by Drupal' block to be configured and moved. $block = array(); $block['id'] = 'system_powered_by_block'; - $block['label'] = $this->randomName(8); + $block['settings[label]'] = $this->randomName(8); $block['machine_name'] = strtolower($this->randomName(8)); $block['theme'] = config('system.theme')->get('default'); $block['region'] = 'header'; // Set block title to confirm that interface works and override any custom titles. - $this->drupalPost('admin/structure/block/add/' . $block['id'] . '/' . $block['theme'], array('label' => $block['label'], 'machine_name' => $block['machine_name'], 'region' => $block['region']), t('Save block')); + $this->drupalPost('admin/structure/block/add/' . $block['id'] . '/' . $block['theme'], array('settings[label]' => $block['settings[label]'], 'machine_name' => $block['machine_name'], 'region' => $block['region']), t('Save block')); $this->assertText(t('The block configuration has been saved.'), 'Block title set.'); // Check to see if the block was created by checking its configuration. $instance = entity_load('block', $block['theme'] . '.' . $block['machine_name']); - $this->assertEqual($instance->label(), $block['label'], 'Stored block title found.'); + $this->assertEqual($instance->label(), $block['settings[label]'], 'Stored block title found.'); // Check whether the block can be moved to all available regions. foreach ($this->regions as $region) { @@ -130,7 +130,7 @@ function testBlock() { // Confirm that the block instance title and markup are not displayed. $this->drupalGet('node'); - $this->assertNoText(t($block['label'])); + $this->assertNoText(t($block['settings[label]'])); // Check for
if the machine name // is my_block_instance_name. $xpath = $this->buildXPathQuery('//div[@id=:id]/*', array(':id' => 'block-' . strtr(strtolower($block['machine_name']), '-', '_'))); @@ -150,7 +150,7 @@ function testHideBlockTitle() { $edit = array( 'machine_name' => $machine_name, 'region' => 'sidebar_first', - 'label' => $title, + 'settings[label]' => $title, ); $this->drupalPost('admin/structure/block/add/' . $block_name . '/' . $default_theme, $edit, t('Save block')); $this->assertText('The block configuration has been saved.', 'Block was saved'); @@ -159,7 +159,7 @@ function testHideBlockTitle() { $this->assertText($title, 'Block title was displayed by default.'); $edit = array( - 'label_display' => FALSE, + 'settings[label_display]' => FALSE, ); $this->drupalPost('admin/structure/block/manage/' . $default_theme . '.' . $machine_name . '/configure', $edit, t('Save block')); $this->assertText('The block configuration has been saved.', 'Block was saved'); @@ -192,7 +192,7 @@ function moveBlockToRegion(array $block, $region) { // Confirm that the block is being displayed. $this->drupalGet(''); - $this->assertText(t($block['label']), 'Block successfully being displayed on the page.'); + $this->assertText(t($block['settings[label]']), 'Block successfully being displayed on the page.'); // Confirm that the custom block was found at the proper region. $xpath = $this->buildXPathQuery('//div[@class=:region-class]//div[@id=:block-id]/*', array( @@ -225,8 +225,7 @@ function testBlockRehash() { $this->assertEqual($settings['cache'], DRUPAL_CACHE_PER_ROLE, 'Test block cache mode defaults to DRUPAL_CACHE_PER_ROLE.'); // Disable caching for this block. - $settings['cache'] = DRUPAL_NO_CACHE; - $block->set('settings', $settings); + $block->getPlugin()->setConfig('cache', DRUPAL_NO_CACHE); $block->save(); // Flushing all caches should call _block_rehash(). $this->resetAll(); @@ -290,13 +289,13 @@ function testBlockModuleDisable() { // Emulate a POST submission rather than using drupalPlaceBlock() to ensure // that the form still functions as expected. $edit = array( - 'label' => $this->randomName(8), + 'settings[label]' => $this->randomName(8), 'machine_name' => strtolower($this->randomName(8)), 'region' => 'sidebar_first', ); $this->drupalPost('admin/structure/block/add/system_powered_by_block/stark', $edit, t('Save block')); $this->assertText(t('The block configuration has been saved.')); - $this->assertText($edit['label']); + $this->assertText($edit['settings[label]']); // Update the weight of a block. $edit = array('blocks[stark.' . $edit['machine_name'] . '][weight]' => -1); diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockTitleXSSTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockTitleXSSTest.php index b04f9fc..7ac3648 100644 --- a/core/modules/block/lib/Drupal/block/Tests/BlockTitleXSSTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/BlockTitleXSSTest.php @@ -32,10 +32,7 @@ public static function getInfo() { protected function setUp() { parent::setUp(); - $this->drupalPlaceBlock('test_xss_title', array( - 'label' => '', - 'machine_name' => 'test_xss_block', - )); + $this->drupalPlaceBlock('test_xss_title', array('label' => '')); } /** diff --git a/core/modules/block/lib/Drupal/block/Tests/Views/DisplayBlockTest.php b/core/modules/block/lib/Drupal/block/Tests/Views/DisplayBlockTest.php index 617f33d..7178e6c 100644 --- a/core/modules/block/lib/Drupal/block/Tests/Views/DisplayBlockTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/Views/DisplayBlockTest.php @@ -90,13 +90,13 @@ protected function findBlockInstance(Block $block) { protected function testDeleteBlockDisplay() { // To test all combinations possible we first place create two instances // of the block display of the first view. - $block_1 = $this->drupalPlaceBlock('views_block:test_view_block-block_1', array(), array('title' => 'test_view_block-block_1:1')); - $block_2 = $this->drupalPlaceBlock('views_block:test_view_block-block_1', array(), array('title' => 'test_view_block-block_1:2')); + $block_1 = $this->drupalPlaceBlock('views_block:test_view_block-block_1', array('title' => 'test_view_block-block_1:1')); + $block_2 = $this->drupalPlaceBlock('views_block:test_view_block-block_1', array('title' => 'test_view_block-block_1:2')); // Then we add one instance of blocks for each of the two displays of the // second view. - $block_3 = $this->drupalPlaceBlock('views_block:test_view_block2-block_1', array(), array('title' => 'test_view_block2-block_1')); - $block_4 = $this->drupalPlaceBlock('views_block:test_view_block2-block_2', array(), array('title' => 'test_view_block2-block_2')); + $block_3 = $this->drupalPlaceBlock('views_block:test_view_block2-block_1', array('title' => 'test_view_block2-block_1')); + $block_4 = $this->drupalPlaceBlock('views_block:test_view_block2-block_2', array('title' => 'test_view_block2-block_2')); $this->drupalGet('test-page'); $this->assertBlockAppears($block_1); diff --git a/core/modules/block/templates/block.tpl.php b/core/modules/block/templates/block.tpl.php index 4b301fa..659ef32 100644 --- a/core/modules/block/templates/block.tpl.php +++ b/core/modules/block/templates/block.tpl.php @@ -46,12 +46,12 @@ -label): ?> - >label; ?> + + > > - +
diff --git a/core/modules/block/tests/config/block.block.stark.test_block.yml b/core/modules/block/tests/config/block.block.stark.test_block.yml index 59ba7b4..fb6856c 100644 --- a/core/modules/block/tests/config/block.block.stark.test_block.yml +++ b/core/modules/block/tests/config/block.block.stark.test_block.yml @@ -1,11 +1,11 @@ id: stark.test_block -label: '' region: '-1' -weight: '' -module: block_test -status: '1' -visibility: { } plugin: test_html_id settings: + label: '' + weight: '' + module: block_test + status: '1' + visibility: { } cache: '1' admin_label: 'Test block html id' diff --git a/core/modules/block/tests/lib/Drupal/block_test/Plugin/block/block/TestBlockInstantiation.php b/core/modules/block/tests/lib/Drupal/block_test/Plugin/block/block/TestBlockInstantiation.php new file mode 100644 index 0000000..bd67c9b --- /dev/null +++ b/core/modules/block/tests/lib/Drupal/block_test/Plugin/block/block/TestBlockInstantiation.php @@ -0,0 +1,69 @@ + 'no message set', + ); + } + + /** + * Overrides \Drupal\block\BlockBase::blockAccess(). + */ + public function blockAccess() { + return user_access('access content'); + } + + /** + * Overrides \Drupal\block\BlockBase::blockForm(). + */ + public function blockForm($form, &$form_state) { + $form['display_message'] = array( + '#type' => 'textfield', + '#title' => t('Display message'), + '#default_value' => $this->configuration['display_message'], + ); + return $form; + } + + /** + * Overrides \Drupal\block\BlockBase::blockSubmit(). + */ + public function blockSubmit($form, &$form_state) { + $this->configuration['display_message'] = $form_state['values']['display_message']; + } + + /** + * Implements \Drupal\block\BlockBase::blockBuild(). + */ + protected function blockBuild() { + return array( + '#children' => $this->configuration['display_message'], + ); + } + +} diff --git a/core/modules/book/book.module b/core/modules/book/book.module index d97dcf1..13e8191 100644 --- a/core/modules/book/book.module +++ b/core/modules/book/book.module @@ -963,7 +963,7 @@ function _book_link_defaults($nid) { * Implements hook_preprocess_HOOK() for block.tpl.php. */ function book_preprocess_block(&$variables) { - if ($variables['block']-> module == 'book') { + if ($variables['configuration']['module'] == 'book') { $variables['attributes']['role'] = 'navigation'; } } diff --git a/core/modules/book/lib/Drupal/book/Tests/BookTest.php b/core/modules/book/lib/Drupal/book/Tests/BookTest.php index 4601342..1385126 100644 --- a/core/modules/book/lib/Drupal/book/Tests/BookTest.php +++ b/core/modules/book/lib/Drupal/book/Tests/BookTest.php @@ -338,7 +338,7 @@ function testBookNavigationBlock() { */ function testNavigationBlockOnAccessModuleEnabled() { $this->drupalLogin($this->admin_user); - $block = $this->drupalPlaceBlock('book_navigation', array(), array('block_mode' => 'book pages')); + $block = $this->drupalPlaceBlock('book_navigation', array('block_mode' => 'book pages')); // Give anonymous users the permission 'node test view'. $edit = array(); diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index 5690c72..dd2a38c 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -1559,7 +1559,7 @@ function comment_preview(Comment $comment) { * Implements hook_preprocess_HOOK() for block.tpl.php. */ function comment_preprocess_block(&$variables) { - if ($variables['block']->module == 'comment') { + if ($variables['configuration']['module'] == 'comment') { $variables['attributes']['role'] = 'navigation'; } } diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentBlockTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentBlockTest.php index 901d325..89f81b1 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentBlockTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentBlockTest.php @@ -46,7 +46,7 @@ public static function getInfo() { */ function testRecentCommentBlock() { $this->drupalLogin($this->admin_user); - $block = $this->drupalPlaceBlock('recent_comments', array(), array('block_count' => 2)); + $block = $this->drupalPlaceBlock('recent_comments', array('block_count' => 2)); // Add some test comments, one without a subject. $comment1 = $this->postComment($this->node, $this->randomName(), $this->randomName()); @@ -78,7 +78,7 @@ function testRecentCommentBlock() { $this->assertTrue(strpos($this->drupalGetContent(), $comment3->comment_body->value) < strpos($this->drupalGetContent(), $comment2->subject->value), 'Comments were ordered correctly in block.'); // Set the number of recent comments to show to 10. - $block->set('settings', array('block_count' => 10)); + $block->getPlugin()->setConfig('block_count', 10); $block->save(); // Post an additional comment. diff --git a/core/modules/forum/forum.module b/core/modules/forum/forum.module index eb2c1ec..a808f58 100644 --- a/core/modules/forum/forum.module +++ b/core/modules/forum/forum.module @@ -649,7 +649,8 @@ function forum_form_node_form_alter(&$form, &$form_state, $form_id) { * * This function can be used as a #pre_render callback. * - * @see forum_block_view() + * @see \Drupal\forum\Plugin\block\block\NewTopicsBlock::blockBuild() + * @see \Drupal\forum\Plugin\block\block\ActiveTopicsBlock::blockBuild() */ function forum_block_view_pre_render($elements) { $result = $elements['#query']->execute(); @@ -971,7 +972,7 @@ function forum_get_topics($tid, $sortby, $forum_per_page) { * Implements hook_preprocess_HOOK() for block.tpl.php. */ function forum_preprocess_block(&$variables) { - if ($variables['block']->module == 'forum') { + if ($variables['configuration']['module'] == 'forum') { $variables['attributes']['role'] = 'navigation'; } } diff --git a/core/modules/forum/lib/Drupal/forum/Tests/ForumBlockTest.php b/core/modules/forum/lib/Drupal/forum/Tests/ForumBlockTest.php index 02314e8..65dd7c2 100644 --- a/core/modules/forum/lib/Drupal/forum/Tests/ForumBlockTest.php +++ b/core/modules/forum/lib/Drupal/forum/Tests/ForumBlockTest.php @@ -71,7 +71,7 @@ public function testNewForumTopicsBlock() { } // Configure the new forum topics block to only show 2 topics. - $block->set('settings', array('block_count' => 2)); + $block->getPlugin()->setConfig('block_count', 2); $block->save(); $this->drupalGet(''); @@ -132,7 +132,7 @@ public function testActiveForumTopicsBlock() { } // Configure the active forum block to only show 2 topics. - $block->set('settings', array('block_count' => 2)); + $block->getPlugin()->setConfig('block_count', 2); $block->save(); $this->drupalGet(''); diff --git a/core/modules/help/help.module b/core/modules/help/help.module index aac8636..77109d5 100644 --- a/core/modules/help/help.module +++ b/core/modules/help/help.module @@ -71,7 +71,7 @@ function help_help($path, $arg) { * Implements hook_preprocess_HOOK() for block.tpl.php. */ function help_preprocess_block(&$variables) { - if ($variables['block']->id == 'system_help_block') { + if ($variables['plugin_id'] == 'system_help_block') { $variables['attributes']['role'] = 'complementary'; } } diff --git a/core/modules/language/language.module b/core/modules/language/language.module index 6bbb5a7..53d6ffe 100644 --- a/core/modules/language/language.module +++ b/core/modules/language/language.module @@ -763,7 +763,7 @@ function language_language_delete($language) { * Implements hook_preprocess_HOOK() for block.tpl.php. */ function language_preprocess_block(&$variables) { - if ($variables['block']->module == 'language') { + if ($variables['configuration']['module'] == 'language') { $variables['attributes']['role'] = 'navigation'; } } diff --git a/core/modules/menu/menu.module b/core/modules/menu/menu.module index d13655e..fa6aa53 100644 --- a/core/modules/menu/menu.module +++ b/core/modules/menu/menu.module @@ -12,7 +12,7 @@ */ use Drupal\Core\Entity\EntityInterface; -use Drupal\block\Plugin\Core\Entity\Block; +use Drupal\block\BlockInterface; use Drupal\system\Plugin\Core\Entity\Menu; use Drupal\system\Plugin\block\block\SystemMenuBlock; use Symfony\Component\HttpFoundation\JsonResponse; @@ -399,13 +399,13 @@ function _menu_parents_recurse($tree, $menu_name, $indent, &$options, $exclude, } /** - * Implements hook_block_view_alter(). + * Implements hook_block_view_NAME_alter() for 'system_menu_block'. */ -function menu_block_view_alter(array &$build, Block $block) { +function menu_block_view_system_menu_block_alter(array &$build, BlockInterface $block) { // Add contextual links for system menu blocks. - if ($block->getPlugin() instanceof SystemMenuBlock) { - foreach (element_children($build['content']) as $key) { - $build['#contextual_links']['menu'] = array('admin/structure/menu/manage', array($build['content'][$key]['#original_link']['menu_name'])); + if (isset($build['#content'])) { + foreach (element_children($build['#content']) as $key) { + $build['#content']['#contextual_links']['menu'] = array('admin/structure/menu/manage', array($build['#content'][$key]['#original_link']['menu_name'])); } } } @@ -717,7 +717,7 @@ function menu_get_menus($all = TRUE) { * Implements hook_preprocess_HOOK() for block.tpl.php. */ function menu_preprocess_block(&$variables) { - if ($variables['block']->module == 'menu') { + if ($variables['configuration']['module'] == 'menu') { $variables['attributes']['role'] = 'navigation'; } } diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeBlockFunctionalTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeBlockFunctionalTest.php index 3beb969..ea2f7b3 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeBlockFunctionalTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeBlockFunctionalTest.php @@ -61,7 +61,7 @@ public function testRecentNodeBlock() { )); // Enable the recent content block with two items. - $block = $this->drupalPlaceBlock('node_recent_block', array('machine_name' => 'test_block'), array('block_count' => 2)); + $block = $this->drupalPlaceBlock('node_recent_block', array('machine_name' => 'test_block', 'block_count' => 2)); // Test that block is not visible without nodes. $this->drupalGet(''); @@ -106,7 +106,7 @@ public function testRecentNodeBlock() { $this->drupalLogin($this->adminUser); // Set the number of recent nodes to show to 10. - $block->set('settings', array('block_count' => 10)); + $block->getPlugin()->setConfig('block_count', 10); $block->save(); // Post an additional node. @@ -132,8 +132,8 @@ public function testRecentNodeBlock() { ), ), )); - $visibility = $block->get('visibility'); - $this->assertTrue(isset($visibility['node_type']['types']['article']), 'Visibility settings were saved to configuration'); + $settings = $block->get('settings'); + $this->assertTrue(isset($settings['visibility']['node_type']['types']['article']), 'Visibility settings were saved to configuration'); // Create a page node. $node5 = $this->drupalCreateNode(array('uid' => $this->adminUser->uid, 'type' => 'page')); diff --git a/core/modules/node/node.module b/core/modules/node/node.module index f663387..b96f61f 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -1116,8 +1116,8 @@ function node_is_page(EntityInterface $node) { * Implements hook_preprocess_HOOK() for block.tpl.php. */ function node_preprocess_block(&$variables) { - if ($variables['block']->module == 'node') { - switch ($variables['block']->id) { + if ($variables['configuration']['module'] == 'node') { + switch ($variables['elements']['#plugin_id']) { case 'node_syndicate_block': $variables['attributes']['role'] = 'complementary'; break; diff --git a/core/modules/openid/openid.module b/core/modules/openid/openid.module index 0f2e04f..67b7070 100644 --- a/core/modules/openid/openid.module +++ b/core/modules/openid/openid.module @@ -6,6 +6,7 @@ */ use Guzzle\Http\Exception\RequestException; +use Drupal\block\BlockInterface; /** * Implements hook_menu(). @@ -160,23 +161,23 @@ function openid_user_logout($account) { } /** - * Implements hook_block_view_MODULE_DELTA_alter(). + * Implements hook_block_view_NAME_alter() for 'user_login_block'. * * Adds the OpenID login form to the user login block. * * @see \Drupal\user\Plugin\block\block\UserLoginBlock */ -function openid_block_view_user_login_block_alter(&$build, $block) { +function openid_block_view_user_login_block_alter(array &$build, BlockInterface $block) { // Only alter the block when it is non-empty, i.e. when no user is logged in. - if (!isset($build['content']['user_login_form'])) { + if (!isset($build['#content']['user_login_form'])) { return; } - $build['content']['openid_login_form'] = drupal_get_form('openid_login_form'); - $build['content']['openid_login_form']['openid_identifier']['#size'] = $build['content']['user_login_form']['name']['#size']; + $build['#content']['openid_login_form'] = drupal_get_form('openid_login_form'); + $build['#content']['openid_login_form']['openid_identifier']['#size'] = $build['#content']['user_login_form']['name']['#size']; // Put an OpenID link as a first element. - $build['content']['user_links']['#items'] = array( + $build['#content']['user_links']['#items'] = array( l(t('Log in using OpenID'), 'user/login/openid', array( 'attributes' => array( 'title' => t('Log in using OpenID.'), @@ -185,10 +186,10 @@ function openid_block_view_user_login_block_alter(&$build, $block) { 'tabindex' => 0, ), )) - ) + $build['content']['user_links']['#items']; + ) + $build['#content']['user_links']['#items']; // Move links under the openid form. - $build['content']['user_links']['#weight'] = 10; + $build['#content']['user_links']['#weight'] = 10; } /** diff --git a/core/modules/overlay/overlay.module b/core/modules/overlay/overlay.module index 446d56c..2e86a03 100644 --- a/core/modules/overlay/overlay.module +++ b/core/modules/overlay/overlay.module @@ -7,6 +7,8 @@ use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; +use Drupal\block\Plugin\Core\Entity\Block; +use Drupal\user\Plugin\Core\Entity\User; /** * Implements hook_help(). @@ -479,7 +481,7 @@ function theme_overlay_disable_message($variables) { /** * Implements hook_block_access(). */ -function overlay_block_access($block) { +function overlay_block_access(Block $block, $operation, User $account, $langcode) { // If we are limiting rendering to a subset of page regions, hide all blocks // which appear in regions not on that list. Note that overlay_page_alter() // does a more comprehensive job of preventing unwanted regions from being diff --git a/core/modules/search/search.module b/core/modules/search/search.module index 6dd68d9..0d9ba4a 100644 --- a/core/modules/search/search.module +++ b/core/modules/search/search.module @@ -134,10 +134,10 @@ function search_permission() { } /** - * Implements hook_preprocess_block(). + * Implements hook_preprocess_HOOK() for block.tpl.php. */ function search_preprocess_block(&$variables) { - if ($variables['block']->id == 'search_form_block') { + if ($variables['plugin_id'] == 'search_form_block') { $variables['attributes']['role'] = 'search'; $variables['content_attributes']['class'][] = 'container-inline'; } diff --git a/core/modules/shortcut/shortcut.module b/core/modules/shortcut/shortcut.module index 25a04c7..137f0c3 100644 --- a/core/modules/shortcut/shortcut.module +++ b/core/modules/shortcut/shortcut.module @@ -488,7 +488,7 @@ function shortcut_renderable_links($shortcut_set = NULL) { * Implements hook_preprocess_HOOK() for block.tpl.php. */ function shortcut_preprocess_block(&$variables) { - if ($variables['block']->module == 'shortcut') { + if ($variables['configuration']['module'] == 'shortcut') { $variables['attributes']['role'] = 'navigation'; } } diff --git a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php index a5c34b3..13cae13 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php @@ -341,8 +341,8 @@ protected function drupalCreateContentType($settings = array()) { * * @param string $plugin_id * The plugin ID of the block type for this block instance. - * @param array $values - * (optional) An associative array of values for the block entity. + * @param array $settings + * (optional) An associative array of settings for the block entity. * Override the defaults by specifying the key and value in the array, for * example: * @code @@ -355,8 +355,6 @@ protected function drupalCreateContentType($settings = array()) { * - machine_name: Random string. * - region: 'sidebar_first'. * - theme: The default theme. - * @param array $settings - * (optional) An associative array of plugin-specific settings. * * @return \Drupal\block\Plugin\Core\Entity\Block * The block entity. @@ -364,15 +362,19 @@ protected function drupalCreateContentType($settings = array()) { * @todo * Add support for creating custom block instances. */ - protected function drupalPlaceBlock($plugin_id, array $values = array(), array $settings = array()) { - $values += array( + protected function drupalPlaceBlock($plugin_id, array $settings = array()) { + $settings += array( 'plugin' => $plugin_id, - 'label' => $this->randomName(8), 'region' => 'sidebar_first', - 'theme' => config('system.theme')->get('default'), 'machine_name' => strtolower($this->randomName(8)), - 'settings' => $settings, + 'theme' => config('system.theme')->get('default'), + 'label' => $this->randomName(8), ); + foreach (array('region', 'machine_name', 'theme', 'plugin') as $key) { + $values[$key] = $settings[$key]; + unset($settings[$key]); + } + $values['settings'] = $settings; // Build the ID out of the theme and machine_name. $values['id'] = $values['theme'] . '.' . $values['machine_name']; $block = entity_create('block', $values); diff --git a/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsReportsTest.php b/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsReportsTest.php index ed14bb0..b897f99 100644 --- a/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsReportsTest.php +++ b/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsReportsTest.php @@ -41,7 +41,8 @@ function testPopularContentBlock() { $client->post($stats_path, $headers, $post)->send(); // Configure and save the block. - $this->drupalPlaceBlock('statistics_popular_block', array('label' => 'Popular content'), array( + $this->drupalPlaceBlock('statistics_popular_block', array( + 'label' => 'Popular content', 'top_day_num' => 3, 'top_all_num' => 3, 'top_last_num' => 3, diff --git a/core/modules/statistics/statistics.module b/core/modules/statistics/statistics.module index 66842a5..9d0c19e 100644 --- a/core/modules/statistics/statistics.module +++ b/core/modules/statistics/statistics.module @@ -237,7 +237,7 @@ function statistics_update_index() { * Implements hook_preprocess_HOOK() for block.tpl.php. */ function statistics_preprocess_block(&$variables) { - if ($variables['block']->module == 'statistics') { + if ($variables['configuration']['module'] == 'statistics') { $variables['attributes']['role'] = 'navigation'; } } diff --git a/core/modules/system/lib/Drupal/system/Tests/Upgrade/BlockUpgradePathTest.php b/core/modules/system/lib/Drupal/system/Tests/Upgrade/BlockUpgradePathTest.php index b9129e3..45f2efb 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Upgrade/BlockUpgradePathTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Upgrade/BlockUpgradePathTest.php @@ -42,16 +42,16 @@ public function testBlockUpgradeTitleLength() { // Add a block instance with a 255-character title. // Confirm that the custom block has been created, and title matches input. $settings = array( - 'label' => $this->randomName(255), + 'settings[label]' => $this->randomName(255), 'machine_name' => strtolower($this->randomName(8)), 'region' => 'sidebar_first', ); $this->drupalPost('admin/structure/block/add/system_powered_by_block/' . config('system.theme')->get('default'), $settings, t('Save block')); - $this->assertText($settings['label'], 'Block with title longer than 64 characters successfully created.'); + $this->assertText($settings['settings[label]'], 'Block with title longer than 64 characters successfully created.'); // Try to add a block with a title over 255 characters. $settings = array( - 'label' => $this->randomName(256), + 'settings[label]' => $this->randomName(256), 'machine_name' => strtolower($this->randomName(8)), 'region' => 'sidebar_first', ); diff --git a/core/modules/system/system.module b/core/modules/system/system.module index ebe5548..e5b428b 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -2674,20 +2674,18 @@ function system_user_timezone(&$form, &$form_state) { * Implements hook_preprocess_HOOK() for block.tpl.php. */ function system_preprocess_block(&$variables) { - switch ($variables['block']->id) { + // Derive the base plugin ID. + list($plugin_id) = explode(':', $variables['plugin_id'] . ':'); + switch ($plugin_id) { case 'system_powered_by_block': $variables['attributes_array']['role'] = 'complementary'; break; case 'system_help_block': $variables['attributes_array']['role'] = 'complementary'; break; - - // System menu blocks should get the same class as menu module blocks. - default: - if ($variables['elements']['#block']->getPlugin() instanceof SystemMenuBlock) { - $variables['attributes_array']['role'] = 'navigation'; - $variables['classes_array'][] = 'block-menu'; - } + case 'system_menu_block': + $variables['attributes_array']['role'] = 'navigation'; + $variables['classes_array'][] = 'block-menu'; } } diff --git a/core/modules/user/user.module b/core/modules/user/user.module index ead593b..04a45f5 100644 --- a/core/modules/user/user.module +++ b/core/modules/user/user.module @@ -671,8 +671,8 @@ function user_validate_current_pass(&$form, &$form_state) { * Implements hook_preprocess_HOOK() for block.tpl.php. */ function user_preprocess_block(&$variables) { - if ($variables['block']->module == 'user') { - switch ($variables['block']->id) { + if ($variables['configuration']['module'] == 'user') { + switch ($variables['elements']['#plugin_id']) { case 'user_login_block': $variables['attributes']['role'] = 'form'; break; diff --git a/core/modules/views/lib/Drupal/views/Plugin/block/block/ViewsBlock.php b/core/modules/views/lib/Drupal/views/Plugin/block/block/ViewsBlock.php index 6b87904..424ac1a 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/block/block/ViewsBlock.php +++ b/core/modules/views/lib/Drupal/views/Plugin/block/block/ViewsBlock.php @@ -8,7 +8,6 @@ namespace Drupal\views\Plugin\block\block; use Drupal\block\BlockBase; -use Drupal\block\Plugin\Core\Entity\Block; use Drupal\Component\Annotation\Plugin; use Drupal\Core\Annotation\Translation; @@ -41,8 +40,8 @@ class ViewsBlock extends BlockBase { /** * Overrides \Drupal\Component\Plugin\PluginBase::__construct(). */ - public function __construct(array $configuration, $plugin_id, array $plugin_definition, Block $entity) { - parent::__construct($configuration, $plugin_id, $plugin_definition, $entity); + public function __construct(array $configuration, $plugin_id, array $plugin_definition) { + parent::__construct($configuration, $plugin_id, $plugin_definition); list($plugin, $delta) = explode(':', $this->getPluginId()); list($name, $this->displayID) = explode('-', $delta, 2); @@ -76,7 +75,7 @@ public function form($form, &$form_state) { protected function blockBuild() { $output = $this->view->executeDisplay($this->displayID); // Set the label to the title configured in the view. - $this->entity->set('label', filter_xss_admin($this->view->getTitle())); + $this->configuration['label'] = filter_xss_admin($this->view->getTitle()); // Before returning the block output, convert it to a renderable array // with contextual links. $this->addContextualLinks($output); diff --git a/core/modules/views/views.module b/core/modules/views/views.module index 6636432..ebaf1b5 100644 --- a/core/modules/views/views.module +++ b/core/modules/views/views.module @@ -560,7 +560,7 @@ function views_contextual_links_view_alter(&$element, $items) { * @param $display_id * The ID of the display within $view whose contextual links will be added. * - * @see views_block_view() + * @see \Drupal\views\Plugin\block\block\ViewsBlock::addContextualLinks() * @see views_page_alter() * @see template_preprocess_views_view() */ diff --git a/core/profiles/minimal/config/block.block.stark.admin.yml b/core/profiles/minimal/config/block.block.stark.admin.yml index e84cdbe..d16ae8b 100644 --- a/core/profiles/minimal/config/block.block.stark.admin.yml +++ b/core/profiles/minimal/config/block.block.stark.admin.yml @@ -1,19 +1,19 @@ id: stark.admin -label: Administration region: sidebar_first -weight: '1' -module: system -status: '1' -visibility: - path: - visibility: '0' - pages: '' - role: - roles: { } - node_type: - types: { } - visibility__active_tab: edit-visibility-path plugin: 'system_menu_block:menu-admin' settings: + label: Administration + weight: '1' + module: system + status: '1' + visibility: + path: + visibility: '0' + pages: '' + role: + roles: { } + node_type: + types: { } + visibility__active_tab: edit-visibility-path cache: '-1' -label_display: visible + label_display: visible diff --git a/core/profiles/minimal/config/block.block.stark.login.yml b/core/profiles/minimal/config/block.block.stark.login.yml index ba8a66d..17a4e1d 100644 --- a/core/profiles/minimal/config/block.block.stark.login.yml +++ b/core/profiles/minimal/config/block.block.stark.login.yml @@ -1,19 +1,19 @@ id: stark.login -label: 'User login' region: sidebar_first -weight: '0' -module: user -status: '1' -visibility: - path: - visibility: '0' - pages: '' - role: - roles: { } - node_type: - types: { } - visibility__active_tab: edit-visibility-path plugin: user_login_block settings: + label: 'User login' + weight: '0' + module: user + status: '1' + visibility: + path: + visibility: '0' + pages: '' + role: + roles: { } + node_type: + types: { } + visibility__active_tab: edit-visibility-path cache: '-1' -label_display: visible + label_display: visible diff --git a/core/profiles/minimal/config/block.block.stark.tools.yml b/core/profiles/minimal/config/block.block.stark.tools.yml index dda5b98..cccbb5e 100644 --- a/core/profiles/minimal/config/block.block.stark.tools.yml +++ b/core/profiles/minimal/config/block.block.stark.tools.yml @@ -1,19 +1,19 @@ id: stark.tools -label: Tools region: sidebar_first -weight: '0' -module: system -status: '1' -visibility: - path: - visibility: '0' - pages: '' - role: - roles: { } - node_type: - types: { } - visibility__active_tab: edit-visibility-path plugin: 'system_menu_block:menu-tools' settings: + label: Tools + weight: '0' + module: system + status: '1' + visibility: + path: + visibility: '0' + pages: '' + role: + roles: { } + node_type: + types: { } + visibility__active_tab: edit-visibility-path cache: '-1' -label_display: visible + label_display: visible diff --git a/core/profiles/standard/config/block.block.bartik.content.yml b/core/profiles/standard/config/block.block.bartik.content.yml index 07c3cdd..c389bb4 100644 --- a/core/profiles/standard/config/block.block.bartik.content.yml +++ b/core/profiles/standard/config/block.block.bartik.content.yml @@ -1,22 +1,22 @@ id: bartik.content +region: content +langcode: en plugin: system_main_block -status: '1' settings: + status: '1' cache: '-1' -visibility: - path: - visibility: '0' - pages: '' - role: - roles: { } - node_type: - types: - article: '0' - page: '0' - visibility__active_tab: edit-visibility-path -label: '' -module: system -region: content -weight: '0' -langcode: en -label_display: visible + visibility: + path: + visibility: '0' + pages: '' + role: + roles: { } + node_type: + types: + article: '0' + page: '0' + visibility__active_tab: edit-visibility-path + label: '' + module: system + weight: '0' + label_display: visible diff --git a/core/profiles/standard/config/block.block.bartik.footer.yml b/core/profiles/standard/config/block.block.bartik.footer.yml index 553edb7..c8ff530 100644 --- a/core/profiles/standard/config/block.block.bartik.footer.yml +++ b/core/profiles/standard/config/block.block.bartik.footer.yml @@ -1,22 +1,22 @@ id: bartik.footer +region: footer plugin: 'system_menu_block:menu-footer' -status: '1' +langcode: en settings: cache: '-1' -label: 'Footer menu' -visibility: - path: - visibility: '0' - pages: '' - role: - roles: { } - node_type: - types: - article: '0' - page: '0' - visibility__active_tab: edit-visibility-path -module: system -region: footer -weight: '0' -langcode: en -label_display: visible + label: 'Footer menu' + status: '1' + visibility: + path: + visibility: '0' + pages: '' + role: + roles: { } + node_type: + types: + article: '0' + page: '0' + visibility__active_tab: edit-visibility-path + module: system + weight: '0' + label_display: visible diff --git a/core/profiles/standard/config/block.block.bartik.help.yml b/core/profiles/standard/config/block.block.bartik.help.yml index 84395a6..bf8abb5 100644 --- a/core/profiles/standard/config/block.block.bartik.help.yml +++ b/core/profiles/standard/config/block.block.bartik.help.yml @@ -1,22 +1,22 @@ id: bartik.help +region: help plugin: system_help_block -status: '1' +langcode: en settings: cache: '-1' -visibility: - path: - visibility: '0' - pages: '' - role: - roles: { } - node_type: - types: - article: '0' - page: '0' - visibility__active_tab: edit-visibility-path -label: '' -module: system -region: help -weight: '0' -langcode: en -label_display: visible + status: '1' + visibility: + path: + visibility: '0' + pages: '' + role: + roles: { } + node_type: + types: + article: '0' + page: '0' + visibility__active_tab: edit-visibility-path + label: '' + module: system + weight: '0' + label_display: visible diff --git a/core/profiles/standard/config/block.block.bartik.login.yml b/core/profiles/standard/config/block.block.bartik.login.yml index aac6997..988234b 100644 --- a/core/profiles/standard/config/block.block.bartik.login.yml +++ b/core/profiles/standard/config/block.block.bartik.login.yml @@ -1,23 +1,23 @@ id: bartik.login -whois_new_count: '5' -status: '1' settings: + whois_new_count: '5' + status: '1' cache: '-1' -visibility: - path: - visibility: '0' - pages: '' - role: - roles: { } - node_type: - types: - article: '0' - page: '0' - visibility__active_tab: edit-visibility-path -label: 'User login' -module: user + visibility: + path: + visibility: '0' + pages: '' + role: + roles: { } + node_type: + types: + article: '0' + page: '0' + visibility__active_tab: edit-visibility-path + label: 'User login' + module: user + weight: '0' + label_display: visible region: sidebar_first -weight: '0' plugin: user_login_block langcode: en -label_display: visible diff --git a/core/profiles/standard/config/block.block.bartik.powered.yml b/core/profiles/standard/config/block.block.bartik.powered.yml index 48424f8..c6a3739 100644 --- a/core/profiles/standard/config/block.block.bartik.powered.yml +++ b/core/profiles/standard/config/block.block.bartik.powered.yml @@ -1,22 +1,22 @@ id: bartik.powered +region: footer plugin: system_powered_by_block -status: '1' +langcode: en settings: + status: '1' cache: '-1' -visibility: - path: - visibility: '0' - pages: '' - role: - roles: { } - node_type: - types: - article: '0' - page: '0' - visibility__active_tab: edit-visibility-path -label: '' -module: system -region: footer -weight: '10' -langcode: en -label_display: visible + visibility: + path: + visibility: '0' + pages: '' + role: + roles: { } + node_type: + types: + article: '0' + page: '0' + visibility__active_tab: edit-visibility-path + label: '' + module: system + weight: '10' + label_display: visible diff --git a/core/profiles/standard/config/block.block.bartik.search.yml b/core/profiles/standard/config/block.block.bartik.search.yml index bcf0249..22f7c23 100644 --- a/core/profiles/standard/config/block.block.bartik.search.yml +++ b/core/profiles/standard/config/block.block.bartik.search.yml @@ -1,22 +1,22 @@ id: bartik.search +region: sidebar_first plugin: search_form_block -status: '1' +langcode: en settings: cache: '-1' -visibility: - path: - visibility: '0' - pages: '' - role: - roles: { } - node_type: - types: - article: '0' - page: '0' - visibility__active_tab: edit-visibility-path -label: 'Search' -module: search -region: sidebar_first -weight: '-1' -langcode: en -label_display: visible + status: '1' + visibility: + path: + visibility: '0' + pages: '' + role: + roles: { } + node_type: + types: + article: '0' + page: '0' + visibility__active_tab: edit-visibility-path + label: 'Search' + module: search + weight: '-1' + label_display: visible diff --git a/core/profiles/standard/config/block.block.bartik.tools.yml b/core/profiles/standard/config/block.block.bartik.tools.yml index 56c8ba4..c56d80f 100644 --- a/core/profiles/standard/config/block.block.bartik.tools.yml +++ b/core/profiles/standard/config/block.block.bartik.tools.yml @@ -1,22 +1,22 @@ id: bartik.tools +region: sidebar_first plugin: 'system_menu_block:menu-tools' -status: '1' +langcode: en settings: cache: '-1' -visibility: - path: - visibility: '0' - pages: '' - role: - roles: { } - node_type: - types: - article: '0' - page: '0' - visibility__active_tab: edit-visibility-path -label: 'Tools' -module: system -region: sidebar_first -weight: '0' -langcode: en -label_display: visible + status: '1' + visibility: + path: + visibility: '0' + pages: '' + role: + roles: { } + node_type: + types: + article: '0' + page: '0' + visibility__active_tab: edit-visibility-path + label: 'Tools' + module: system + weight: '0' + label_display: visible diff --git a/core/profiles/standard/config/block.block.seven.content.yml b/core/profiles/standard/config/block.block.seven.content.yml index f14f147..7c4b669 100644 --- a/core/profiles/standard/config/block.block.seven.content.yml +++ b/core/profiles/standard/config/block.block.seven.content.yml @@ -1,22 +1,22 @@ id: seven.content +region: content plugin: system_main_block -status: '1' +langcode: en settings: cache: '-1' -visibility: - path: - visibility: '0' - pages: '' - role: - roles: { } - node_type: - types: - article: '0' - page: '0' - visibility__active_tab: edit-visibility-path -label: '' -module: system -region: content -weight: '0' -langcode: en -label_display: visible + status: '1' + visibility: + path: + visibility: '0' + pages: '' + role: + roles: { } + node_type: + types: + article: '0' + page: '0' + visibility__active_tab: edit-visibility-path + label: '' + module: system + weight: '0' + label_display: visible diff --git a/core/profiles/standard/config/block.block.seven.help.yml b/core/profiles/standard/config/block.block.seven.help.yml index 075f518..b337339 100644 --- a/core/profiles/standard/config/block.block.seven.help.yml +++ b/core/profiles/standard/config/block.block.seven.help.yml @@ -1,22 +1,22 @@ id: seven.help +region: help plugin: system_help_block -status: '1' +langcode: en settings: cache: '-1' -visibility: - path: - visibility: '0' - pages: '' - role: - roles: { } - node_type: - types: - article: '0' - page: '0' - visibility__active_tab: edit-visibility-path -label: '' -module: system -region: help -weight: '0' -langcode: en -label_display: visible + status: '1' + visibility: + path: + visibility: '0' + pages: '' + role: + roles: { } + node_type: + types: + article: '0' + page: '0' + visibility__active_tab: edit-visibility-path + label: '' + module: system + weight: '0' + label_display: visible diff --git a/core/profiles/standard/config/block.block.seven.login.yml b/core/profiles/standard/config/block.block.seven.login.yml index f0fb2b2..dd8d4d8 100644 --- a/core/profiles/standard/config/block.block.seven.login.yml +++ b/core/profiles/standard/config/block.block.seven.login.yml @@ -1,22 +1,22 @@ id: seven.login +region: content plugin: user_login_block -status: '1' settings: cache: '-1' -visibility: - path: - visibility: '0' - pages: '' - role: - roles: { } - node_type: - types: - article: '0' - page: '0' - visibility__active_tab: edit-visibility-path -label: 'User login' -module: user -region: content -weight: '10' -langcode: en -label_display: visible + status: '1' + visibility: + path: + visibility: '0' + pages: '' + role: + roles: { } + node_type: + types: + article: '0' + page: '0' + visibility__active_tab: edit-visibility-path + label: 'User login' + module: user + weight: '10' + langcode: en + label_display: visible