12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256 |
- <?php
- use Drupal\Component\Utility\Crypt;
- use Drupal\Component\Utility\OpCodeCache;
- use Drupal\Component\Utility\Unicode;
- use Drupal\Component\Utility\UrlHelper;
- use Drupal\Core\Extension\Dependency;
- use Drupal\Core\Extension\ExtensionDiscovery;
- use Drupal\Core\File\FileSystemInterface;
- use Drupal\Core\Installer\InstallerKernel;
- use Drupal\Core\Site\Settings;
- use Symfony\Component\HttpFoundation\RedirectResponse;
- const REQUIREMENT_INFO = -1;
- const REQUIREMENT_OK = 0;
- const REQUIREMENT_WARNING = 1;
- const REQUIREMENT_ERROR = 2;
- const FILE_EXIST = 1;
- const FILE_READABLE = 2;
- const FILE_WRITABLE = 4;
- const FILE_EXECUTABLE = 8;
- const FILE_NOT_EXIST = 16;
- const FILE_NOT_READABLE = 32;
- const FILE_NOT_WRITABLE = 64;
- const FILE_NOT_EXECUTABLE = 128;
- function drupal_load_updates() {
-
- $extension_list_module = \Drupal::service('extension.list.module');
- foreach (drupal_get_installed_schema_version(NULL, FALSE, TRUE) as $module => $schema_version) {
- if ($extension_list_module->exists($module) && !$extension_list_module->checkIncompatibility($module)) {
- if ($schema_version > -1) {
- module_load_install($module);
- }
- }
- }
- }
- function drupal_install_profile_distribution_name() {
-
-
- $info = [];
- if (InstallerKernel::installationAttempted()) {
- global $install_state;
- if (isset($install_state['profile_info'])) {
- $info = $install_state['profile_info'];
- }
- }
-
- else {
- $profile = \Drupal::installProfile();
- $info = \Drupal::service('extension.list.profile')->getExtensionInfo($profile);
- }
- return isset($info['distribution']['name']) ? $info['distribution']['name'] : 'Drupal';
- }
- function drupal_install_profile_distribution_version() {
-
-
- if (InstallerKernel::installationAttempted()) {
- global $install_state;
- return isset($install_state['profile_info']['version']) ? $install_state['profile_info']['version'] : \Drupal::VERSION;
- }
-
- else {
- $profile = \Drupal::installProfile();
- $info = \Drupal::service('extension.list.profile')->getExtensionInfo($profile);
- return $info['version'];
- }
- }
- function drupal_detect_database_types() {
- $databases = drupal_get_database_types();
- foreach ($databases as $driver => $installer) {
- $databases[$driver] = $installer->name();
- }
- return $databases;
- }
- function drupal_get_database_types() {
- $databases = [];
- $drivers = [];
-
- $mask = ExtensionDiscovery::PHP_FUNCTION_PATTERN;
-
-
- $file_system = \Drupal::service('file_system');
- $files = $file_system->scanDirectory(DRUPAL_ROOT . '/core/lib/Drupal/Core/Database/Driver', $mask, ['recurse' => FALSE]);
- if (is_dir(DRUPAL_ROOT . '/drivers/lib/Drupal/Driver/Database')) {
- $files += $file_system->scanDirectory(DRUPAL_ROOT . '/drivers/lib/Drupal/Driver/Database/', $mask, ['recurse' => FALSE]);
- }
- foreach ($files as $file) {
- if (file_exists($file->uri . '/Install/Tasks.php')) {
-
-
- $drivers[$file->filename] = NULL;
- }
- }
-
-
- $class_loader = \Drupal::service('class_loader');
-
- $extension_discovery = new ExtensionDiscovery(DRUPAL_ROOT, FALSE, []);
- $modules = $extension_discovery->scan('module');
- foreach ($modules as $module) {
- $module_driver_path = DRUPAL_ROOT . '/' . $module->getPath() . '/src/Driver/Database';
- if (is_dir($module_driver_path)) {
- $driver_files = $file_system->scanDirectory($module_driver_path, $mask, ['recurse' => FALSE]);
- foreach ($driver_files as $driver_file) {
- $tasks_file = $module_driver_path . '/' . $driver_file->filename . '/Install/Tasks.php';
- if (file_exists($tasks_file)) {
- $namespace = 'Drupal\\' . $module->getName() . '\\Driver\\Database\\' . $driver_file->filename;
-
-
- $drivers[$driver_file->filename] = $namespace;
-
-
-
-
- $class_loader->addPsr4($namespace . '\\', $module->getPath() . '/src/Driver/Database/' . $driver_file->filename);
- }
- }
- }
- }
- foreach ($drivers as $driver => $namespace) {
- $installer = db_installer_object($driver, $namespace);
- if ($installer->installable()) {
- $databases[$driver] = $installer;
- }
- }
-
- if (isset($databases['mysql'])) {
- $mysql_database = $databases['mysql'];
- unset($databases['mysql']);
- $databases = ['mysql' => $mysql_database] + $databases;
- }
- return $databases;
- }
- function drupal_rewrite_settings($settings = [], $settings_file = NULL) {
- if (!isset($settings_file)) {
- $settings_file = \Drupal::service('site.path') . '/settings.php';
- }
-
- $variable_names = [];
- $settings_settings = [];
- foreach ($settings as $setting => $data) {
- if ($setting != 'settings') {
- _drupal_rewrite_settings_global($GLOBALS[$setting], $data);
- }
- else {
- _drupal_rewrite_settings_global($settings_settings, $data);
- }
- $variable_names['$' . $setting] = $setting;
- }
- $contents = file_get_contents($settings_file);
- if ($contents !== FALSE) {
-
- if (trim($contents) === '') {
- $contents = "<?php\n";
- }
-
-
- $buffer = '';
- $state = 'default';
- foreach (token_get_all($contents) as $token) {
- if (is_array($token)) {
- list($type, $value) = $token;
- }
- else {
- $type = -1;
- $value = $token;
- }
-
- if (!in_array($type, [T_WHITESPACE, T_COMMENT, T_DOC_COMMENT])) {
- switch ($state) {
- case 'default':
- if ($type === T_VARIABLE && isset($variable_names[$value])) {
-
- $parent = &$settings;
-
- $index = $variable_names[$value];
-
- $current = &$parent[$index];
- $state = 'candidate_left';
- }
- break;
- case 'candidate_left':
- if ($value == '[') {
- $state = 'array_index';
- }
- if ($value == '=') {
- $state = 'candidate_right';
- }
- break;
- case 'array_index':
- if (_drupal_rewrite_settings_is_array_index($type, $value)) {
- $index = trim($value, '\'"');
- $state = 'right_bracket';
- }
- else {
-
- throw new Exception('invalid array index');
- }
- break;
- case 'right_bracket':
- if ($value == ']') {
- if (isset($current[$index])) {
-
- $parent = &$current;
- $current = &$parent[$index];
- $state = 'candidate_left';
- }
- else {
-
- $state = 'wait_for_semicolon';
- }
- }
- else {
-
- throw new Exception('] expected');
- }
- break;
- case 'candidate_right':
- if (_drupal_rewrite_settings_is_simple($type, $value)) {
- $value = _drupal_rewrite_settings_dump_one($current);
-
- unset($parent[$index]);
-
- $state = 'semicolon_skip';
- }
- else {
- $state = 'wait_for_semicolon';
- }
- break;
- case 'wait_for_semicolon':
- if ($value == ';') {
- $state = 'default';
- }
- break;
- case 'semicolon_skip':
- if ($value == ';') {
- $value = '';
- $state = 'default';
- }
- else {
-
-
- throw new Exception('Unexpected token after replacing value.');
- }
- break;
- }
- }
- $buffer .= $value;
- }
- foreach ($settings as $name => $setting) {
- $buffer .= _drupal_rewrite_settings_dump($setting, '$' . $name);
- }
-
- if (file_put_contents($settings_file, $buffer) === FALSE) {
- throw new Exception("Failed to modify '$settings_file'. Verify the file permissions.");
- }
- else {
-
-
- if (!empty($settings_settings)) {
- $old_settings = Settings::getAll();
- new Settings($settings_settings + $old_settings);
- }
-
-
-
-
- OpCodeCache::invalidate(DRUPAL_ROOT . '/' . $settings_file);
- }
- }
- else {
- throw new Exception("Failed to open '$settings_file'. Verify the file permissions.");
- }
- }
- function _drupal_rewrite_settings_is_simple($type, $value) {
- $is_integer = $type == T_LNUMBER;
- $is_float = $type == T_DNUMBER;
- $is_string = $type == T_CONSTANT_ENCAPSED_STRING;
- $is_boolean_or_null = $type == T_STRING && in_array(strtoupper($value), ['TRUE', 'FALSE', 'NULL']);
- return $is_integer || $is_float || $is_string || $is_boolean_or_null;
- }
- function _drupal_rewrite_settings_is_array_index($type) {
- $is_integer = $type == T_LNUMBER;
- $is_float = $type == T_DNUMBER;
- $is_string = $type == T_CONSTANT_ENCAPSED_STRING;
- return $is_integer || $is_float || $is_string;
- }
- function _drupal_rewrite_settings_global(&$ref, $variable) {
- if (is_object($variable)) {
- $ref = $variable->value;
- }
- else {
- foreach ($variable as $k => $v) {
- _drupal_rewrite_settings_global($ref[$k], $v);
- }
- }
- }
- function _drupal_rewrite_settings_dump($variable, $variable_name) {
- $return = '';
- if (is_object($variable)) {
- if (!empty($variable->required)) {
- $return .= _drupal_rewrite_settings_dump_one($variable, "$variable_name = ", "\n");
- }
- }
- else {
- foreach ($variable as $k => $v) {
- $return .= _drupal_rewrite_settings_dump($v, $variable_name . "['" . $k . "']");
- }
- }
- return $return;
- }
- function _drupal_rewrite_settings_dump_one(\stdClass $variable, $prefix = '', $suffix = '') {
- $return = $prefix . var_export($variable->value, TRUE) . ';';
- if (!empty($variable->comment)) {
- $return .= ' // ' . $variable->comment;
- }
- $return .= $suffix;
- return $return;
- }
- function drupal_install_config_directories() {
- @trigger_error('drupal_install_config_directories() is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. There is no replacement. See https://www.drupal.org/node/3018145.', E_USER_DEPRECATED);
- global $config_directories, $install_state;
-
-
- if (empty($config_directories[CONFIG_SYNC_DIRECTORY])) {
- if (empty($install_state['config_install_path'])) {
-
- $config_directories[CONFIG_SYNC_DIRECTORY] = \Drupal::service('site.path') . '/files/config_' . Crypt::randomBytesBase64(55) . '/sync';
- }
- else {
-
-
- $config_directories[CONFIG_SYNC_DIRECTORY] = $install_state['config_install_path'];
- }
- $settings['config_directories'][CONFIG_SYNC_DIRECTORY] = (object) [
- 'value' => $config_directories[CONFIG_SYNC_DIRECTORY],
- 'required' => TRUE,
- ];
-
- drupal_rewrite_settings($settings);
- }
-
-
-
-
-
-
- if (!\Drupal::service('file_system')->prepareDirectory($config_directories[CONFIG_SYNC_DIRECTORY], FileSystemInterface::CREATE_DIRECTORY)
- && !file_exists($config_directories[CONFIG_SYNC_DIRECTORY])) {
- throw new Exception("The directory '" . config_get_config_directory(CONFIG_SYNC_DIRECTORY) . "' could not be created. To proceed with the installation, either create the directory or ensure that the installer has the permissions to create it automatically. For more information, see the <a href='https://www.drupal.org/server-permissions'>online handbook</a>.");
- }
- elseif (is_writable($config_directories[CONFIG_SYNC_DIRECTORY])) {
-
-
-
-
- $text = 'This directory contains configuration to be imported into your Drupal site. To make this configuration active, visit admin/config/development/configuration/sync.' . ' For information about deploying configuration between servers, see https://www.drupal.org/documentation/administer/config';
- file_put_contents(config_get_config_directory(CONFIG_SYNC_DIRECTORY) . '/README.txt', "$text\n");
- }
- }
- function install_ensure_config_directory($type) {
- @trigger_error('install_ensure_config_directory() is deprecated in Drupal 8.1.0 and will be removed before Drupal 9.0.0. Use config_get_config_directory() and \Drupal\Core\File\FileSystemInterface::prepareDirectory() instead. See https://www.drupal.org/node/2501187.', E_USER_DEPRECATED);
-
- global $config_directories;
- if (!isset($config_directories[$type])) {
- return FALSE;
- }
-
-
- else {
- $config_directory = config_get_config_directory($type);
- return \Drupal::service('file_system')->prepareDirectory($config_directory, FileSystemInterface::CREATE_DIRECTORY | FileSystemInterface::MODIFY_PERMISSIONS);
- }
- }
- function drupal_verify_profile($install_state) {
- $profile = $install_state['parameters']['profile'];
- $info = $install_state['profile_info'];
-
- $listing = new ExtensionDiscovery(\Drupal::root());
- $present_modules = [];
- foreach ($listing->scan('module') as $present_module) {
- $present_modules[] = $present_module->getName();
- }
-
-
- $present_modules[] = $profile;
-
- $missing_modules = array_diff($info['install'], $present_modules);
- $requirements = [];
- if ($missing_modules) {
- $build = [
- '#theme' => 'item_list',
- '#context' => ['list_style' => 'comma-list'],
- ];
- foreach ($missing_modules as $module) {
- $build['#items'][] = ['#markup' => '<span class="admin-missing">' . Unicode::ucfirst($module) . '</span>'];
- }
- $modules_list = \Drupal::service('renderer')->renderPlain($build);
- $requirements['required_modules'] = [
- 'title' => t('Required modules'),
- 'value' => t('Required modules not found.'),
- 'severity' => REQUIREMENT_ERROR,
- 'description' => t('The following modules are required but were not found. Move them into the appropriate modules subdirectory, such as <em>/modules</em>. Missing modules: @modules', ['@modules' => $modules_list]),
- ];
- }
- return $requirements;
- }
- function drupal_install_system($install_state) {
-
- unset($GLOBALS['conf']['container_service_providers']['InstallerServiceProvider']);
-
- $GLOBALS['conf']['container_service_providers']['InstallerServiceProvider'] = 'Drupal\Core\Installer\NormalInstallerServiceProvider';
-
- $request = \Drupal::request();
-
-
- $kernel = \Drupal::service('kernel');
- $kernel->shutdown();
-
- $kernel->rebuildContainer(FALSE);
-
- $kernel->boot();
- $kernel->preHandle($request);
-
- if (PHP_SAPI !== 'cli') {
- $request->setSession($kernel->getContainer()->get('session'));
- }
-
-
-
-
-
- \Drupal::service('extension.list.module')->setPathname('system', 'core/modules/system/system.info.yml');
-
- \Drupal::service('config.installer')->installDefaultConfig('core', 'core');
-
-
- \Drupal::configFactory()->getEditable('core.extension')
- ->set('profile', $install_state['parameters']['profile'])
- ->save();
-
- $kernel->getContainer()->get('module_installer')->install(['system'], FALSE);
- \Drupal::service('router.builder')->rebuild();
-
- if (isset($install_state['parameters']['langcode'])) {
- \Drupal::configFactory()->getEditable('system.site')
- ->set('langcode', (string) $install_state['parameters']['langcode'])
- ->set('default_langcode', (string) $install_state['parameters']['langcode'])
- ->save(TRUE);
- }
- }
- function drupal_verify_install_file($file, $mask = NULL, $type = 'file', $autofix = TRUE) {
- $return = TRUE;
-
- if (isset($mask) && ($mask & FILE_NOT_EXIST) && file_exists($file)) {
- return FALSE;
- }
-
- if (isset($type) && file_exists($file)) {
- $check = 'is_' . $type;
- if (!function_exists($check) || !$check($file)) {
- $return = FALSE;
- }
- }
-
- if (isset($mask)) {
- $masks = [FILE_EXIST, FILE_READABLE, FILE_WRITABLE, FILE_EXECUTABLE, FILE_NOT_READABLE, FILE_NOT_WRITABLE, FILE_NOT_EXECUTABLE];
- foreach ($masks as $current_mask) {
- if ($mask & $current_mask) {
- switch ($current_mask) {
- case FILE_EXIST:
- if (!file_exists($file)) {
- if ($type == 'dir' && $autofix) {
- drupal_install_mkdir($file, $mask);
- }
- if (!file_exists($file)) {
- $return = FALSE;
- }
- }
- break;
- case FILE_READABLE:
- if (!is_readable($file)) {
- $return = FALSE;
- }
- break;
- case FILE_WRITABLE:
- if (!is_writable($file)) {
- $return = FALSE;
- }
- break;
- case FILE_EXECUTABLE:
- if (!is_executable($file)) {
- $return = FALSE;
- }
- break;
- case FILE_NOT_READABLE:
- if (is_readable($file)) {
- $return = FALSE;
- }
- break;
- case FILE_NOT_WRITABLE:
- if (is_writable($file)) {
- $return = FALSE;
- }
- break;
- case FILE_NOT_EXECUTABLE:
- if (is_executable($file)) {
- $return = FALSE;
- }
- break;
- }
- }
- }
- }
- if (!$return && $autofix) {
- return drupal_install_fix_file($file, $mask);
- }
- return $return;
- }
- function drupal_install_mkdir($file, $mask, $message = TRUE) {
- $mod = 0;
- $masks = [FILE_READABLE, FILE_WRITABLE, FILE_EXECUTABLE, FILE_NOT_READABLE, FILE_NOT_WRITABLE, FILE_NOT_EXECUTABLE];
- foreach ($masks as $m) {
- if ($mask & $m) {
- switch ($m) {
- case FILE_READABLE:
- $mod |= 0444;
- break;
- case FILE_WRITABLE:
- $mod |= 0222;
- break;
- case FILE_EXECUTABLE:
- $mod |= 0111;
- break;
- }
- }
- }
- if (@\Drupal::service('file_system')->mkdir($file, $mod)) {
- return TRUE;
- }
- else {
- return FALSE;
- }
- }
- function drupal_install_fix_file($file, $mask, $message = TRUE) {
-
- if (!file_exists($file)) {
- return FALSE;
- }
- $mod = fileperms($file) & 0777;
- $masks = [FILE_READABLE, FILE_WRITABLE, FILE_EXECUTABLE, FILE_NOT_READABLE, FILE_NOT_WRITABLE, FILE_NOT_EXECUTABLE];
-
-
-
-
- foreach ($masks as $m) {
- if ($mask & $m) {
- switch ($m) {
- case FILE_READABLE:
- if (!is_readable($file)) {
- $mod |= 0444;
- }
- break;
- case FILE_WRITABLE:
- if (!is_writable($file)) {
- $mod |= 0222;
- }
- break;
- case FILE_EXECUTABLE:
- if (!is_executable($file)) {
- $mod |= 0111;
- }
- break;
- case FILE_NOT_READABLE:
- if (is_readable($file)) {
- $mod &= ~0444;
- }
- break;
- case FILE_NOT_WRITABLE:
- if (is_writable($file)) {
- $mod &= ~0222;
- }
- break;
- case FILE_NOT_EXECUTABLE:
- if (is_executable($file)) {
- $mod &= ~0111;
- }
- break;
- }
- }
- }
-
- if (@chmod($file, $mod)) {
- return TRUE;
- }
- else {
- return FALSE;
- }
- }
- function install_goto($path) {
- global $base_url;
- $headers = [
-
- 'Cache-Control' => 'no-cache',
- ];
- $response = new RedirectResponse($base_url . '/' . $path, 302, $headers);
- $response->send();
- }
- function drupal_current_script_url($query = []) {
- $uri = $_SERVER['SCRIPT_NAME'];
- $query = array_merge(UrlHelper::filterQueryParameters(\Drupal::request()->query->all()), $query);
- if (!empty($query)) {
- $uri .= '?' . UrlHelper::buildQuery($query);
- }
- return $uri;
- }
- function drupal_requirements_url($severity) {
- $query = [];
-
-
- if ($severity == REQUIREMENT_WARNING) {
- $query['continue'] = 1;
- }
- return drupal_current_script_url($query);
- }
- function drupal_check_profile($profile) {
- $info = install_profile_info($profile);
-
- $requirements = [];
-
-
-
- $drupal_root = \Drupal::root();
- $module_list = (new ExtensionDiscovery($drupal_root))->scan('module');
- foreach ($info['install'] as $module) {
-
-
-
- if (isset($module_list[$module])) {
- $function = $module . '_requirements';
- $module_path = $module_list[$module]->getPath();
- $install_file = "$drupal_root/$module_path/$module.install";
- if (is_file($install_file)) {
- require_once $install_file;
- }
- \Drupal::service('class_loader')->addPsr4('Drupal\\' . $module . '\\', \Drupal::root() . "/$module_path/src");
- if (function_exists($function)) {
- $requirements = array_merge($requirements, $function('install'));
- }
- }
- }
-
- $function = $profile . '_requirements';
- if (function_exists($function)) {
- $requirements = array_merge($requirements, $function('install'));
- }
- return $requirements;
- }
- function drupal_requirements_severity(&$requirements) {
- $severity = REQUIREMENT_OK;
- foreach ($requirements as $requirement) {
- if (isset($requirement['severity'])) {
- $severity = max($severity, $requirement['severity']);
- }
- }
- return $severity;
- }
- function drupal_check_module($module) {
- module_load_install($module);
-
- $requirements = \Drupal::moduleHandler()->invoke($module, 'requirements', ['install']);
- if (is_array($requirements) && drupal_requirements_severity($requirements) == REQUIREMENT_ERROR) {
-
- foreach ($requirements as $requirement) {
- if (isset($requirement['severity']) && $requirement['severity'] == REQUIREMENT_ERROR) {
- $message = $requirement['description'];
- if (isset($requirement['value']) && $requirement['value']) {
- $message = t('@requirements_message (Currently using @item version @version)', ['@requirements_message' => $requirement['description'], '@item' => $requirement['title'], '@version' => $requirement['value']]);
- }
- \Drupal::messenger()->addError($message);
- }
- }
- return FALSE;
- }
- return TRUE;
- }
- function install_profile_info($profile, $langcode = 'en') {
- static $cache = [];
- if (!isset($cache[$profile][$langcode])) {
-
- $defaults = [
- 'dependencies' => [],
- 'install' => [],
- 'themes' => ['stark'],
- 'description' => '',
- 'version' => NULL,
- 'hidden' => FALSE,
- 'php' => DRUPAL_MINIMUM_PHP,
- 'config_install_path' => NULL,
- ];
- $profile_path = drupal_get_path('profile', $profile);
- $info = \Drupal::service('info_parser')->parse("$profile_path/$profile.info.yml");
- $info += $defaults;
- $dependency_name_function = function ($dependency) {
- return Dependency::createFromString($dependency)->getName();
- };
-
- $info['dependencies'] = array_map($dependency_name_function, $info['dependencies']);
-
- $info['install'] = array_map($dependency_name_function, $info['install']);
-
-
- $required = array_diff(drupal_required_modules(), [$profile]);
- $locale = !empty($langcode) && $langcode != 'en' ? ['locale'] : [];
-
-
- $info['install'] = array_unique(array_merge($info['install'], $required, $info['dependencies'], $locale));
-
- if (is_dir($profile_path . '/config/sync')) {
- $info['config_install_path'] = $profile_path . '/config/sync';
- }
- $cache[$profile][$langcode] = $info;
- }
- return $cache[$profile][$langcode];
- }
- function db_installer_object($driver, $namespace = NULL) {
-
-
- if ($namespace) {
- $task_class = $namespace . "\\Install\\Tasks";
- return new $task_class();
- }
-
- $task_class = "Drupal\\Driver\\Database\\{$driver}\\Install\\Tasks";
- if (class_exists($task_class)) {
- return new $task_class();
- }
- else {
-
- $task_class = "Drupal\\Core\\Database\\Driver\\{$driver}\\Install\\Tasks";
- return new $task_class();
- }
- }
|