first commit

This commit is contained in:
2024-07-15 12:33:27 +02:00
commit ce50ae282b
22084 changed files with 2623791 additions and 0 deletions

View File

@@ -0,0 +1,62 @@
<?php
/**
* @file
* Locates the Drupal root directory and bootstraps the kernel.
*/
use Drupal\Core\DrupalKernel;
use Symfony\Component\HttpFoundation\Request;
// Immediately return if classes are discoverable (already booted).
if (class_exists('\Drupal\Core\DrupalKernel') && class_exists('\Drupal')) {
return \Drupal::service('kernel');
}
/**
*
*/
function _find_autoloader($dir) {
if (file_exists($autoloadFile = $dir . '/autoload.php') || file_exists($autoloadFile = $dir . '/vendor/autoload.php')) {
return include_once $autoloadFile;
}
elseif (empty($dir) || $dir === DIRECTORY_SEPARATOR) {
return FALSE;
}
return _find_autoloader(dirname($dir));
}
$autoloader = _find_autoloader(empty($_SERVER['PWD']) ? getcwd() : $_SERVER['PWD']);
if (!$autoloader || !class_exists('\Drupal\Core\DrupalKernel')) {
print "This script must be invoked inside a Drupal 8 environment. Unable to continue.\n";
exit();
}
// Create a DrupalKernel instance.
DrupalKernel::bootEnvironment();
$kernel = new DrupalKernel('prod', $autoloader);
// Need to change the current working directory to the actual root path.
// This is needed in case the script is initiated inside a sub-directory.
chdir($kernel->getAppRoot());
// Initialize settings, this requires reflection since its a protected method.
$request = Request::createFromGlobals();
$initializeSettings = new \ReflectionMethod($kernel, 'initializeSettings');
$initializeSettings->setAccessible(TRUE);
$initializeSettings->invokeArgs($kernel, [$request]);
// Boot the kernel.
$kernel->boot();
$kernel->preHandle($request);
// Due to a core bug, the theme handler has to be invoked to register theme
// namespaces with the autoloader.
// @todo Remove once installed_extensions makes its way into core.
// @see https://www.drupal.org/project/drupal/issues/2941757
$container = $kernel->getContainer();
if (!$container->has('installed_extensions')) {
$container->get('theme_handler')->listInfo();
}
return $kernel;

View File

@@ -0,0 +1,88 @@
#!/usr/bin/env php
<?php
/**
* @file
* Generates the markdown documentation for all available theme settings.
*/
/**
* Note: this script is intended to be executed independently via PHP, e.g.:
* $ ./scripts/gen-theme-setting-docs.php
*/
use Drupal\bootstrap\Bootstrap;
use Drupal\bootstrap\Plugin\Setting\DeprecatedSettingInterface;
use Drupal\bootstrap\Plugin\Setting\SettingInterface;
use Drupal\Component\Render\FormattableMarkup;
use Drupal\Component\Utility\Html;
use Drupal\Core\Serialization\Yaml;
$kernel = require_once __DIR__ . '/bootstrap.php';
$bootstrap = Bootstrap::getTheme('bootstrap');
/** @var \Drupal\bootstrap\Plugin\Setting\SettingInterface[] $settings */
$settings = array_filter($bootstrap->getSettingPlugin(NULL, TRUE), function (SettingInterface $setting) {
return !!$setting->getGroups();
});
// Populate the variables with settings.
$variables = ['groups' => []];
$deprecatedSettings = [];
$replacementPairs = [
'&quot;' => '"',
'\n' => "\n",
];
foreach ($settings as $id => $setting) {
$defaultValue = $setting->getDefaultValue();
$deprecated = FALSE;
if ($setting instanceof DeprecatedSettingInterface) {
$newSetting = $setting->getDeprecatedReplacementSetting()->getPluginId();
$deprecated = [
'reason' => new FormattableMarkup($setting->getDeprecatedReason(), []),
'replacement' => new FormattableMarkup('<a href="#@anchor">@setting</a>', [
'@anchor' => Html::cleanCssIdentifier($newSetting),
'@setting' => $newSetting,
]),
'version' => new FormattableMarkup($setting->getDeprecatedVersion(), []),
];
}
$data = [
'id' => $id,
'description' => new FormattableMarkup(strtr($setting->getDescription(), $replacementPairs), []),
'defaultValue' => $defaultValue !== NULL ? new FormattableMarkup(strtr(trim(Yaml::encode([$id => $defaultValue])), $replacementPairs), []) : NULL,
'deprecated' => $deprecated,
];
// Defer adding deprecated settings.
if ($deprecated) {
$deprecatedSettings[$id] = $data;
}
else {
// Only get the first two groups (we don't need 3rd, or more, levels).
$header = implode(' > ', array_slice(array_filter($setting->getGroups()), 0, 2, FALSE));
$variables['groups'][$header][$id] = $data;
}
}
// Add Deprecated settings last (special table).
if ($deprecatedSettings) {
$variables['deprecated'] = $deprecatedSettings;
}
$docsPath = "{$bootstrap->getPath()}/docs";
// Render the settings.
$output = Bootstrap::renderCustomTemplate("{$docsPath}/theme-settings.twig", $variables);
// Save the generated output to the appropriate file.
$result = Bootstrap::putContents("{$docsPath}/Theme-Settings.md", $output, '<!-- THEME SETTINGS GENERATION START -->', '<!-- THEME SETTINGS GENERATION END -->');
if ($result) {
echo 'Successfully generated theme documentation!';
exit(0);
}
echo 'Unable to generate theme documentation!';
exit(1);