function AttributeClassDiscovery::getTwoLevelNamespace

Same name and namespace in other branches
  1. 11.x core/lib/Drupal/Component/Plugin/Discovery/AttributeClassDiscovery.php \Drupal\Component\Plugin\Discovery\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.

File

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

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.