Commit bda5391e authored by catch's avatar catch
Browse files

Issue #3039296 by jungle, abhisekmazumdar, pandaski, tvb, dww, alexpott,...

Issue #3039296 by jungle, abhisekmazumdar, pandaski, tvb, dww, alexpott, init90: Fix examples in hook_install() and hook_uninstall()

(cherry picked from commit 0bcbf2f0)
parent c8a95613
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
*/ */
use Drupal\Core\Database\Database; use Drupal\Core\Database\Database;
use Drupal\Core\File\FileSystemInterface;
use Drupal\Core\Link; use Drupal\Core\Link;
use Drupal\Core\Url; use Drupal\Core\Url;
use Drupal\Core\Utility\UpdateException; use Drupal\Core\Utility\UpdateException;
...@@ -241,13 +240,8 @@ function hook_modules_installed($modules, $is_syncing) { ...@@ -241,13 +240,8 @@ function hook_modules_installed($modules, $is_syncing) {
* @see hook_modules_installed() * @see hook_modules_installed()
*/ */
function hook_install($is_syncing) { function hook_install($is_syncing) {
// Create the styles directory and ensure it's writable. // Set general module variables.
$directory = \Drupal::config('system.file')->get('default_scheme') . '://styles'; \Drupal::state()->set('mymodule.foo', 'bar');
\Drupal::service('file_system')->prepareDirectory($directory, FileSystemInterface::CREATE_DIRECTORY | FileSystemInterface::MODIFY_PERMISSIONS);
if (!$is_syncing) {
// Modify a configuration value because we're not syncing.
\Drupal::configFactory()->getEditable('system.file')->set('default_scheme', 'private')->save();
}
} }
/** /**
...@@ -316,11 +310,8 @@ function hook_modules_uninstalled($modules, $is_syncing) { ...@@ -316,11 +310,8 @@ function hook_modules_uninstalled($modules, $is_syncing) {
* @see hook_modules_uninstalled() * @see hook_modules_uninstalled()
*/ */
function hook_uninstall($is_syncing) { function hook_uninstall($is_syncing) {
// Remove the styles directory and generated images. // Delete remaining general module variables.
\Drupal::service('file_system')->deleteRecursive(\Drupal::config('system.file')->get('default_scheme') . '://styles'); \Drupal::state()->delete('mymodule.foo');
if (!$is_syncing) {
\Drupal::service('mymodule.service')->removeContent();
}
} }
/** /**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment