diff --git a/core/modules/block/lib/Drupal/block/BlockAccessController.php b/core/modules/block/lib/Drupal/block/BlockAccessController.php index 253cbe4..7761f4b 100644 --- a/core/modules/block/lib/Drupal/block/BlockAccessController.php +++ b/core/modules/block/lib/Drupal/block/BlockAccessController.php @@ -28,7 +28,68 @@ public function viewAccess(EntityInterface $entity, $langcode = LANGUAGE_DEFAULT $access = $this->access($entity, 'view', $langcode, $account); if ($access !== FALSE) { // If entity access did not explicitly deny access, consult the plugin. - return $entity->getPlugin()->access(); + 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 645fcd5..e31ff82 100644 --- a/core/modules/block/lib/Drupal/block/BlockBase.php +++ b/core/modules/block/lib/Drupal/block/BlockBase.php @@ -23,12 +23,10 @@ public function __construct(array $configuration, $plugin_id, array $plugin_defi parent::__construct($configuration, $plugin_id, $plugin_definition); $this->configuration += $this->settings() + array( - 'label' => '', - 'admin_label' => $plugin_definition['admin_label'], + 'label' => $plugin_definition['admin_label'], 'weight' => '', 'module' => $plugin_definition['module'], 'label_display' => BLOCK_LABEL_VISIBLE, - 'visibility' => array(), 'cache' => DRUPAL_NO_CACHE, 'status' => TRUE, ); @@ -124,68 +122,11 @@ public function access() { return FALSE; } - // Otherwise, check for other access restrictions. - global $user; - // Deny access to disabled blocks. if (!$this->configuration['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->configuration['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; - } - } - // Check other modules for block access rules. foreach (module_implements('block_plugin_access') as $module) { if (module_invoke($module, 'block_plugin_access', $this) === FALSE) { @@ -218,7 +159,7 @@ public function form($form, &$form_state) { '#type' => 'textfield', '#title' => t('Title'), '#maxlength' => 255, - '#default_value' => !empty($this->configuration['label']) ? $this->configuration['label'] : $this->configuration['admin_label'], + '#default_value' => $this->configuration['label'], '#required' => TRUE, ); $form['label_display'] = array( @@ -228,130 +169,6 @@ public function form($form, &$form_state) { '#return_value' => BLOCK_LABEL_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, - '#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 = $this->configuration['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 += $this->blockForm($form, $form_state); return $form; @@ -388,12 +205,6 @@ public function blockForm($form, &$form_state) { * @see \Drupal\block\BlockBase::blockValidate() */ public function validate($form, &$form_state) { - // @todo The final location of visibility is unresolved. This moves the - // values into the plugin settings, out of the entity values. - $form_state['values']['settings']['visibility'] = $form_state['values']['visibility']; - unset($form_state['values']['visibility']); - - $form_state['values']['settings']['visibility']['role']['roles'] = array_filter($form_state['values']['settings']['visibility']['role']['roles']); $this->blockValidate($form, $form_state); } @@ -427,8 +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); - $this->configuration = $form_state['values']['settings'] + $this->configuration; } } @@ -463,6 +276,7 @@ public function build() { '#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); diff --git a/core/modules/block/lib/Drupal/block/BlockFormController.php b/core/modules/block/lib/Drupal/block/BlockFormController.php index 6f95259..9f3a13a 100644 --- a/core/modules/block/lib/Drupal/block/BlockFormController.php +++ b/core/modules/block/lib/Drupal/block/BlockFormController.php @@ -41,6 +41,130 @@ public function form(array $form, array &$form_state, EntityInterface $entity) { '#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', @@ -76,7 +200,10 @@ public function validate(array $form, array &$form_state) { $config_id = explode('.', $form_state['values']['machine_name']); $form_state['values']['machine_name'] = array_pop($config_id); } - $entity->getPlugin()->validate($form, $form_state); + $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); } /** @@ -87,7 +214,9 @@ 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->save(); 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 40390a4..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 @@ -88,6 +88,13 @@ class Block extends ConfigEntityBase { protected $pluginBag; /** + * The visibility settings. + * + * @var array + */ + protected $visibility; + + /** * Overrides \Drupal\Core\Config\Entity\ConfigEntityBase::__construct(); */ public function __construct(array $values, $entity_type) { @@ -148,6 +155,7 @@ public function getExportProperties() { 'region', 'plugin', 'settings', + 'visibility', ); foreach ($names as $name) { $properties[$name] = $this->get($name); diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockInterfaceTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockInterfaceTest.php index ad4c9a3..19e7d0f 100644 --- a/core/modules/block/lib/Drupal/block/Tests/BlockInterfaceTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/BlockInterfaceTest.php @@ -50,13 +50,9 @@ public function testBlockInterface() { $expected_configuration = array( 'label' => 'Custom Display Message', 'display_message' => 'no message set', - 'admin_label' => 'Display message', 'weight' => '', 'module' => 'block_test', 'label_display' => BLOCK_LABEL_VISIBLE, - 'visibility' => - array ( - ), 'cache' => DRUPAL_NO_CACHE, 'status' => TRUE, ); @@ -87,58 +83,6 @@ public function testBlockInterface() { '#default_value' => TRUE, '#return_value' => 'visible', ), - 'visibility' => array( - '#type' => 'vertical_tabs', - '#title' => 'Visibility settings', - '#attached' => array( - 'js' => array( - 0 => 'core/modules/block/block.js', - ), - ), - '#tree' => TRUE, - '#weight' => 10, - '#parents' => array( - 0 => 'visibility', - ), - 'path' => array( - '#type' => 'details', - '#title' => 'Pages', - '#collapsed' => TRUE, - '#group' => 'visibility', - '#weight' => 0, - 'visibility' => array( - '#type' => 'radios', - '#title' => 'Show block on specific pages', - '#options' => array( - 0 => 'All pages except those listed', - 1 => 'Only the listed pages', - ), - '#default_value' => 0, - ), - 'pages' => array( - '#type' => 'textarea', - '#title' => 'Pages', - '#default_value' => '', - '#description' => '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/* for every user page. <front> is the front page.', - ), - ), - 'role' => array( - '#type' => 'details', - '#title' => 'Roles', - '#collapsed' => TRUE, - '#group' => 'visibility', - '#weight' => 10, - 'roles' => array( - '#type' => 'checkboxes', - '#title' => 'Show block for specific roles', - '#default_value' => array( - ), - '#options' => array( - ), - '#description' => 'Show this block only for the selected role(s). If you select no roles, the block will be visible to all users.', - ), - ), - ), 'display_message' => array( '#type' => 'textfield', '#title' => t('Display message'), @@ -151,19 +95,15 @@ public function testBlockInterface() { $expected_build = array( '#theme' => 'block', - '#content' => array( + 'content' => array( '#children' => 'My custom display message.', ), '#configuration' => array( 'label' => 'Custom Display Message', 'display_message' => 'My custom display message.', - 'admin_label' => 'Display message', 'weight' => '', 'module' => 'block_test', 'label_display' => BLOCK_LABEL_VISIBLE, - 'visibility' => - array ( - ), 'cache' => DRUPAL_NO_CACHE, 'status' => TRUE, ), diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockStorageUnitTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockStorageUnitTest.php index 8fda7f8..b18c9ba 100644 --- a/core/modules/block/lib/Drupal/block/Tests/BlockStorageUnitTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/BlockStorageUnitTest.php @@ -100,14 +100,13 @@ protected function createTests() { 'plugin' => 'test_html_id', 'settings' => array( 'cache' => '1', - 'label' => '', - 'admin_label' => t('Test block html id'), + 'label' => t('Test block html id'), 'weight' => '', 'module' => 'block_test', 'label_display' => BLOCK_LABEL_VISIBLE, - 'visibility' => array(), 'status' => '1', ), + 'visibility' => '', ); $this->assertIdentical($actual_properties, $expected_properties, 'The block properties are exported correctly.'); @@ -139,9 +138,11 @@ protected function renderTests() { $output = entity_view($entity, 'block'); $expected = array(); $expected[] = '
'; - $expected[] = ' '; - $expected[] = '
'; - $expected[] = '
'; + $expected[] = ''; + $expected[] = '

Test block html id

'; + $expected[] = ' '; + $expected[] = '
'; + $expected[] = '
'; $expected[] = '
'; $expected[] = ''; $expected_output = implode("\n", $expected); @@ -162,10 +163,11 @@ protected function renderTests() { $output = entity_view($entity, 'block'); $expected = array(); $expected[] = '
'; - $expected[] = '

Powered by Bananas

'; $expected[] = ''; - $expected[] = '
'; - $expected[] = '
'; + $expected[] = '

Powered by Bananas

'; + $expected[] = ' '; + $expected[] = '
'; + $expected[] = '
'; $expected[] = '
'; $expected[] = ''; $expected_output = implode("\n", $expected); 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/node/node.module b/core/modules/node/node.module index 2c176bd..b96f61f 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -1998,14 +1998,14 @@ function theme_node_recent_content($variables) { function node_form_block_form_alter(&$form, &$form_state) { $block = $form_state['entity']; $visibility = $block->get('visibility'); - $form['settings']['visibility']['node_type'] = array( + $form['visibility']['node_type'] = array( '#type' => 'details', '#title' => t('Content types'), '#collapsed' => TRUE, '#group' => 'visibility', '#weight' => 5, ); - $form['settings']['visibility']['node_type']['types'] = array( + $form['visibility']['node_type']['types'] = array( '#type' => 'checkboxes', '#title' => t('Show block for specific content types'), '#default_value' => !empty($visibility['node_type']['types']) ? $visibility['node_type']['types'] : array(), @@ -2021,8 +2021,7 @@ function node_form_block_form_alter(&$form, &$form_state) { * if the visibility conditions are not met. */ function node_block_access($block) { - $settings = $block->get('settings'); - $visibility = $settings['visibility']; + $visibility = $block->get('visibility'); if (!empty($visibility)) { $allowed_types = array(); $node = menu_get_object();