function PhpExtensionsValidator::isExtensionLoaded

Indicates if a particular PHP extension is loaded.

Parameters

string $name: The name of the PHP extension to check for.

Return value

bool TRUE if the given extension is loaded, FALSE otherwise.

2 calls to PhpExtensionsValidator::isExtensionLoaded()
PhpExtensionsValidator::validateOpenSsl in core/modules/package_manager/src/Validator/PhpExtensionsValidator.php
Flags an error if the OpenSSL extension is not installed.
PhpExtensionsValidator::validateXdebug in core/modules/package_manager/src/Validator/PhpExtensionsValidator.php
Flags a warning if Xdebug is enabled.

File

core/modules/package_manager/src/Validator/PhpExtensionsValidator.php, line 36

Class

PhpExtensionsValidator
Performs validation if certain PHP extensions are enabled.

Namespace

Drupal\package_manager\Validator

Code

protected final function isExtensionLoaded(string $name) : bool {
    // If and ONLY if we're currently running a test, allow the list of loaded
    // extensions to be overridden by a state variable.
    if (self::insideTest()) {
        // By default, assume OpenSSL is enabled and Xdebug isn't. This allows us
        // to run tests in environments that we might not support in production,
        // such as Drupal CI.
        $loaded_extensions = \Drupal::state()->get('package_manager_loaded_php_extensions', [
            'openssl',
        ]);
        return in_array($name, $loaded_extensions, TRUE);
    }
    return extension_loaded($name);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.