Skip to content

Instantly share code, notes, and snippets.

@vladdancer
Last active June 21, 2022 10:05
Show Gist options
  • Save vladdancer/7a06505e7b05e364882b5a1b9f354d0e to your computer and use it in GitHub Desktop.
Save vladdancer/7a06505e7b05e364882b5a1b9f354d0e to your computer and use it in GitHub Desktop.
Load PHP class from custom module within settings.php file #php #drupal8+
<?php
/**
* @file
* Load PHP class from custom module within settings.php file.
*/
if (class_exists(ClassLoader::class)) {
$class_loader = new ClassLoader();
$class_loader->addPsr4('Drupal\\mymodule\\', DRUPAL_ROOT . '/modules/custom/mymodule/src');
$class_loader->register();
}
if (!class_exists('Drupal\mymodule\MyModuleConstants')) {
return;
}
$some_constants = \Drupal\mymodule\MymoduleConstants::LEGACY_DB_KEY;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment