Commit 65b155d9 authored by Dries's avatar Dries

Issue #1199946 by alexpott, fubhy, bojanz, steinmb, chx, catch: Fixed Disabled...

Issue #1199946 by alexpott, fubhy, bojanz, steinmb, chx, catch: Fixed Disabled modules are broken beyond repair so the 'disable' functionality needs to be removed.
parent 6b7bdcdd
...@@ -86,8 +86,10 @@ function entity_invoke_bundle_hook($hook, $entity_type, $bundle, $bundle_new = N ...@@ -86,8 +86,10 @@ function entity_invoke_bundle_hook($hook, $entity_type, $bundle, $bundle_new = N
// Notify the entity storage controller. // Notify the entity storage controller.
$method = 'onBundle' . ucfirst($hook); $method = 'onBundle' . ucfirst($hook);
\Drupal::entityManager()->getStorageController($entity_type)->$method($bundle, $bundle_new); $storage_controller = \Drupal::entityManager()->getStorageController($entity_type);
if (method_exists($storage_controller, $method)) {
$storage_controller->$method($bundle, $bundle_new);
}
// Invoke hook_entity_bundle_*() hooks. // Invoke hook_entity_bundle_*() hooks.
\Drupal::moduleHandler()->invokeAll('entity_bundle_' . $hook, array($entity_type, $bundle, $bundle_new)); \Drupal::moduleHandler()->invokeAll('entity_bundle_' . $hook, array($entity_type, $bundle, $bundle_new));
} }
......
...@@ -995,7 +995,7 @@ function install_base_system(&$install_state) { ...@@ -995,7 +995,7 @@ function install_base_system(&$install_state) {
// Enable the user module so that sessions can be recorded during the // Enable the user module so that sessions can be recorded during the
// upcoming bootstrap step. // upcoming bootstrap step.
module_enable(array('user'), FALSE); Drupal::moduleHandler()->install(array('user'), FALSE);
// Save the list of other modules to install for the upcoming tasks. // Save the list of other modules to install for the upcoming tasks.
// variable_set() can be used now that system.module is installed. // variable_set() can be used now that system.module is installed.
...@@ -2037,7 +2037,7 @@ function _install_module_batch($module, $module_name, &$context) { ...@@ -2037,7 +2037,7 @@ function _install_module_batch($module, $module_name, &$context) {
// loaded by drupal_bootstrap in subsequent batch requests, and other // loaded by drupal_bootstrap in subsequent batch requests, and other
// modules possibly depending on it can safely perform their installation // modules possibly depending on it can safely perform their installation
// steps. // steps.
module_enable(array($module), FALSE); Drupal::moduleHandler()->install(array($module), FALSE);
$context['results'][] = $module; $context['results'][] = $module;
$context['message'] = t('Installed %module module.', array('%module' => $module_name)); $context['message'] = t('Installed %module module.', array('%module' => $module_name));
} }
...@@ -2529,7 +2529,7 @@ function install_configure_form_submit($form, &$form_state) { ...@@ -2529,7 +2529,7 @@ function install_configure_form_submit($form, &$form_state) {
// Enable update.module if this option was selected. // Enable update.module if this option was selected.
if ($form_state['values']['update_status_module'][1]) { if ($form_state['values']['update_status_module'][1]) {
module_enable(array('file', 'update'), FALSE); Drupal::moduleHandler()->install(array('file', 'update'), FALSE);
// Add the site maintenance account's email address to the list of // Add the site maintenance account's email address to the list of
// addresses to be notified when updates are available, if selected. // addresses to be notified when updates are available, if selected.
......
...@@ -203,8 +203,9 @@ function language_types_disable($types) { ...@@ -203,8 +203,9 @@ function language_types_disable($types) {
*/ */
function language_types_set(array $configurable_language_types) { function language_types_set(array $configurable_language_types) {
// Ensure that we are getting the defined language negotiation information. An // Ensure that we are getting the defined language negotiation information. An
// invocation of module_enable() or module_disable() could outdate the cached // invocation of \Drupal\Core\Extension\ModuleHandler::install() or
// information. // \Drupal\Core\Extension\ModuleHandler::uninstall() could invalidate the
// cached information.
drupal_static_reset('language_types_info'); drupal_static_reset('language_types_info');
drupal_static_reset('language_negotiation_info'); drupal_static_reset('language_negotiation_info');
...@@ -343,8 +344,9 @@ function language_negotiation_get_switch_links($type, $path) { ...@@ -343,8 +344,9 @@ function language_negotiation_get_switch_links($type, $path) {
*/ */
function language_negotiation_purge() { function language_negotiation_purge() {
// Ensure that we are getting the defined language negotiation information. An // Ensure that we are getting the defined language negotiation information. An
// invocation of module_enable() or module_disable() could outdate the cached // invocation of \Drupal\Core\Extension\ModuleHandler::install() or
// information. // \Drupal\Core\Extension\ModuleHandler::uninstall() could invalidate the
// cached information.
drupal_static_reset('language_negotiation_info'); drupal_static_reset('language_negotiation_info');
drupal_static_reset('language_types_info'); drupal_static_reset('language_types_info');
......
...@@ -201,32 +201,21 @@ function module_load_include($type, $module, $name = NULL) { ...@@ -201,32 +201,21 @@ function module_load_include($type, $module, $name = NULL) {
return FALSE; return FALSE;
} }
/**
* Enables or installs a given list of modules.
*
* @deprecated as of Drupal 8.0. Use
* \Drupal::moduleHandler()->enable($module_list, $enable_dependencies = TRUE).
*/
function module_enable($module_list, $enable_dependencies = TRUE) {
return \Drupal::moduleHandler()->enable($module_list, $enable_dependencies);
}
/** /**
* Disables a given set of modules. * Installs a given list of modules.
* *
* @deprecated as of Drupal 8.0. Use * @deprecated as of Drupal 8.0. Use
* \Drupal::moduleHandler()->disable($module_list, $disable_dependents = TRUE). * \Drupal::moduleHandler()->install($module_list, $enable_dependencies = TRUE)
*/ */
function module_disable($module_list, $disable_dependents = TRUE) { function module_install($module_list, $enable_dependencies = TRUE) {
\Drupal::moduleHandler()->disable($module_list, $disable_dependents); return \Drupal::moduleHandler()->install($module_list, $enable_dependencies);
} }
/** /**
* Uninstalls a given list of disabled modules. * Installs a given list of modules.
* *
* @deprecated as of Drupal 8.0. Use * @deprecated as of Drupal 8.0. Use
* \Drupal::moduleHandler()->uninstall($module_list, $uninstall_dependents = TRUE). * \Drupal::moduleHandler()->install($module_list, $enable_dependencies = TRUE).
*/ */
function module_uninstall($module_list = array(), $uninstall_dependents = TRUE) { function module_uninstall($module_list = array(), $uninstall_dependents = TRUE) {
return \Drupal::moduleHandler()->uninstall($module_list, $uninstall_dependents); return \Drupal::moduleHandler()->uninstall($module_list, $uninstall_dependents);
...@@ -332,7 +321,7 @@ function module_set_weight($module, $weight) { ...@@ -332,7 +321,7 @@ function module_set_weight($module, $weight) {
->save(); ->save();
// Prepare the new module list, sorted by weight, including filenames. // Prepare the new module list, sorted by weight, including filenames.
// @see module_enable() // @see Drupal\Core\Extension\ModuleHandler::install()
$module_handler = \Drupal::moduleHandler(); $module_handler = \Drupal::moduleHandler();
$current_module_filenames = $module_handler->getModuleList(); $current_module_filenames = $module_handler->getModuleList();
$current_modules = array_fill_keys(array_keys($current_module_filenames), 0); $current_modules = array_fill_keys(array_keys($current_module_filenames), 0);
...@@ -345,13 +334,6 @@ function module_set_weight($module, $weight) { ...@@ -345,13 +334,6 @@ function module_set_weight($module, $weight) {
$module_handler->setModuleList($module_filenames); $module_handler->setModuleList($module_filenames);
return; return;
} }
$disabled_config = \Drupal::config('system.module.disabled');
if ($disabled_config->get($module) !== NULL) {
$disabled_config
->set($module, $weight)
->save();
return;
}
} }
/** /**
......
...@@ -335,7 +335,6 @@ function update_prepare_d8_bootstrap() { ...@@ -335,7 +335,6 @@ function update_prepare_d8_bootstrap() {
} }
$module_config = \Drupal::config('system.module'); $module_config = \Drupal::config('system.module');
$disabled_modules = \Drupal::config('system.module.disabled');
$theme_config = \Drupal::config('system.theme'); $theme_config = \Drupal::config('system.theme');
$disabled_themes = \Drupal::config('system.theme.disabled'); $disabled_themes = \Drupal::config('system.theme.disabled');
$schema_store = \Drupal::keyValue('system.schema'); $schema_store = \Drupal::keyValue('system.schema');
...@@ -378,9 +377,6 @@ function update_prepare_d8_bootstrap() { ...@@ -378,9 +377,6 @@ function update_prepare_d8_bootstrap() {
if ($record->status && isset($module_data[$record->name])) { if ($record->status && isset($module_data[$record->name])) {
$module_config->set('enabled.' . $record->name, $record->weight); $module_config->set('enabled.' . $record->name, $record->weight);
} }
else {
$disabled_modules->set($record->name, $record->weight);
}
} }
elseif ($record->type == 'theme') { elseif ($record->type == 'theme') {
if ($record->status) { if ($record->status) {
...@@ -399,7 +395,6 @@ function update_prepare_d8_bootstrap() { ...@@ -399,7 +395,6 @@ function update_prepare_d8_bootstrap() {
$sorted_with_filenames[$m] = drupal_get_filename('module', $m); $sorted_with_filenames[$m] = drupal_get_filename('module', $m);
} }
\Drupal::moduleHandler()->setModuleList($sorted_with_filenames); \Drupal::moduleHandler()->setModuleList($sorted_with_filenames);
$disabled_modules->save();
$theme_config->save(); $theme_config->save();
$disabled_themes->save(); $disabled_themes->save();
...@@ -490,8 +485,7 @@ function update_prepare_stored_includes() { ...@@ -490,8 +485,7 @@ function update_prepare_stored_includes() {
*/ */
function update_prepare_d8_language() { function update_prepare_d8_language() {
if (db_table_exists('languages')) { if (db_table_exists('languages')) {
Drupal::moduleHandler()->install(array('language'));
module_enable(array('language'));
$languages = db_select('languages', 'l') $languages = db_select('languages', 'l')
->fields('l') ->fields('l')
...@@ -683,7 +677,7 @@ function update_fix_d8_requirements() { ...@@ -683,7 +677,7 @@ function update_fix_d8_requirements() {
// Make sure that file.module is enabled as it is required for the user // Make sure that file.module is enabled as it is required for the user
// picture upgrade path. // picture upgrade path.
module_enable(array('file')); Drupal::moduleHandler()->install(array('file'));
$schema = array( $schema = array(
'description' => 'Generic key/value storage table with an expiration.', 'description' => 'Generic key/value storage table with an expiration.',
...@@ -727,8 +721,8 @@ function update_fix_d8_requirements() { ...@@ -727,8 +721,8 @@ function update_fix_d8_requirements() {
// views configurations. // views configurations.
// Like any other module APIs and services, Views' services are not available // Like any other module APIs and services, Views' services are not available
// in update.php. Existing listings are migrated into configuration, using // in update.php. Existing listings are migrated into configuration, using
// the limited standard tools of raw database queries and \Drupal::config(). // the limited standard tools of raw database queries and Drupal::config().
module_enable(array('views')); \Drupal::moduleHandler()->install(array('views'));
update_variable_set('update_d8_requirements', TRUE); update_variable_set('update_d8_requirements', TRUE);
} }
......
...@@ -253,77 +253,50 @@ public function invokeAll($hook, $args = array()); ...@@ -253,77 +253,50 @@ public function invokeAll($hook, $args = array());
public function alter($type, &$data, &$context1 = NULL, &$context2 = NULL); public function alter($type, &$data, &$context1 = NULL, &$context2 = NULL);
/** /**
* Enables or installs a given list of modules. * Installs a given list of modules.
*
* Definitions:
* - "Enabling" is the process of activating a module for use by Drupal.
* - "Disabling" is the process of deactivating a module.
* - "Installing" is the process of enabling it for the first time or after it
* has been uninstalled.
* - "Uninstalling" is the process of removing all traces of a module.
* *
* Order of events: * Order of events:
* - Gather and add module dependencies to $module_list (if applicable). * - Gather and add module dependencies to $module_list (if applicable).
* - For each module that is being enabled: * - For each module that is being installed:
* - Invoke hook_module_preinstall().
* - Install module schema and update system registries and caches. * - Install module schema and update system registries and caches.
* - If the module is being enabled for the first time or had been * - Invoke hook_install() and add it to the list of installed modules.
* uninstalled, invoke hook_install() and add it to the list of installed
* modules.
* - Invoke hook_enable().
* - Invoke hook_modules_installed(). * - Invoke hook_modules_installed().
* - Invoke hook_modules_enabled().
* *
* @param $module_list * @param array $module_list
* An array of module names. * An array of module names.
* @param $enable_dependencies * @param bool $enable_dependencies
* If TRUE, dependencies will automatically be added and enabled in the * (optional) If TRUE, dependencies will automatically be installed in the
* correct order. This incurs a significant performance cost, so use FALSE * correct order. This incurs a significant performance cost, so use FALSE
* if you know $module_list is already complete and in the correct order. * if you know $module_list is already complete.
* *
* @return * @return bool
* FALSE if one or more dependencies are missing, TRUE otherwise. * FALSE if one or more dependencies are missing, TRUE otherwise.
* *
* @see hook_module_preinstall()
* @see hook_install() * @see hook_install()
* @see hook_enable()
* @see hook_modules_installed() * @see hook_modules_installed()
* @see hook_modules_enabled()
*/
public function enable($module_list, $enable_dependencies = TRUE);
/**
* Disables a given set of modules.
*
* @param $module_list
* An array of module names.
* @param $disable_dependents
* If TRUE, dependent modules will automatically be added and disabled in the
* correct order. This incurs a significant performance cost, so use FALSE
* if you know $module_list is already complete and in the correct order.
*/ */
public function disable($module_list, $disable_dependents = TRUE); public function install(array $module_list, $enable_dependencies = TRUE);
/** /**
* Uninstalls a given list of disabled modules. * Uninstalls a given list of disabled modules.
* *
* @param array $module_list * @param array $module_list
* The modules to uninstall. It is the caller's responsibility to ensure that * The modules to uninstall.
* all modules in this list have already been disabled before this function
* is called.
* @param bool $uninstall_dependents * @param bool $uninstall_dependents
* (optional) If TRUE, the function will check that all modules which depend * (optional) If TRUE, dependent modules will automatically be uninstalled
* on the passed-in module list either are already uninstalled or contained in * in the correct order. This incurs a significant performance cost, so use
* the list, and it will ensure that the modules are uninstalled in the * FALSE if you know $module_list is already complete.
* correct order. This incurs a significant performance cost, so use FALSE if
* you know $module_list is already complete and in the correct order.
* Defaults to TRUE.
* *
* @return bool * @return bool
* Returns TRUE if the operation succeeds or FALSE if it aborts due to an * FALSE if one or more dependencies are missing, TRUE otherwise.
* unsafe condition, namely, $uninstall_dependents is TRUE and a module in *
* $module_list has dependents which are not already uninstalled and not also * @see hook_module_preuninstall()
* included in $module_list). * @see hook_uninstall()
* @see hook_modules_uninstalled()
*/ */
public function uninstall($module_list = array(), $uninstall_dependents = TRUE); public function uninstall(array $module_list, $uninstall_dependents = TRUE);
/** /**
* Returns an array of directories for all enabled modules. Useful for * Returns an array of directories for all enabled modules. Useful for
......
...@@ -58,7 +58,7 @@ public function getImplementations($hook) { ...@@ -58,7 +58,7 @@ public function getImplementations($hook) {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function enable($module_list, $enable_dependencies = TRUE) { public function install(array $module_list, $enable_dependencies = TRUE) {
$schema_store = \Drupal::keyValue('system.schema'); $schema_store = \Drupal::keyValue('system.schema');
$old_schema = array(); $old_schema = array();
foreach ($module_list as $module) { foreach ($module_list as $module) {
...@@ -74,16 +74,13 @@ public function enable($module_list, $enable_dependencies = TRUE) { ...@@ -74,16 +74,13 @@ public function enable($module_list, $enable_dependencies = TRUE) {
db_create_table($table, $spec); db_create_table($table, $spec);
} }
} }
// Enable the module with a weight of 0. // Enable the module with a weight of 0.
$module_config = \Drupal::config('system.module'); $module_config = \Drupal::config('system.module');
$module_config $module_config
->set("enabled.$module", 0) ->set("enabled.$module", 0)
->set('enabled', module_config_sort($module_config->get('enabled'))) ->set('enabled', module_config_sort($module_config->get('enabled')))
->save(); ->save();
// Ensure the module is not contained in disabled modules.
\Drupal::config('system.module.disabled')
->clear($module)
->save();
$current_schema = $schema_store->get($module); $current_schema = $schema_store->get($module);
// Set the schema version if the module was not just disabled before. // Set the schema version if the module was not just disabled before.
...@@ -105,7 +102,7 @@ public function enable($module_list, $enable_dependencies = TRUE) { ...@@ -105,7 +102,7 @@ public function enable($module_list, $enable_dependencies = TRUE) {
$module_config_path = drupal_get_path('module', $module) . '/config'; $module_config_path = drupal_get_path('module', $module) . '/config';
if (is_dir($module_config_path)) { if (is_dir($module_config_path)) {
$module_filestorage = new FileStorage($module_config_path); $module_filestorage = new FileStorage($module_config_path);
$config_storage = drupal_container()->get('config.storage'); $config_storage = \Drupal::service('config.storage');
foreach ($module_filestorage->listAll() as $config_name) { foreach ($module_filestorage->listAll() as $config_name) {
// If this file already exists, something in the upgrade path went // If this file already exists, something in the upgrade path went
// completely wrong and we want to know. // completely wrong and we want to know.
...@@ -134,14 +131,7 @@ public function enable($module_list, $enable_dependencies = TRUE) { ...@@ -134,14 +131,7 @@ public function enable($module_list, $enable_dependencies = TRUE) {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function disable($module_list, $disable_dependents = TRUE) { public function uninstall(array $module_list, $uninstall_dependents = TRUE) {
throw new \LogicException('Disabling modules is not supported during updates');
}
/**
* {@inheritdoc}
*/
public function uninstall($module_list = array(), $uninstall_dependents = TRUE) {
throw new \LogicException('Uninstalling modules is not supported during updates'); throw new \LogicException('Uninstalling modules is not supported during updates');
} }
......
...@@ -35,7 +35,6 @@ public static function getInfo() { ...@@ -35,7 +35,6 @@ public static function getInfo() {
* Tests Action uninstall. * Tests Action uninstall.
*/ */
public function testActionUninstall() { public function testActionUninstall() {
\Drupal::moduleHandler()->disable(array('action'));
\Drupal::moduleHandler()->uninstall(array('action')); \Drupal::moduleHandler()->uninstall(array('action'));
$this->assertTrue(entity_load('action', 'user_block_user_action', TRUE), 'Configuration entity \'user_block_user_action\' still exists after uninstalling action module.' ); $this->assertTrue(entity_load('action', 'user_block_user_action', TRUE), 'Configuration entity \'user_block_user_action\' still exists after uninstalling action module.' );
......
...@@ -59,7 +59,7 @@ function testSettingsPage() { ...@@ -59,7 +59,7 @@ function testSettingsPage() {
// Make sure settings form is still accessible even after disabling a module // Make sure settings form is still accessible even after disabling a module
// that provides the selected plugins. // that provides the selected plugins.
module_disable(array('aggregator_test')); module_uninstall(array('aggregator_test'));
$this->resetAll(); $this->resetAll();
$this->drupalGet('admin/config/services/aggregator/settings'); $this->drupalGet('admin/config/services/aggregator/settings');
$this->assertResponse(200); $this->assertResponse(200);
......
...@@ -72,7 +72,7 @@ function testUpdateFeedItem() { ...@@ -72,7 +72,7 @@ function testUpdateFeedItem() {
// Make sure updating items works even after disabling a module // Make sure updating items works even after disabling a module
// that provides the selected plugins. // that provides the selected plugins.
$this->enableTestPlugins(); $this->enableTestPlugins();
module_disable(array('aggregator_test')); module_uninstall(array('aggregator_test'));
$this->updateFeedItems($feed); $this->updateFeedItems($feed);
$this->assertResponse(200); $this->assertResponse(200);
} }
......
...@@ -184,7 +184,7 @@ function block_update_8005() { ...@@ -184,7 +184,7 @@ function block_update_8005() {
* Enable the Custom Block module. * Enable the Custom Block module.
*/ */
function block_update_8006() { function block_update_8006() {
module_enable(array('custom_block')); Drupal::moduleHandler()->install(array('custom_block'));
} }
/** /**
......
...@@ -238,7 +238,7 @@ function moveBlockToRegion(array $block, $region) { ...@@ -238,7 +238,7 @@ function moveBlockToRegion(array $block, $region) {
* Test _block_rehash(). * Test _block_rehash().
*/ */
function testBlockRehash() { function testBlockRehash() {
module_enable(array('block_test')); \Drupal::moduleHandler()->install(array('block_test'));
$this->assertTrue(module_exists('block_test'), 'Test block module enabled.'); $this->assertTrue(module_exists('block_test'), 'Test block module enabled.');
// Clear the block cache to load the block_test module's block definitions. // Clear the block cache to load the block_test module's block definitions.
...@@ -267,100 +267,4 @@ function testBlockRehash() { ...@@ -267,100 +267,4 @@ function testBlockRehash() {
$this->assertEqual($settings['cache'], DRUPAL_NO_CACHE, "Test block's database entry updated to DRUPAL_NO_CACHE."); $this->assertEqual($settings['cache'], DRUPAL_NO_CACHE, "Test block's database entry updated to DRUPAL_NO_CACHE.");
} }
/**
* Tests blocks belonging to disabled modules.
*/
function testBlockModuleDisable() {
module_enable(array('block_test'));
$this->assertTrue(module_exists('block_test'), 'Test block module enabled.');
// Clear the block cache to load the block_test module's block definitions.
$manager = $this->container->get('plugin.manager.block');
$manager->clearCachedDefinitions();
// Add test blocks in different regions and confirm they are displayed.
$blocks = array();
$regions = array('sidebar_first', 'content', 'footer');
foreach ($regions as $region) {
$blocks[$region] = $this->drupalPlaceBlock('test_cache', array('region' => $region));
}
$this->drupalGet('');
foreach ($regions as $region) {
$this->assertText($blocks[$region]->label());
}
// Disable the block test module and refresh the definitions cache.
module_disable(array('block_test'), FALSE);
$this->assertFalse(module_exists('block_test'), 'Test block module disabled.');
$manager->clearCachedDefinitions();
// Ensure that the block administration page still functions as expected.
$this->drupalGet('admin/structure/block');
$this->assertResponse(200);
// A 200 response is possible with a fatal error, so check the title too.
$this->assertTitle(t('Block layout') . ' | Drupal');
// Ensure that the disabled module's block instance is not listed.
foreach ($regions as $region) {
$this->assertNoText($blocks[$region]->label());
}
// Ensure that the disabled module's block plugin is no longer available.
$this->drupalGet('admin/structure/block/list/' . \Drupal::config('system.theme')->get('default'));
$this->assertNoText(t('Test block caching'));
// Confirm that the block is no longer displayed on the front page.
$this->drupalGet('');
$this->assertResponse(200);
foreach ($regions as $region) {
$this->assertNoText($blocks[$region]->label());
}
// Confirm that a different block instance can still be enabled by
// submitting the block library form.
// Emulate a POST submission rather than using drupalPlaceBlock() to ensure
// that the form still functions as expected.
$edit = array(
'settings[label]' => $this->randomName(8),
'machine_name' => strtolower($this->randomName(8)),
'region' => 'sidebar_first',
);
$this->drupalPostForm('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['settings[label]']);
// Update the weight of a block.
$edit = array('blocks[stark.' . $edit['machine_name'] . '][weight]' => -1);
$this->drupalPostForm('admin/structure/block', $edit, t('Save blocks'));
$this->assertText(t('The block settings have been updated.'));
// Re-enable the module and refresh the definitions cache.
module_enable(array('block_test'), FALSE);
$this->assertTrue(module_exists('block_test'), 'Test block module re-enabled.');
$manager->clearCachedDefinitions();
// Reload the admin page and confirm the block can again be configured.
$this->drupalGet('admin/structure/block');
foreach ($regions as $region) {
$this->assertLinkByHref(url('admin/structure/block/manage/' . $blocks[$region]->id()));
}
// Confirm that the blocks are again displayed on the front page in the
// correct regions.
$this->drupalGet('');
foreach ($regions as $region) {
// @todo Use a proper method for this.
$name_pieces = explode('.', $blocks[$region]->id());
$machine_name = array_pop($name_pieces);
$xpath = $this->buildXPathQuery('//div[@class=:region-class]//div[@id=:block-id]/*', array(
':region-class' => 'region region-' . drupal_html_class($region),
':block-id' => 'block-' . strtr(strtolower($machine_name), '-', '_'),
));
$this->assertFieldByXPath($xpath, NULL, format_string('Block %name found in the %region region.', array(
'%name' => $blocks[$region]->label(),
'%region' => $region,
)));
}
}
} }
...@@ -6,15 +6,15 @@ ...@@ -6,15 +6,15 @@
*/ */
/** /**
* Implements hook_enable(). * Implements hook_install().
* *
* Import breakpoints from all enabled themes. * Import breakpoints from all enabled themes.
*/ */
function breakpoint_enable() { function breakpoint_install() {
// Import breakpoints from enabled themes. // Import breakpoints from enabled themes.
$themes = array_filter(list_themes(), function ($theme) {return $theme->status;}); $themes = array_filter(list_themes(), function ($theme) {return $theme->status;});
_breakpoint_theme_enabled(array_keys($themes)); _breakpoint_theme_enabled(array_keys($themes));
// Import breakpoints from modules. // Import breakpoints from modules.
_breakpoint_modules_enabled(array_keys(\Drupal::moduleHandler()->getModuleList())); _breakpoint_modules_installed(array_keys(\Drupal::moduleHandler()->getModuleList()));
} }
...@@ -62,7 +62,7 @@ function breakpoint_themes_disabled($theme_list) { ...@@ -62,7 +62,7 @@ function breakpoint_themes_disabled($theme_list) {
} }
/** /**
* Implements hook_modules_enabled(). * Implements hook_modules_installed().
* *
* @param array $modules * @param array $modules
* An array of the modules that were enabled. * An array of the modules that were enabled.
...@@ -71,8 +71,8 @@ function breakpoint_themes_disabled($theme_list) { ...@@ -71,8 +71,8 @@ function breakpoint_themes_disabled($theme_list) {
* *
* @todo: This should be removed if https://drupal.org/node/1813100 is resolved. * @todo: This should be removed if https://drupal.org/node/1813100 is resolved.
*/