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

Breadcrumb

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

function ServiceLoader::providerAvailable

@internal

2 calls to ServiceLoader::providerAvailable()
Plugin::dumpGeneratedServiceProviderData in vendor/tbachert/spi/src/Composer/Plugin.php
ServiceLoader::register in vendor/tbachert/spi/src/ServiceLoader.php
Registers a service provider implementation for the given service type.

File

vendor/tbachert/spi/src/ServiceLoader.php, line 125

Class

ServiceLoader
Service provider loading facility.

Namespace

Nevay\SPI

Code

public static function providerAvailable(string $provider, bool $skipRuntimeValidatedRequirements = false) : bool {
    if (!class_exists($provider)) {
        return false;
    }
    $reflection = new ReflectionClass($provider);
    
    /** @var ReflectionAttribute<ServiceProviderRequirement> $attribute */
    foreach ($reflection->getAttributes(ServiceProviderRequirement::class, ReflectionAttribute::IS_INSTANCEOF) as $attribute) {
        $requirement = $attribute->newInstance();
        if ($skipRuntimeValidatedRequirements && $requirement instanceof ServiceProviderRequirementRuntimeValidated) {
            continue;
        }
        if (!$requirement->isSatisfied()) {
            return false;
        }
    }
    return true;
}

API Navigation

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