class InfoParserDynamic in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/lib/Drupal/Core/Extension/InfoParserDynamic.php \Drupal\Core\Extension\InfoParserDynamic
Parses dynamic .info.yml files that might change during the page request.
Hierarchy
- class \Drupal\Core\Extension\InfoParserDynamic implements InfoParserInterface
Expanded class hierarchy of InfoParserDynamic
1 file declares its use of InfoParserDynamic
- UpdateUploadTest.php in core/
modules/ update/ src/ Tests/ UpdateUploadTest.php - Contains \Drupal\update\Tests\UpdateUploadTest.
File
- core/
lib/ Drupal/ Core/ Extension/ InfoParserDynamic.php, line 16 - Contains \Drupal\Core\Extension\InfoParserDynamic.
Namespace
Drupal\Core\ExtensionView source
class InfoParserDynamic implements InfoParserInterface {
/**
* {@inheritdoc}
*/
public function parse($filename) {
if (!file_exists($filename)) {
$parsed_info = array();
}
else {
try {
$parsed_info = Yaml::decode(file_get_contents($filename));
} catch (InvalidDataTypeException $e) {
throw new InfoParserException("Unable to parse {$filename} " . $e
->getMessage());
}
$missing_keys = array_diff($this
->getRequiredKeys(), array_keys($parsed_info));
if (!empty($missing_keys)) {
throw new InfoParserException('Missing required keys (' . implode(', ', $missing_keys) . ') in ' . $filename);
}
if (isset($parsed_info['version']) && $parsed_info['version'] === 'VERSION') {
$parsed_info['version'] = \Drupal::VERSION;
}
}
return $parsed_info;
}
/**
* Returns an array of keys required to exist in .info.yml file.
*
* @return array
* An array of required keys.
*/
protected function getRequiredKeys() {
return array(
'type',
'core',
'name',
);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
InfoParserDynamic:: |
protected | function | Returns an array of keys required to exist in .info.yml file. | |
InfoParserDynamic:: |
public | function |
Parses Drupal module, theme and profile .info.yml files. Overrides InfoParserInterface:: |
1 |