Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. DriverFactory.php

function DriverFactory::createDriverFromEnv

Return value

Driver|null

File

vendor/revolt/event-loop/src/EventLoop/DriverFactory.php, line 55

Class

DriverFactory

Namespace

Revolt\EventLoop

Code

private function createDriverFromEnv() : ?Driver {
    $driver = \getenv("REVOLT_DRIVER");
    if (!$driver) {
        return null;
    }
    if (!\class_exists($driver)) {
        throw new \Error(\sprintf("Driver '%s' does not exist.", $driver));
    }
    if (!\is_subclass_of($driver, Driver::class)) {
        throw new \Error(\sprintf("Driver '%s' is not a subclass of '%s'.", $driver, Driver::class));
    }
    return new $driver();
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal