function YamlDirectoryDiscovery::getIdentifier

Same name in other branches
  1. 9 core/lib/Drupal/Component/Discovery/YamlDirectoryDiscovery.php \Drupal\Component\Discovery\YamlDirectoryDiscovery::getIdentifier()
  2. 8.9.x core/lib/Drupal/Component/Discovery/YamlDirectoryDiscovery.php \Drupal\Component\Discovery\YamlDirectoryDiscovery::getIdentifier()
  3. 11.x core/lib/Drupal/Component/Discovery/YamlDirectoryDiscovery.php \Drupal\Component\Discovery\YamlDirectoryDiscovery::getIdentifier()

Gets the identifier from the data.

Parameters

string $file: The filename.

array $data: The data from the YAML file.

Return value

string The identifier from the data.

2 methods override YamlDirectoryDiscovery::getIdentifier()
DirectoryWithMetadataDiscovery::getIdentifier in core/modules/sdc/src/Plugin/Discovery/DirectoryWithMetadataDiscovery.php
The IDs can collide in two different scenarios:
DirectoryWithMetadataDiscovery::getIdentifier in core/lib/Drupal/Core/Plugin/Discovery/DirectoryWithMetadataDiscovery.php
The IDs can collide in two different scenarios:

File

core/lib/Drupal/Component/Discovery/YamlDirectoryDiscovery.php, line 112

Class

YamlDirectoryDiscovery
Discovers multiple YAML files in a set of directories.

Namespace

Drupal\Component\Discovery

Code

protected function getIdentifier($file, array $data) {
    if (!isset($data[$this->idKey])) {
        throw new DiscoveryException("The {$file} contains no data in the identifier key '{$this->idKey}'");
    }
    return $data[$this->idKey];
}

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