YamlDiscovery.php

Same filename in this branch
  1. 10 core/lib/Drupal/Core/Plugin/Discovery/YamlDiscovery.php
  2. 10 core/lib/Drupal/Component/Discovery/YamlDiscovery.php
Same filename in other branches
  1. 9 core/lib/Drupal/Core/Discovery/YamlDiscovery.php
  2. 9 core/lib/Drupal/Core/Plugin/Discovery/YamlDiscovery.php
  3. 9 core/lib/Drupal/Component/Discovery/YamlDiscovery.php
  4. 8.9.x core/lib/Drupal/Core/Discovery/YamlDiscovery.php
  5. 8.9.x core/lib/Drupal/Core/Plugin/Discovery/YamlDiscovery.php
  6. 8.9.x core/lib/Drupal/Component/Discovery/YamlDiscovery.php
  7. 11.x core/lib/Drupal/Core/Discovery/YamlDiscovery.php
  8. 11.x core/lib/Drupal/Core/Plugin/Discovery/YamlDiscovery.php
  9. 11.x core/lib/Drupal/Component/Discovery/YamlDiscovery.php

Namespace

Drupal\Core\Discovery

File

core/lib/Drupal/Core/Discovery/YamlDiscovery.php

View source
<?php

namespace Drupal\Core\Discovery;

use Drupal\Component\Discovery\YamlDiscovery as ComponentYamlDiscovery;
use Drupal\Component\Serialization\Exception\InvalidDataTypeException;
use Drupal\Core\Serialization\Yaml;

/**
 * Provides discovery for YAML files within a given set of directories.
 *
 * This overrides the Component file decoding with the Core YAML implementation.
 */
class YamlDiscovery extends ComponentYamlDiscovery {
    
    /**
     * {@inheritdoc}
     */
    protected function decode($file) {
        try {
            return Yaml::decode(file_get_contents($file)) ?: [];
        } catch (InvalidDataTypeException $e) {
            throw new InvalidDataTypeException($file . ': ' . $e->getMessage(), $e->getCode(), $e);
        }
    }

}

Classes

Title Deprecated Summary
YamlDiscovery Provides discovery for YAML files within a given set of directories.

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