function AttributeClassDiscovery::getTwoLevelNamespace

Gets a string containing the first two levels of a class name or namespace.

Parameters

string $namespace: The class name or namespace.

Return value

string A namespace string containing only two levels.

3 calls to AttributeClassDiscovery::getTwoLevelNamespace()
AttributeClassDiscovery::getDefinitions in core/lib/Drupal/Component/Plugin/Discovery/AttributeClassDiscovery.php
Gets the definition of all plugins for this type.
AttributeClassDiscovery::hasMissingDependencies in core/lib/Drupal/Component/Plugin/Discovery/AttributeClassDiscovery.php
Whether the plugin definition has missing dependencies.
AttributeClassDiscovery::__construct in core/lib/Drupal/Component/Plugin/Discovery/AttributeClassDiscovery.php
Constructs a new instance.

File

core/lib/Drupal/Component/Plugin/Discovery/AttributeClassDiscovery.php, line 285

Class

AttributeClassDiscovery
Defines a discovery mechanism to find plugins with attributes.

Namespace

Drupal\Component\Plugin\Discovery

Code

protected function getTwoLevelNamespace(string $namespace) : string {
  return implode('\\', array_slice(explode('\\', $namespace), 0, 2));
}

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