Add support for provisioning and rebuilding via interface
This commit is contained in:
parent
f5c5999f44
commit
ddb4bb3546
76 changed files with 1306 additions and 625 deletions
|
|
@ -1,13 +1,28 @@
|
|||
<?php
|
||||
|
||||
use \Drupal\Core\Site\Settings;
|
||||
|
||||
/** gets a setting from 'settings.php' */
|
||||
function get_setting($name) {
|
||||
use \Drupal\Core\Site\Settings;
|
||||
return Settings::get($name);
|
||||
}
|
||||
|
||||
/** sets a setting in 'settings.php' */
|
||||
function set_setting($name, $value) {
|
||||
function set_setting(string $name, mixed $value): bool {
|
||||
// find settings.php
|
||||
$filename = DRUPAL_ROOT . "/" . \Drupal::service("site.path") . "/settings.php";
|
||||
|
||||
// setup user write permissions for the file
|
||||
$old = fileperms($filename);
|
||||
if ($old === FALSE) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$new = 0777; // set all permissions
|
||||
if (!chmod($filename, $new)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// load install.inc
|
||||
if(is_file(DRUPAL_ROOT . "/internal/")) {
|
||||
include_once DRUPAL_ROOT . "/internal/core/includes/install.inc";
|
||||
|
|
@ -21,9 +36,20 @@ function set_setting($name, $value) {
|
|||
"required" => TRUE,
|
||||
];
|
||||
|
||||
// find the filename
|
||||
$filename = DRUPAL_ROOT . "/" . \Drupal::service("site.path") . "/settings.php";
|
||||
drupal_rewrite_settings($settings, $filename);
|
||||
// do the rewrite
|
||||
try {
|
||||
drupal_rewrite_settings($settings, $filename);
|
||||
} catch(Throwable $t) {
|
||||
throw $t; // DEBUG
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return True;
|
||||
|
||||
// reset the file mode
|
||||
return chmod($filename, $old);
|
||||
}
|
||||
|
||||
/** Sets the trusted host to the specified domain */
|
||||
function set_trusted_domain(string $domain): bool {
|
||||
return set_setting("trusted_host_patterns", [preg_quote($domain)]);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue