diff --git a/composer.json b/composer.json index 9ad2a9854..527448412 100644 --- a/composer.json +++ b/composer.json @@ -203,6 +203,7 @@ "drupal/config_pages": "^2.6", "drupal/ctools": "^3.4", "drupal/default_content": "^2.0", + "drupal/domain_registration": "^1.4", "drupal/dropzonejs": "^2.1", "drupal/email_registration": "^1.0", "drupal/entity_browser": "^2.5", diff --git a/idea.install b/idea.install index ad8143e8e..46291df6c 100644 --- a/idea.install +++ b/idea.install @@ -6,6 +6,7 @@ */ use Drupal\user\Entity\User; +use Symfony\Component\HttpFoundation\Request; /** * Implements hook_install(). @@ -26,7 +27,7 @@ function idea_install() { // Force set the administerusersbyrole configuration in fact // the module change it during installation of profile. - // @Todo: Further investigation. + // @todo Further investigation. \Drupal::configFactory()->getEditable('administerusersbyrole.settings')->set('roles', ['manager' => 'safe'])->save(); // To avoid issues with importing of configurations set system.site @@ -36,4 +37,30 @@ function idea_install() { ->set('slogan', 'Ideas, challenges, news') ->set('page', ['front' => '/home']) ->save(); + + drupal_register_shutdown_function('_idea_rebuild_cache'); +} + +/** + * Force rebuild all Drupal's caches. + * + * Rules require clearing the cache to rebuild the container and register + * new rules events. Clearing cache in hook_install() didn't help, that's + * why it was moved to shutdown function. + */ +function _idea_rebuild_cache() { + $loader = require DRUPAL_ROOT . '/autoload.php'; + include_once DRUPAL_ROOT . '/core/includes/utility.inc'; + + $request = Request::createFromGlobals(); + + // Clear user cache for all major platforms. + $user_caches = [ + 'apcu_clear_cache', + 'wincache_ucache_clear', + 'xcache_clear_cache', + ]; + array_map('call_user_func', array_filter($user_caches, 'is_callable')); + + drupal_rebuild($loader, $request); }