function mongodb_watchdog_requirements in MongoDB 8.2
Implements hook_requirements().
- Ensure a logger alias
- Ensure the logger alias does not point to the same DB as another alias.
See also
http://blog.riff.org/2015_08_27_drupal_8_tip_of_the_day_autoloaded_code_...
File
- modules/
mongodb_watchdog/ mongodb_watchdog.install, line 34 - MongoDB watchdog install file.
Code
function mongodb_watchdog_requirements($phase) {
if ($phase === 'install') {
// Dependencies may not be installed yet, and module isn't either.
require_once __DIR__ . "/../mongodb/mongodb.module";
require_once __DIR__ . "/../mongodb/src/MongoDb.php";
require_once __DIR__ . "/src/Logger.php";
require_once __DIR__ . "/src/Install/Requirements.php";
// Module is not yet available so its services aren't either.
$requirements = \Drupal::classResolver()
->getInstanceFromDefinition(Requirements::class);
}
else {
// Outside install phase, the whole module is available.
/** @var \Drupal\mongodb_watchdog\Install\Requirements $requirements */
$requirements = \Drupal::service(Logger::SERVICE_REQUIREMENTS);
/** @var \Drupal\mongodb_watchdog\Logger $logger */
$logger = \Drupal::service(Logger::SERVICE_LOGGER);
$logger
->ensureSchema();
}
return $requirements
->check($phase);
}