/** * {@inheritdoc} */ public function buildForm(array $form, FormStateInterface $form_state, $bundle_name = NULL) { $this->currentBundle = $this->assigner->loadBundle($bundle_name); $settings = $this->currentBundle->getAssignmentSettings(self::METHOD_ID); $this->setTypeSelect($form, $settings['types'], $this->t('exclude')); $module_settings = $settings['module']; $curated_settings = $settings['curated']; $form['curated'] = array( '#type' => 'checkbox', '#title' => t('Exclude designated site-specific configuration'), '#default_value' => $curated_settings, '#description' => $this->t('Select this option to exclude from packaging items on a curated list of site-specific configuration.'), ); $form['module'] = array( '#type' => 'container', '#tree' => TRUE, ); $form['module']['enabled'] = array( '#type' => 'checkbox', '#title' => t('Exclude module-provided entity configuration'), '#default_value' => $module_settings['enabled'], '#description' => $this->t('Select this option to exclude from packaging any configuration that is provided by already enabled modules. Note that <a href="!url">simple configuration</a> will not be excluded as it is always module-provided.', array('!url' => 'http://www.drupal.org/node/1809490')), '#attributes' => array( 'data-module-enabled' => 'status', ), ); $show_if_module_enabled_checked = array( 'visible' => array( ':input[data-module-enabled="status"]' => array('checked' => TRUE), ), ); $info = system_get_info('module', drupal_get_profile()); $form['module']['profile'] = array( '#type' => 'checkbox', '#title' => t("Don't exclude install profile's configuration"), '#default_value' => $module_settings['profile'], '#description' => $this->t("Select this option to not exclude from packaging any configuration that is provided by this site's install profile, %profile.", array('%profile' => $info['name'])), '#states' => $show_if_module_enabled_checked, ); $machine_name = $this->currentBundle->getMachineName(); $machine_name = !empty($machine_name) ? $machine_name : t('none'); $form['module']['namespace'] = array( '#type' => 'checkbox', '#title' => t("Don't exclude configuration by namespace"), '#default_value' => $module_settings['namespace'], '#description' => $this->t("Select this option to not exclude from packaging any configuration that is provided by modules with the package namespace (currently %namespace).", array('%namespace' => $machine_name)), '#states' => $show_if_module_enabled_checked, ); $this->setActions($form); return $form; }
/** * Returns a map of all config object names and their folders. * * The list is based on enabled modules and themes. The active configuration * storage is used rather than \Drupal\Core\Extension\ModuleHandler and * \Drupal\Core\Extension\ThemeHandler in order to resolve circular * dependencies between these services and \Drupal\Core\Config\ConfigInstaller * and \Drupal\Core\Config\TypedConfigManager. * * @return array * An array mapping config object names with directories. */ protected function getAllFolders() { if (!isset($this->folders)) { $this->folders = array(); $this->folders += $this->getCoreNames(); $install_profile = Settings::get('install_profile'); $profile = drupal_get_profile(); $extensions = $this->configStorage->read('core.extension'); // @todo Remove this scan as part of https://www.drupal.org/node/2186491 $listing = new ExtensionDiscovery(\Drupal::root()); if (!empty($extensions['module'])) { $modules = $extensions['module']; // Remove the install profile as this is handled later. unset($modules[$install_profile]); $profile_list = $listing->scan('profile'); if ($profile && isset($profile_list[$profile])) { // Prime the drupal_get_filename() static cache with the profile info // file location so we can use drupal_get_path() on the active profile // during the module scan. // @todo Remove as part of https://www.drupal.org/node/2186491 drupal_get_filename('profile', $profile, $profile_list[$profile]->getPathname()); } $module_list_scan = $listing->scan('module'); $module_list = array(); foreach (array_keys($modules) as $module) { if (isset($module_list_scan[$module])) { $module_list[$module] = $module_list_scan[$module]; } } $this->folders += $this->getComponentNames($module_list); } if (!empty($extensions['theme'])) { $theme_list_scan = $listing->scan('theme'); foreach (array_keys($extensions['theme']) as $theme) { if (isset($theme_list_scan[$theme])) { $theme_list[$theme] = $theme_list_scan[$theme]; } } $this->folders += $this->getComponentNames($theme_list); } if ($this->includeProfile) { // The install profile can override module default configuration. We do // this by replacing the config file path from the module/theme with the // install profile version if there are any duplicates. if (isset($profile)) { if (!isset($profile_list)) { $profile_list = $listing->scan('profile'); } if (isset($profile_list[$profile])) { $profile_folders = $this->getComponentNames(array($profile_list[$profile])); $this->folders = $profile_folders + $this->folders; } } } } return $this->folders; }
/** * Confirms that the installation succeeded. */ public function testInstalled() { $this->assertUrl('user/1'); $this->assertResponse(200); // Confirm that we are logged-in after installation. $this->assertText($this->rootUser->getUsername()); // Confirm that the minimal profile was installed. $this->assertEqual(drupal_get_profile(), 'minimal'); }
/** * {@inheritdoc} */ public function buildForm(array $form, FormStateInterface $form_state) { // Make sure the install API is available. include_once DRUPAL_ROOT . '/core/includes/install.inc'; // Get a list of all available modules. $modules = system_rebuild_module_data(); $uninstallable = array_filter($modules, function ($module) use($modules) { return empty($modules[$module->getName()]->info['required']) && $module->status; }); // Include system.admin.inc so we can use the sort callbacks. $this->moduleHandler->loadInclude('system', 'inc', 'system.admin'); $form['filters'] = array('#type' => 'container', '#attributes' => array('class' => array('table-filter', 'js-show'))); $form['filters']['text'] = array('#type' => 'search', '#title' => $this->t('Filter modules'), '#title_display' => 'invisible', '#size' => 30, '#placeholder' => $this->t('Filter by name or description'), '#description' => $this->t('Enter a part of the module name or description'), '#attributes' => array('class' => array('table-filter-text'), 'data-table' => '#system-modules-uninstall', 'autocomplete' => 'off')); $form['modules'] = array(); // Only build the rest of the form if there are any modules available to // uninstall; if (empty($uninstallable)) { return $form; } $profile = drupal_get_profile(); // Sort all modules by their name. uasort($uninstallable, 'system_sort_modules_by_info_name'); $validation_reasons = $this->moduleInstaller->validateUninstall(array_keys($uninstallable)); $form['uninstall'] = array('#tree' => TRUE); foreach ($uninstallable as $module_key => $module) { $name = $module->info['name'] ?: $module->getName(); $form['modules'][$module->getName()]['#module_name'] = $name; $form['modules'][$module->getName()]['name']['#markup'] = $name; $form['modules'][$module->getName()]['description']['#markup'] = $this->t($module->info['description']); $form['uninstall'][$module->getName()] = array('#type' => 'checkbox', '#title' => $this->t('Uninstall @module module', array('@module' => $name)), '#title_display' => 'invisible'); // If a validator returns reasons not to uninstall a module, // list the reasons and disable the check box. if (isset($validation_reasons[$module_key])) { $form['modules'][$module->getName()]['#validation_reasons'] = $validation_reasons[$module_key]; $form['uninstall'][$module->getName()]['#disabled'] = TRUE; } // All modules which depend on this one must be uninstalled first, before // we can allow this module to be uninstalled. (The installation profile // is excluded from this list.) foreach (array_keys($module->required_by) as $dependent) { if ($dependent != $profile && drupal_get_installed_schema_version($dependent) != SCHEMA_UNINSTALLED) { $name = isset($modules[$dependent]->info['name']) ? $modules[$dependent]->info['name'] : $dependent; $form['modules'][$module->getName()]['#required_by'][] = $name; $form['uninstall'][$module->getName()]['#disabled'] = TRUE; } } } $form['#attached']['library'][] = 'system/drupal.system.modules'; $form['actions'] = array('#type' => 'actions'); $form['actions']['submit'] = array('#type' => 'submit', '#value' => $this->t('Uninstall')); return $form; }
/** * A helper function to generate a list of paths to the Superfish library files. */ public function superfish_library_path() { // Ensure the Libraries API module is installed and working. if (function_exists('libraries_get_path')) { $directory = libraries_get_path('superfish'); } elseif (file_exists('profiles/' . drupal_get_profile() . '/libraries/superfish')) { $directory = 'profiles/' . drupal_get_profile() . '/libraries/superfish'; } else { $directory = 'sites/all/libraries/superfish'; } if (file_exists($directory)) { $output = $directory . "/jquery.hoverIntent.minified.js\r\n" . $directory . "/superfish.js\r\n" . $directory . "/supersubs.js\r\n" . $directory . "/supposition.js\r\n" . $directory . "/sfsmallscreen.js\r\n" . $directory . "/sftouchscreen.js"; } else { $output = ''; } return $output; }
/** * {@inheritdoc} */ public function collect(Request $request, Response $response, \Exception $exception = NULL) { $this->data['version'] = Drupal::VERSION; $this->data['profile'] = drupal_get_profile(); $this->data['config_url'] = (new Drupal\Core\Url('webprofiler.settings', [], ['query' => $this->redirectDestination->getAsArray()]))->toString(); try { $process = new Process("git log -1 --pretty=format:'%H - %s (%ci)' --abbrev-commit"); $process->setTimeout(3600); $process->mustRun(); $this->data['git_commit'] = $process->getOutput(); $process = new Process("git log -1 --pretty=format:'%h' --abbrev-commit"); $process->setTimeout(3600); $process->mustRun(); $this->data['abbr_git_commit'] = $process->getOutput(); } catch (ProcessFailedException $e) { $this->data['git_commit'] = $this->data['git_commit_abbr'] = NULL; } }
/** * Defines a list of the locations, where icon sets are searched. * * @return array */ protected function setSearchDirs() { // Similar to 'modules' and 'themes' directories inside an installation // profile, installation profiles may want to place libraries into a // 'libraries' directory. $profile = drupal_get_profile(); if ($profile && strpos($profile, "core") === FALSE) { $profile_path = drupal_get_path('profile', $profile); $searchdirs[] = "{$profile_path}/libraries"; } // Search sites/all/libraries for backwars-compatibility. $searchdirs[] = 'sites/all/libraries'; // Always search the root 'libraries' directory. $searchdirs[] = 'libraries'; // Also search sites/<domain>/*. $site_path = \Drupal::service('kernel')->getSitePath(); $searchdirs[] = "{$site_path}/libraries"; // Add the social_media_links module directory. $searchdirs[] = drupal_get_path('module', 'social_media_links') . '/libraries'; $this->searchDirs = $searchdirs; }
/** * {@inheritdoc} */ public function buildForm(array $form, FormStateInterface $form_state, $bundle_name = NULL) { $this->currentBundle = $this->assigner->loadBundle($bundle_name); $settings = $this->currentBundle->getAssignmentSettings(self::METHOD_ID); $this->setConfigTypeSelect($form, $settings['types']['config'], $this->t('exclude')); $module_settings = $settings['module']; $curated_settings = $settings['curated']; $form['curated'] = array('#type' => 'checkbox', '#title' => $this->t('Exclude designated site-specific configuration'), '#default_value' => $curated_settings, '#description' => $this->t('Select this option to exclude from packaging items on a curated list of site-specific configuration.')); $form['module'] = array('#type' => 'container', '#tree' => TRUE); $form['module']['installed'] = array('#type' => 'checkbox', '#title' => $this->t('Exclude installed module-provided entity configuration'), '#default_value' => $module_settings['installed'], '#description' => $this->t('Select this option to exclude from packaging any configuration that is provided by already installed modules.'), '#attributes' => array('data-module-installed' => 'status')); $show_if_module_installed_checked = array('visible' => array(':input[data-module-installed="status"]' => array('checked' => TRUE))); $info = system_get_info('module', drupal_get_profile()); $form['module']['profile'] = array('#type' => 'checkbox', '#title' => $this->t("Don't exclude install profile's configuration"), '#default_value' => $module_settings['profile'], '#description' => $this->t("Select this option to not exclude from packaging any configuration that is provided by this site's install profile, %profile.", array('%profile' => $info['name'])), '#states' => $show_if_module_installed_checked); $machine_name = $this->currentBundle->getMachineName(); $machine_name = !empty($machine_name) ? $machine_name : t('none'); $form['module']['namespace'] = array('#type' => 'checkbox', '#title' => $this->t("Don't exclude non-installed configuration by namespace"), '#default_value' => $module_settings['namespace'], '#description' => $this->t("Select this option to not exclude from packaging any configuration that is provided by non-installed modules with the package namespace (currently %namespace).", array('%namespace' => $machine_name)), '#states' => $show_if_module_installed_checked, '#attributes' => array('data-namespace' => 'status')); $show_if_namespace_checked = array('visible' => array(':input[data-namespace="status"]' => array('checked' => TRUE), ':input[data-module-installed="status"]' => array('checked' => TRUE))); $form['module']['namespace_any'] = array('#type' => 'checkbox', '#title' => $this->t("Don't exclude ANY configuration by namespace"), '#default_value' => $module_settings['namespace_any'], '#description' => $this->t("Select this option to not exclude from packaging any configuration that is provided by ANY modules with the package namespace (currently %namespace).\n Warning: Can cause installed configuration to be reassigned to different packages.", array('%namespace' => $machine_name)), '#states' => $show_if_namespace_checked); $this->setActions($form); return $form; }
/** * Returns a map of all config object names and their folders. * * The list is based on enabled modules and themes. The active configuration * storage is used rather than \Drupal\Core\Extension\ModuleHandler and * \Drupal\Core\Extension\ThemeHandler in order to resolve circular * dependencies between these services and \Drupal\Core\Config\ConfigInstaller * and \Drupal\Core\Config\TypedConfigManager. * * @return array * An array mapping config object names with directories. */ protected function getAllFolders() { if (!isset($this->folders)) { $this->folders = array(); $this->folders += $this->getComponentNames('core', array('core')); $extensions = $this->configStorage->read('core.extension'); if (!empty($extensions['module'])) { $this->folders += $this->getComponentNames('module', array_keys($extensions['module'])); } if (!empty($extensions['theme'])) { $this->folders += $this->getComponentNames('theme', array_keys($extensions['theme'])); } // The install profile can override module default configuration. We do // this by replacing the config file path from the module/theme with the // install profile version if there are any duplicates. $profile_folders = $this->getComponentNames('profile', array(drupal_get_profile())); $folders_to_replace = array_intersect_key($profile_folders, $this->folders); if (!empty($folders_to_replace)) { $this->folders = array_merge($this->folders, $folders_to_replace); } } return $this->folders; }
/** * Generates a random database prefix, runs the install scripts on the * prefixed database and enable the specified modules. After installation * many caches are flushed and the internal browser is setup so that the * page requests will run on the new prefix. A temporary files directory * is created with the same name as the database prefix. * * @param ... * List of modules to enable for the duration of the test. */ protected function setUp() { global $db_prefix, $user, $language; // Store necessary current values before switching to prefixed database. $this->originalLanguage = $language; $this->originalLanguageDefault = variable_get('language_default'); $this->originalPrefix = $db_prefix; $this->originalFileDirectory = file_directory_path(); $this->originalProfile = drupal_get_profile(); $clean_url_original = variable_get('clean_url', 0); // Generate temporary prefixed database to ensure that tests have a clean starting point. $db_prefix_new = Database::getConnection()->prefixTables('{simpletest' . mt_rand(1000, 1000000) . '}'); db_update('simpletest_test_id')->fields(array('last_prefix' => $db_prefix_new))->condition('test_id', $this->testId)->execute(); $db_prefix = $db_prefix_new; // Create test directory ahead of installation so fatal errors and debug // information can be logged during installation process. // Use temporary files directory with the same prefix as the database. $public_files_directory = $this->originalFileDirectory . '/simpletest/' . substr($db_prefix, 10); $private_files_directory = $public_files_directory . '/private'; $temp_files_directory = $private_files_directory . '/temp'; // Create the directories file_prepare_directory($public_files_directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS); file_prepare_directory($private_files_directory, FILE_CREATE_DIRECTORY); file_prepare_directory($temp_files_directory, FILE_CREATE_DIRECTORY); $this->generatedTestFiles = FALSE; // Log fatal errors. ini_set('log_errors', 1); ini_set('error_log', $public_files_directory . '/error.log'); // Reset all statics so that test is performed with a clean environment. drupal_static_reset(); include_once DRUPAL_ROOT . '/includes/install.inc'; drupal_install_system(); $this->preloadRegistry(); // Include the default profile variable_set('install_profile', 'standard'); $profile_details = install_profile_info('standard', 'en'); // Install the modules specified by the default profile. drupal_install_modules($profile_details['dependencies'], TRUE); drupal_static_reset('_node_types_build'); if ($modules = func_get_args()) { // Install modules needed for this test. drupal_install_modules($modules, TRUE); } // Because the schema is static cached, we need to flush // it between each run. If we don't, then it will contain // stale data for the previous run's database prefix and all // calls to it will fail. drupal_get_schema(NULL, TRUE); // Run default profile tasks. $install_state = array(); drupal_install_modules(array('standard'), TRUE); // Rebuild caches. node_types_rebuild(); actions_synchronize(); _drupal_flush_css_js(); $this->refreshVariables(); $this->checkPermissions(array(), TRUE); // Log in with a clean $user. $this->originalUser = $user; drupal_save_session(FALSE); $user = user_load(1); // Restore necessary variables. variable_set('install_task', 'done'); variable_set('clean_url', $clean_url_original); variable_set('site_mail', '*****@*****.**'); // Set up English language. unset($GLOBALS['conf']['language_default']); $language = language_default(); // Set path variables variable_set('file_public_path', $public_files_directory); variable_set('file_private_path', $private_files_directory); variable_set('file_temporary_path', $temp_files_directory); // Use the test mail class instead of the default mail handler class. variable_set('mail_system', array('default-system' => 'TestingMailSystem')); drupal_set_time_limit($this->timeLimit); }
/** * Prepares the current environment for running the test. * * Backups various current environment variables and resets them, so they do * not interfere with the Drupal site installation in which tests are executed * and can be restored in TestBase::restoreEnvironment(). * * Also sets up new resources for the testing environment, such as the public * filesystem and configuration directories. * * This method is private as it must only be called once by TestBase::run() * (multiple invocations for the same test would have unpredictable * consequences) and it must not be callable or overridable by test classes. * * @see TestBase::beforePrepareEnvironment() */ private function prepareEnvironment() { $user = \Drupal::currentUser(); // Allow (base) test classes to backup global state information. $this->beforePrepareEnvironment(); // Create the database prefix for this test. $this->prepareDatabasePrefix(); $language_interface = \Drupal::languageManager()->getCurrentLanguage(); // When running the test runner within a test, back up the original database // prefix. if (DRUPAL_TEST_IN_CHILD_SITE) { $this->originalPrefix = drupal_valid_test_ua(); } // Backup current in-memory configuration. $site_path = \Drupal::service('site.path'); $this->originalSite = $site_path; $this->originalSettings = Settings::getAll(); $this->originalConfig = $GLOBALS['config']; // @todo Remove all remnants of $GLOBALS['conf']. // @see https://www.drupal.org/node/2183323 $this->originalConf = isset($GLOBALS['conf']) ? $GLOBALS['conf'] : NULL; // Backup statics and globals. $this->originalContainer = clone \Drupal::getContainer(); $this->originalLanguage = $language_interface; $this->originalConfigDirectories = $GLOBALS['config_directories']; // Save further contextual information. // Use the original files directory to avoid nesting it within an existing // simpletest directory if a test is executed within a test. $this->originalFileDirectory = Settings::get('file_public_path', $site_path . '/files'); $this->originalProfile = drupal_get_profile(); $this->originalUser = isset($user) ? clone $user : NULL; // Prevent that session data is leaked into the UI test runner by closing // the session and then setting the session-name (i.e. the name of the // session cookie) to a random value. If a test starts a new session, then // it will be associated with a different session-name. After the test-run // it can be safely destroyed. // @see TestBase::restoreEnvironment() if (PHP_SAPI !== 'cli' && session_status() === PHP_SESSION_ACTIVE) { session_write_close(); } $this->originalSessionName = session_name(); session_name('SIMPLETEST' . Crypt::randomBytesBase64()); // Save and clean the shutdown callbacks array because it is static cached // and will be changed by the test run. Otherwise it will contain callbacks // from both environments and the testing environment will try to call the // handlers defined by the original one. $callbacks =& drupal_register_shutdown_function(); $this->originalShutdownCallbacks = $callbacks; $callbacks = array(); // Create test directory ahead of installation so fatal errors and debug // information can be logged during installation process. file_prepare_directory($this->siteDirectory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS); // Prepare filesystem directory paths. $this->publicFilesDirectory = $this->siteDirectory . '/files'; $this->privateFilesDirectory = $this->siteDirectory . '/private'; $this->tempFilesDirectory = $this->siteDirectory . '/temp'; $this->translationFilesDirectory = $this->siteDirectory . '/translations'; $this->generatedTestFiles = FALSE; // Ensure the configImporter is refreshed for each test. $this->configImporter = NULL; // Unregister all custom stream wrappers of the parent site. // Availability of Drupal stream wrappers varies by test base class: // - KernelTestBase supports and maintains stream wrappers in a custom // way. // - WebTestBase re-initializes Drupal stream wrappers after installation. // The original stream wrappers are restored after the test run. // @see TestBase::restoreEnvironment() $this->originalContainer->get('stream_wrapper_manager')->unregister(); // Reset statics. drupal_static_reset(); // Ensure there is no service container. $this->container = NULL; \Drupal::unsetContainer(); // Unset globals. unset($GLOBALS['config_directories']); unset($GLOBALS['config']); unset($GLOBALS['conf']); // Log fatal errors. ini_set('log_errors', 1); ini_set('error_log', DRUPAL_ROOT . '/' . $this->siteDirectory . '/error.log'); // Change the database prefix. $this->changeDatabasePrefix(); // After preparing the environment and changing the database prefix, we are // in a valid test environment. drupal_valid_test_ua($this->databasePrefix); // Reset settings. new Settings(array('hash_salt' => $this->databasePrefix, 'container_yamls' => [])); drupal_set_time_limit($this->timeLimit); }
/** * Return driver specific configuration options. * * @param $database * An array of driver specific configuration options. * * @return * The options form array. */ public function getFormOptions(array $database) { $form['database'] = array('#type' => 'textfield', '#title' => t('Database name'), '#default_value' => empty($database['database']) ? '' : $database['database'], '#size' => 45, '#required' => TRUE, '#states' => array('required' => array(':input[name=driver]' => array('value' => $this->pdoDriver)))); $form['username'] = array('#type' => 'textfield', '#title' => t('Database username'), '#default_value' => empty($database['username']) ? '' : $database['username'], '#size' => 45, '#required' => TRUE, '#states' => array('required' => array(':input[name=driver]' => array('value' => $this->pdoDriver)))); $form['password'] = array('#type' => 'password', '#title' => t('Database password'), '#default_value' => empty($database['password']) ? '' : $database['password'], '#required' => FALSE, '#size' => 45); $form['advanced_options'] = array('#type' => 'details', '#title' => t('Advanced options'), '#weight' => 10); $profile = drupal_get_profile(); $db_prefix = $profile == 'standard' ? 'drupal_' : $profile . '_'; $form['advanced_options']['prefix'] = array('#type' => 'textfield', '#title' => t('Table name prefix'), '#default_value' => empty($database['prefix']) ? '' : $database['prefix'], '#size' => 45, '#description' => t('If more than one application will be sharing this database, a unique table name prefix–such as %prefix–will prevent collisions.', array('%prefix' => $db_prefix)), '#weight' => 10); $form['advanced_options']['host'] = array('#type' => 'textfield', '#title' => t('Host'), '#default_value' => empty($database['host']) ? 'localhost' : $database['host'], '#size' => 45, '#maxlength' => 255, '#required' => TRUE); $form['advanced_options']['port'] = array('#type' => 'number', '#title' => t('Port number'), '#default_value' => empty($database['port']) ? '' : $database['port'], '#min' => 0, '#max' => 65535); return $form; }
/** * {@inheritdoc} */ public function getProfileName() { $name = $this->isProfile() ? $this->profileName : ''; return !empty($name) ? $name : drupal_get_profile(); }
/** * Generates a random database prefix, runs the install scripts on the * prefixed database and enable the specified modules. After installation * many caches are flushed and the internal browser is setup so that the * page requests will run on the new prefix. A temporary files directory * is created with the same name as the database prefix. * * @param ... * List of modules to enable for the duration of the test. This can be * either a single array or a variable number of string arguments. */ protected function setUp() { global $user, $language, $conf; // Generate a temporary prefixed database to ensure that tests have a clean starting point. $this->databasePrefix = 'simpletest' . mt_rand(1000, 1000000); db_update('simpletest_test_id')->fields(array('last_prefix' => $this->databasePrefix))->condition('test_id', $this->testId)->execute(); // Clone the current connection and replace the current prefix. $connection_info = Database::getConnectionInfo('default'); Database::renameConnection('default', 'simpletest_original_default'); foreach ($connection_info as $target => $value) { $connection_info[$target]['prefix'] = array('default' => $value['prefix']['default'] . $this->databasePrefix); } Database::addConnectionInfo('default', 'default', $connection_info['default']); // Store necessary current values before switching to prefixed database. $this->originalLanguage = $language; $this->originalLanguageDefault = variable_get('language_default'); $this->originalFileDirectory = variable_get('file_public_path', conf_path() . '/files'); $this->originalProfile = drupal_get_profile(); $this->removeTables = variable_get('simpletest_remove_tables', TRUE); $clean_url_original = variable_get('clean_url', 0); // Save and clean shutdown callbacks array because it static cached and // will be changed by the test run. If we don't, then it will contain // callbacks from both environments. So testing environment will try // to call handlers from original environment. $callbacks =& drupal_register_shutdown_function(); $this->originalShutdownCallbacks = $callbacks; $callbacks = array(); // Create test directory ahead of installation so fatal errors and debug // information can be logged during installation process. // Use temporary files directory with the same prefix as the database. $public_files_directory = $this->originalFileDirectory . '/simpletest/' . substr($this->databasePrefix, 10); $private_files_directory = $public_files_directory . '/private'; $temp_files_directory = $private_files_directory . '/temp'; // Create the directories file_prepare_directory($public_files_directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS); file_prepare_directory($private_files_directory, FILE_CREATE_DIRECTORY); file_prepare_directory($temp_files_directory, FILE_CREATE_DIRECTORY); $this->generatedTestFiles = FALSE; // Log fatal errors. ini_set('log_errors', 1); ini_set('error_log', $public_files_directory . '/error.log'); // Reset all statics and variables to perform tests in a clean environment. $conf = array(); drupal_static_reset(); // Set the test information for use in other parts of Drupal. $test_info =& $GLOBALS['drupal_test_info']; $test_info['test_run_id'] = $this->databasePrefix; $test_info['in_child_site'] = FALSE; $this->setUpInstall(func_get_args(), $public_files_directory, $private_files_directory, $temp_files_directory); // Rebuild caches. drupal_static_reset(); drupal_flush_all_caches(); // Register actions declared by any modules. actions_synchronize(); // Reload global $conf array and permissions. $this->refreshVariables(); $this->checkPermissions(array(), TRUE); // Reset statically cached schema for new database prefix. drupal_get_schema(NULL, TRUE); // Run cron once in that environment, as install.php does at the end of // the installation process. drupal_cron_run(); // Log in with a clean $user. $this->originalUser = $user; drupal_save_session(FALSE); $user = user_load(1); $this->setUpVariables($clean_url_original); // Set up English language. unset($GLOBALS['conf']['language_default']); $language = language_default(); // Use the test mail class instead of the default mail handler class. variable_set('mail_system', array('default-system' => 'TestingMailSystem')); drupal_set_time_limit($this->timeLimit); }
/** * Generates a random database prefix, runs the install scripts on the * prefixed database and enable the specified modules. After installation * many caches are flushed and the internal browser is setup so that the * page requests will run on the new prefix. A temporary files directory * is created with the same name as the database prefix. * * @param ... * List of modules to enable for the duration of the test. This can be * either a single array or a variable number of string arguments. */ protected function setUp() { global $user, $language, $conf; // Generate a temporary prefixed database to ensure that tests have a clean starting point. $this->databasePrefix = 'simpletest' . mt_rand(1000, 1000000); db_update('simpletest_test_id')->fields(array('last_prefix' => $this->databasePrefix))->condition('test_id', $this->testId)->execute(); // Clone the current connection and replace the current prefix. $connection_info = Database::getConnectionInfo('default'); Database::renameConnection('default', 'simpletest_original_default'); foreach ($connection_info as $target => $value) { $connection_info[$target]['prefix'] = array('default' => $value['prefix']['default'] . $this->databasePrefix); } Database::addConnectionInfo('default', 'default', $connection_info['default']); // Store necessary current values before switching to prefixed database. $this->originalLanguage = $language; $this->originalLanguageDefault = variable_get('language_default'); $this->originalFileDirectory = variable_get('file_public_path', conf_path() . '/files'); $this->originalProfile = drupal_get_profile(); $clean_url_original = variable_get('clean_url', 0); // Set to English to prevent exceptions from utf8_truncate() from t() // during install if the current language is not 'en'. // The following array/object conversion is copied from language_default(). $language = (object) array('language' => 'en', 'name' => 'English', 'native' => 'English', 'direction' => 0, 'enabled' => 1, 'plurals' => 0, 'formula' => '', 'domain' => '', 'prefix' => '', 'weight' => 0, 'javascript' => ''); // Save and clean shutdown callbacks array because it static cached and // will be changed by the test run. If we don't, then it will contain // callbacks from both environments. So testing environment will try // to call handlers from original environment. $callbacks =& drupal_register_shutdown_function(); $this->originalShutdownCallbacks = $callbacks; $callbacks = array(); // Create test directory ahead of installation so fatal errors and debug // information can be logged during installation process. // Use temporary files directory with the same prefix as the database. $public_files_directory = $this->originalFileDirectory . '/simpletest/' . substr($this->databasePrefix, 10); $private_files_directory = $public_files_directory . '/private'; $temp_files_directory = $private_files_directory . '/temp'; // Create the directories file_prepare_directory($public_files_directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS); file_prepare_directory($private_files_directory, FILE_CREATE_DIRECTORY); file_prepare_directory($temp_files_directory, FILE_CREATE_DIRECTORY); $this->generatedTestFiles = FALSE; // Log fatal errors. ini_set('log_errors', 1); ini_set('error_log', $public_files_directory . '/error.log'); // Reset all statics and variables to perform tests in a clean environment. $conf = array(); drupal_static_reset(); // Set the test information for use in other parts of Drupal. $test_info =& $GLOBALS['drupal_test_info']; $test_info['test_run_id'] = $this->databasePrefix; $test_info['in_child_site'] = FALSE; include_once DRUPAL_ROOT . '/includes/install.inc'; drupal_install_system(); $this->preloadRegistry(); // Set path variables. variable_set('file_public_path', $public_files_directory); variable_set('file_private_path', $private_files_directory); variable_set('file_temporary_path', $temp_files_directory); // Include the testing profile. variable_set('install_profile', $this->profile); $profile_details = install_profile_info($this->profile, 'en'); // Install the modules specified by the testing profile. module_enable($profile_details['dependencies'], FALSE); // Install modules needed for this test. This could have been passed in as // either a single array argument or a variable number of string arguments. // @todo Remove this compatibility layer in Drupal 8, and only accept // $modules as a single array argument. $modules = func_get_args(); if (isset($modules[0]) && is_array($modules[0])) { $modules = $modules[0]; } if ($modules) { $success = module_enable($modules, TRUE); $this->assertTrue($success, t('Enabled modules: %modules', array('%modules' => implode(', ', $modules)))); } // Run the profile tasks. $install_profile_module_exists = db_query("SELECT 1 FROM {system} WHERE type = 'module' AND name = :name", array(':name' => $this->profile))->fetchField(); if ($install_profile_module_exists) { module_enable(array($this->profile), FALSE); } // Reset/rebuild all data structures after enabling the modules. $this->resetAll(); // Run cron once in that environment, as install.php does at the end of // the installation process. drupal_cron_run(); // Log in with a clean $user. $this->originalUser = $user; drupal_save_session(FALSE); $user = user_load(1); // Restore necessary variables. variable_set('install_task', 'done'); variable_set('clean_url', $clean_url_original); variable_set('site_mail', '*****@*****.**'); variable_set('date_default_timezone', date_default_timezone_get()); // Set up English language. unset($GLOBALS['conf']['language_default']); $language = language_default(); // Use the test mail class instead of the default mail handler class. variable_set('mail_system', array('default-system' => 'TestingMailSystem')); drupal_set_time_limit($this->timeLimit); }
/** * Prepares the current environment for running the test. * * Backups various current environment variables and resets them, so they do * not interfere with the Drupal site installation in which tests are executed * and can be restored in tearDown(). * * Also sets up new resources for the testing environment, such as the public * filesystem and configuration directories. * * @see DrupalWebTestCase::setUp() * @see DrupalWebTestCase::tearDown() */ protected function prepareEnvironment() { global $user, $language, $conf; // Store necessary current values before switching to prefixed database. $this->originalLanguage = $language; $this->originalLanguageDefault = variable_get('language_default'); $this->originalFileDirectory = variable_get('file_public_path', conf_path() . '/files'); $this->originalProfile = drupal_get_profile(); $this->originalCleanUrl = variable_get('clean_url', 0); $this->originalUser = $user; // Set to English to prevent exceptions from utf8_truncate() from t() // during install if the current language is not 'en'. // The following array/object conversion is copied from language_default(). $language = (object) array('language' => 'en', 'name' => 'English', 'native' => 'English', 'direction' => 0, 'enabled' => 1, 'plurals' => 0, 'formula' => '', 'domain' => '', 'prefix' => '', 'weight' => 0, 'javascript' => ''); // Save and clean the shutdown callbacks array because it is static cached // and will be changed by the test run. Otherwise it will contain callbacks // from both environments and the testing environment will try to call the // handlers defined by the original one. $callbacks =& drupal_register_shutdown_function(); $this->originalShutdownCallbacks = $callbacks; $callbacks = array(); // Create test directory ahead of installation so fatal errors and debug // information can be logged during installation process. // Use temporary files directory with the same prefix as the database. $this->public_files_directory = $this->originalFileDirectory . '/simpletest/' . substr($this->databasePrefix, 10); $this->private_files_directory = $this->public_files_directory . '/private'; $this->temp_files_directory = $this->private_files_directory . '/temp'; // Create the directories file_prepare_directory($this->public_files_directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS); file_prepare_directory($this->private_files_directory, FILE_CREATE_DIRECTORY); file_prepare_directory($this->temp_files_directory, FILE_CREATE_DIRECTORY); $this->generatedTestFiles = FALSE; // Log fatal errors. ini_set('log_errors', 1); ini_set('error_log', $this->public_files_directory . '/error.log'); // Set the test information for use in other parts of Drupal. $test_info =& $GLOBALS['drupal_test_info']; $test_info['test_run_id'] = $this->databasePrefix; $test_info['in_child_site'] = FALSE; // Indicate the environment was set up correctly. $this->setupEnvironment = TRUE; }
protected function getTestProfile() { // returns current profile return drupal_get_profile(); }
/** * Installation task; perform final steps and display a 'finished' page. * * @param $install_state * An array of information about the current installation state. * @return * A message informing the user that the installation is complete. */ function install_finished(&$install_state) { drupal_set_title(st('@drupal installation complete', array('@drupal' => drupal_install_profile_distribution_name())), PASS_THROUGH); $messages = drupal_set_message(); $output = '<p>' . st('Congratulations, you installed @drupal!', array('@drupal' => drupal_install_profile_distribution_name())) . '</p>'; $output .= '<p>' . (isset($messages['error']) ? st('Review the messages above before visiting <a href="@url">your new site</a>.', array('@url' => url(''))) : st('<a href="@url">Visit your new site</a>.', array('@url' => url('')))) . '</p>'; // Rebuild the module and theme data, in case any newly-installed modules // need to modify it via hook_system_info_alter(). We need to clear the // theme static cache first, to make sure that the theme data is actually // rebuilt. drupal_static_reset('_system_rebuild_theme_data'); system_rebuild_module_data(); system_rebuild_theme_data(); // Flush all caches to ensure that any full bootstraps during the installer // do not leave stale cached data, and that any content types or other items // registered by the install profile are registered correctly. drupal_flush_all_caches(); // Register actions declared by any modules. actions_synchronize(); // Remember the profile which was used. variable_set('install_profile', drupal_get_profile()); // Install profiles are always loaded last db_update('system')->fields(array('weight' => 1000))->condition('type', 'module')->condition('name', drupal_get_profile())->execute(); // Cache a fully-built schema. drupal_get_schema(NULL, TRUE); // Run cron to populate update status tables (if available) so that users // will be warned if they've installed an out of date Drupal version. // Will also trigger indexing of profile-supplied content or feeds. drupal_cron_run(); return $output; }
/** * Tests that drupal_get_profile() returns NULL. * * As the currently active installation profile is used when installing * configuration, for example, this is essential to ensure test isolation. */ public function testDrupalGetProfile() { $this->assertNull(drupal_get_profile()); }
/** * {@inheritdoc} */ public function getAllModules(FeaturesBundleInterface $bundle = NULL) { // ModuleHandler::getModuleDirectories() returns data only for installed // modules. system_rebuild_module_data() includes only the site's install // profile directory, while we may need to include a custom profile. // @see _system_rebuild_module_data(). $listing = new ExtensionDiscovery(\Drupal::root()); $profile_directories = []; // Register the install profile. $installed_profile = drupal_get_profile(); if ($installed_profile) { $profile_directories[] = drupal_get_path('profile', $installed_profile); } if (isset($bundle) && $bundle->isProfile()) { $profile_directory = 'profiles/' . $bundle->getProfileName(); if ($bundle->getProfileName() != $installed_profile && is_dir($profile_directory)) { $profile_directories[] = $profile_directory; } } $listing->setProfileDirectories($profile_directories); // Find modules. $modules = $listing->scan('module'); // Find installation profiles. $profiles = $listing->scan('profile'); foreach ($profiles as $key => $profile) { $modules[$key] = $profile; } $return = array(); // Detect modules by namespace. // If namespace is provided but is empty, then match all modules. foreach ($modules as $module_name => $extension) { if ($this->isFeatureModule($extension) && (!isset($bundle) || $bundle->isDefault() || $bundle->inBundle($module_name))) { $return[$module_name] = $extension; } } return $return; }
/** * Returns a map of all config object names and their folders. * * The list is based on installed modules and themes. The active * configuration storage is used rather than * \Drupal\Core\Extension\ModuleHandler and * \Drupal\Core\Extension\ThemeHandler in order to resolve circular * dependencies between these services and * \Drupal\Core\Config\ConfigInstaller and * \Drupal\Core\Config\TypedConfigManager. * * NOTE: This code is copied from ExtensionInstallStorage::getAllFolders() with * the following changes (Notes in CHANGED below) * - Load all modules whether installed or not * * @return array * An array mapping config object names with directories. */ public function getAllFolders() { if (!isset($this->folders)) { $this->folders = array(); $this->folders += $this->getCoreNames(); $install_profile = Settings::get('install_profile'); $profile = drupal_get_profile(); $extensions = $this->configStorage->read('core.extension'); // @todo Remove this scan as part of https://www.drupal.org/node/2186491 $listing = new ExtensionDiscovery(\Drupal::root()); // CHANGED START: Add profile directories for any bundles that use a profile. $profile_directories = []; if ($profile) { $profile_directories[] = drupal_get_path('profile', $profile); } if ($this->includeProfile) { // Add any profiles used in bundles. /** @var \Drupal\features\FeaturesAssignerInterface $assigner */ $assigner = \Drupal::service('features_assigner'); $bundles = $assigner->getBundleList(); foreach ($bundles as $bundle_name => $bundle) { if ($bundle->isProfile()) { // Register the profile directory. $profile_directory = 'profiles/' . $bundle->getProfileName(); if (is_dir($profile_directory)) { $profile_directories[] = $profile_directory; } } } } $listing->setProfileDirectories($profile_directories); // CHANGED END if (!empty($extensions['module'])) { // CHANGED START: Find ANY modules, not just installed ones. //$modules = $extensions['module']; $module_list_scan = $listing->scan('module'); $modules = $module_list_scan; // CHANGED END // Remove the install profile as this is handled later. unset($modules[$install_profile]); $profile_list = $listing->scan('profile'); if ($profile && isset($profile_list[$profile])) { // Prime the drupal_get_filename() static cache with the profile info // file location so we can use drupal_get_path() on the active profile // during the module scan. // @todo Remove as part of https://www.drupal.org/node/2186491 drupal_get_filename('profile', $profile, $profile_list[$profile]->getPathname()); } $module_list = array(); foreach (array_keys($module_list_scan) as $module) { if (isset($module_list_scan[$module])) { $module_list[$module] = $module_list_scan[$module]; } } $this->folders += $this->getComponentNames($module_list); } if (!empty($extensions['theme'])) { $theme_list_scan = $listing->scan('theme'); foreach (array_keys($extensions['theme']) as $theme) { if (isset($theme_list_scan[$theme])) { $theme_list[$theme] = $theme_list_scan[$theme]; } } $this->folders += $this->getComponentNames($theme_list); } if ($this->includeProfile) { // The install profile can override module default configuration. We do // this by replacing the config file path from the module/theme with the // install profile version if there are any duplicates. if (isset($profile)) { if (!isset($profile_list)) { $profile_list = $listing->scan('profile'); } if (isset($profile_list[$profile])) { $profile_folders = $this->getComponentNames(array($profile_list[$profile])); $this->folders = $profile_folders + $this->folders; } } } } return $this->folders; }
/** * Verifies that installation succeeded. */ public function testInstaller() { $this->assertUrl('user/1'); $this->assertResponse(200); $this->assertEqual('testing', drupal_get_profile(), 'Profile was changed from minimal to testing during interactive install.'); }
/** * {@inheritdoc} */ public function uninstall(array $module_list, $uninstall_dependents = TRUE) { // Get all module data so we can find dependencies and sort. $module_data = system_rebuild_module_data(); $module_list = $module_list ? array_combine($module_list, $module_list) : array(); if (array_diff_key($module_list, $module_data)) { // One or more of the given modules doesn't exist. return FALSE; } // Only process currently installed modules. $extension_config = \Drupal::config('core.extension'); $installed_modules = $extension_config->get('module') ?: array(); if (!($module_list = array_intersect_key($module_list, $installed_modules))) { // Nothing to do. All modules already uninstalled. return TRUE; } if ($uninstall_dependents) { // Add dependent modules to the list. The new modules will be processed as // the while loop continues. $profile = drupal_get_profile(); while (list($module) = each($module_list)) { foreach (array_keys($module_data[$module]->required_by) as $dependent) { if (!isset($module_data[$dependent])) { // The dependent module does not exist. return FALSE; } // Skip already uninstalled modules. if (isset($installed_modules[$dependent]) && !isset($module_list[$dependent]) && $dependent != $profile) { $module_list[$dependent] = $dependent; } } } } // Set the actual module weights. $module_list = array_map(function ($module) use($module_data) { return $module_data[$module]->sort; }, $module_list); // Sort the module list by their weights. asort($module_list); $module_list = array_keys($module_list); // Only process modules that are enabled. A module is only enabled if it is // configured as enabled. Custom or overridden module handlers might contain // the module already, which means that it might be loaded, but not // necessarily installed. $schema_store = \Drupal::keyValue('system.schema'); $entity_manager = \Drupal::entityManager(); foreach ($module_list as $module) { // Clean up all entity bundles (including fields) of every entity type // provided by the module that is being uninstalled. foreach ($entity_manager->getDefinitions() as $entity_type_id => $entity_type) { if ($entity_type->getProvider() == $module) { foreach (array_keys($entity_manager->getBundleInfo($entity_type_id)) as $bundle) { $entity_manager->onBundleDelete($bundle, $entity_type_id); } } } // Allow modules to react prior to the uninstallation of a module. $this->invokeAll('module_preuninstall', array($module)); // Uninstall the module. module_load_install($module); $this->invoke($module, 'uninstall'); // Remove all configuration belonging to the module. \Drupal::service('config.manager')->uninstall('module', $module); // Notify the entity manager that this module's entity types are being // deleted, so that it can notify all interested handlers. For example, // a SQL-based storage handler can use this as an opportunity to drop // the corresponding database tables. foreach ($entity_manager->getDefinitions() as $entity_type) { if ($entity_type->getProvider() == $module) { $entity_manager->onEntityTypeDelete($entity_type); } } // Remove the schema. drupal_uninstall_schema($module); // Remove the module's entry from the config. $extension_config->clear("module.{$module}")->save(); // Update the module handler to remove the module. // The current ModuleHandler instance is obsolete with the kernel rebuild // below. $module_filenames = $this->getModuleList(); unset($module_filenames[$module]); $this->setModuleList($module_filenames); // Remove any potential cache bins provided by the module. $this->removeCacheBins($module); // Clear the static cache of system_rebuild_module_data() to pick up the // new module, since it merges the installation status of modules into // its statically cached list. drupal_static_reset('system_rebuild_module_data'); // Clear plugin manager caches and flag router to rebuild if requested. \Drupal::getContainer()->get('plugin.cache_clearer')->clearCachedDefinitions(); \Drupal::service('router.builder_indicator')->setRebuildNeeded(); // Update the kernel to exclude the uninstalled modules. \Drupal::service('kernel')->updateModules($module_filenames, $module_filenames); // Update the theme registry to remove the newly uninstalled module. drupal_theme_rebuild(); // Modules can alter theme info, so refresh theme data. // @todo ThemeHandler cannot be injected into ModuleHandler, since that // causes a circular service dependency. // @see https://drupal.org/node/2208429 \Drupal::service('theme_handler')->refreshInfo(); \Drupal::logger('system')->info('%module module uninstalled.', array('%module' => $module)); $schema_store->delete($module); } drupal_get_installed_schema_version(NULL, TRUE); // Let other modules react. $this->invokeAll('modules_uninstalled', array($module_list)); return TRUE; }
/** * Returns a map of all config object names and their folders. * * @return array * An array mapping config object names with directories. */ protected function getAllFolders() { if (!isset($this->folders)) { $this->folders = array(); $this->folders += $this->getComponentNames('core', array('core')); // @todo Refactor getComponentNames() to use the extension list directly. if ($profile = drupal_get_profile()) { $this->folders += $this->getComponentNames('profile', array($profile)); } $listing = new ExtensionDiscovery(); $this->folders += $this->getComponentNames('module', array_keys($listing->scan('module'))); $this->folders += $this->getComponentNames('theme', array_keys($listing->scan('theme'))); } return $this->folders; }
/** * {@inheritdoc} */ public function assignPackages($force = FALSE) { $current_bundle = $this->assigner->getBundle(); $settings = $current_bundle->getAssignmentSettings(self::METHOD_ID); $config_collection = $this->featuresManager->getConfigCollection(); // Exclude by configuration type. $exclude_types = $settings['types']['config']; if (!empty($exclude_types)) { foreach ($config_collection as $item_name => $item) { // Don't exclude already-assigned items. if (empty($item->getPackage()) && in_array($item->getType(), $exclude_types)) { $item->setExcluded(TRUE); } } } // Exclude configuration already provided by modules. $exclude_module = $settings['module']; if (!empty($exclude_module['installed'])) { $install_list = $this->featuresManager->getExtensionStorages()->listAll(); // There are two settings that can limit what's included. // First, we can skip configuration provided by the install profile. $module_profile = !empty($exclude_module['profile']); // Second, we can skip configuration provided by namespaced modules. $module_namespace = !empty($exclude_module['namespace']); if ($module_profile || $module_namespace) { $profile_list = []; $extension_list = []; // Load the names of any configuration objects provided by the install // profile. if ($module_profile) { $all_modules = $this->featuresManager->getAllModules(); // FeaturesBundleInterface::getProfileName() would return the profile // for the current bundle, if any. We want the profile that was // installed. $profile_name = drupal_get_profile(); if (isset($all_modules[$profile_name])) { $profile_list = $this->featuresManager->listExtensionConfig($all_modules[$profile_name]); // If the configuration has been assigned to a feature that's // present on the file system, don't make an exception for it. foreach ($all_modules as $name => $extension) { if ($name != $profile_name && $this->featuresManager->isFeatureModule($extension)) { $profile_list = array_diff($profile_list, $this->featuresManager->listExtensionConfig($extension)); } } } } // Load the names of any configuration objects provided by modules // having the namespace of the current package set. if ($module_namespace) { $modules = $this->featuresManager->getFeaturesModules($current_bundle); foreach ($modules as $extension) { $extension_list = array_merge($extension_list, $this->featuresManager->listExtensionConfig($extension)); } } // If any configuration was found, remove it from the list. $install_list = array_diff($install_list, $profile_list, $extension_list); } foreach ($install_list as $item_name) { if (isset($config_collection[$item_name])) { // Flag extension-provided configuration, which should not be added // to regular features but can be added to an install profile. $config_collection[$item_name]->setExtensionProvided(TRUE); } } } // Exclude configuration items on a curated list of site-specific // configuration. if ($settings['curated']) { $item_names = ['core.extension', 'field.settings', 'field_ui.settings', 'filter.settings', 'forum.settings', 'image.settings', 'node.settings', 'system.authorize', 'system.date', 'system.file', 'system.diff', 'system.logging', 'system.maintenance', 'system.performance', 'system.site', 'update.settings']; foreach ($item_names as $item_name) { unset($config_collection[$item_name]); } // Unset role-related actions that are automatically created by the // User module. // @see user_user_role_insert() $prefixes = ['system.action.user_add_role_action.', 'system.action.user_remove_role_action.']; foreach (array_keys($config_collection) as $item_name) { foreach ($prefixes as $prefix) { if (strpos($item_name, $prefix) === 0) { unset($config_collection[$item_name]); } } } } // Register the updated data. $this->featuresManager->setConfigCollection($config_collection); }
/** * Returns a map of all config object names and their folders. * * @return array * An array mapping config object names with directories. */ protected function getAllFolders() { if (!isset($this->folders)) { $this->folders = array(); $this->folders += $this->getCoreNames(); // Perform an ExtensionDiscovery scan as we cannot use drupal_get_path() // yet because the system module may not yet be enabled during install. // @todo Remove as part of https://www.drupal.org/node/2186491 $listing = new ExtensionDiscovery(\Drupal::root()); if ($profile = drupal_get_profile()) { $profile_list = $listing->scan('profile'); if (isset($profile_list[$profile])) { // Prime the drupal_get_filename() static cache with the profile info // file location so we can use drupal_get_path() on the active profile // during the module scan. // @todo Remove as part of https://www.drupal.org/node/2186491 drupal_get_filename('profile', $profile, $profile_list[$profile]->getPathname()); $this->folders += $this->getComponentNames(array($profile_list[$profile])); } } // @todo Remove as part of https://www.drupal.org/node/2186491 $this->folders += $this->getComponentNames($listing->scan('module')); $this->folders += $this->getComponentNames($listing->scan('theme')); } return $this->folders; }
function get_profile() { return drupal_get_profile(); }
/** * {@inheritdoc} */ public function collect(Request $request, Response $response, \Exception $exception = NULL) { $this->data['version'] = Drupal::VERSION; $this->data['profile'] = drupal_get_profile(); $this->data['config_url'] = $this->urlGenerator->generateFromRoute('webprofiler.settings', [], ['query' => $this->redirectDestination->getAsArray()]); }
/** * Sets installation profile directories based on current site settings. * * @return $this */ public function setProfileDirectoriesFromSettings() { $this->profileDirectories = array(); $profile = drupal_get_profile(); // For SimpleTest to be able to test modules packaged together with a // distribution we need to include the profile of the parent site (in // which test runs are triggered). if (drupal_valid_test_ua() && !drupal_installation_attempted()) { $testing_profile = \Drupal::config('simpletest.settings')->get('parent_profile'); if ($testing_profile && $testing_profile != $profile) { $this->profileDirectories[] = drupal_get_path('profile', $testing_profile); } } // In case both profile directories contain the same extension, the actual // profile always has precedence. if ($profile) { $this->profileDirectories[] = drupal_get_path('profile', $profile); } return $this; }
/** * Installation task; perform final steps and display a 'finished' page. * * @param $install_state * An array of information about the current installation state. * @return * A message informing the user that the installation is complete. */ function install_finished(&$install_state) { drupal_set_title(st('@drupal installation complete', array('@drupal' => drupal_install_profile_name())), PASS_THROUGH); $messages = drupal_set_message(); $output = '<p>' . st('Congratulations, @drupal has been successfully installed.', array('@drupal' => drupal_install_profile_name())) . '</p>'; $output .= '<p>' . (isset($messages['error']) ? st('Review the messages above before continuing on to <a href="@url">your new site</a>.', array('@url' => url(''))) : st('You may now visit <a href="@url">your new site</a>.', array('@url' => url('')))) . '</p>'; if (module_exists('help')) { $output .= '<p>' . st('For more information on configuring Drupal, refer to the <a href="@help">help section</a>.', array('@help' => url('admin/help'))) . '</p>'; } // Rebuild the module and theme data, in case any newly-installed modules // need to modify it via hook_system_info_alter(). We need to clear the // theme static cache first, to make sure that the theme data is actually // rebuilt. drupal_static_reset('_system_rebuild_theme_data'); system_rebuild_module_data(); system_rebuild_theme_data(); // Rebuild menu and registry to get content type links registered by the // profile, and possibly any other menu items created through the tasks. menu_rebuild(); // Rebuild the database cache of node types, so that any node types added // by newly installed modules are registered correctly and initialized with // the necessary fields. node_types_rebuild(); // Register actions declared by any modules. actions_synchronize(); // Randomize query-strings on css/js files, to hide the fact that this is a // new install, not upgraded yet. _drupal_flush_css_js(); // Remember the profile which was used. variable_set('install_profile', drupal_get_profile()); // Install profiles are always loaded last db_update('system')->fields(array('weight' => 1000))->condition('type', 'module')->condition('name', drupal_get_profile())->execute(); // Cache a fully-built schema. drupal_get_schema(NULL, TRUE); // Run cron to populate update status tables (if available) so that users // will be warned if they've installed an out of date Drupal version. // Will also trigger indexing of profile-supplied content or feeds. drupal_cron_run(); return $output; }