function AttributeClassDiscovery::getProviderFromNamespace

Same name in other branches
  1. 11.x core/lib/Drupal/Core/Plugin/Discovery/AttributeClassDiscovery.php \Drupal\Core\Plugin\Discovery\AttributeClassDiscovery::getProviderFromNamespace()

Extracts the provider name from a Drupal namespace.

Parameters

string $namespace: The namespace to extract the provider from.

Return value

string|null The matching provider name, or NULL otherwise.

2 calls to AttributeClassDiscovery::getProviderFromNamespace()
AttributeClassDiscovery::prepareAttributeDefinition in core/lib/Drupal/Core/Plugin/Discovery/AttributeClassDiscovery.php
Prepares the attribute definition.
AttributeDiscoveryWithAnnotations::prepareAnnotationDefinition in core/lib/Drupal/Core/Plugin/Discovery/AttributeDiscoveryWithAnnotations.php
Prepares the annotation definition.

File

core/lib/Drupal/Core/Plugin/Discovery/AttributeClassDiscovery.php, line 82

Class

AttributeClassDiscovery
Defines a discovery mechanism to find plugins using attributes.

Namespace

Drupal\Core\Plugin\Discovery

Code

protected function getProviderFromNamespace(string $namespace) : ?string {
    preg_match('|^Drupal\\\\(?<provider>[\\w]+)\\\\|', $namespace, $matches);
    if (isset($matches['provider'])) {
        return mb_strtolower($matches['provider']);
    }
    return NULL;
}

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