You are here

protected static function Yaml::getSerializer in Drupal 10

Same name in this branch
  1. 10 core/lib/Drupal/Core/Serialization/Yaml.php \Drupal\Core\Serialization\Yaml::getSerializer()
  2. 10 core/lib/Drupal/Component/Serialization/Yaml.php \Drupal\Component\Serialization\Yaml::getSerializer()
Same name and namespace in other branches
  1. 8 core/lib/Drupal/Component/Serialization/Yaml.php \Drupal\Component\Serialization\Yaml::getSerializer()
  2. 9 core/lib/Drupal/Component/Serialization/Yaml.php \Drupal\Component\Serialization\Yaml::getSerializer()

Determines which implementation to use for parsing YAML.

2 calls to Yaml::getSerializer()
Yaml::decode in core/lib/Drupal/Component/Serialization/Yaml.php
Decodes data from the serialization format.
Yaml::getSerializer in core/lib/Drupal/Core/Serialization/Yaml.php
Determines which implementation to use for parsing YAML.
2 methods override Yaml::getSerializer()
Yaml::getSerializer in core/lib/Drupal/Core/Serialization/Yaml.php
Determines which implementation to use for parsing YAML.
YamlStub::getSerializer in core/tests/Drupal/Tests/Component/Serialization/YamlTest.php
Determines which implementation to use for parsing YAML.

File

core/lib/Drupal/Component/Serialization/Yaml.php, line 48

Class

Yaml
Provides a YAML serialization implementation.

Namespace

Drupal\Component\Serialization

Code

protected static function getSerializer() {
  if (!isset(static::$serializer)) {

    // Use the PECL YAML extension if it is available. It has better
    // performance for file reads and is YAML compliant.
    if (extension_loaded('yaml')) {
      static::$serializer = YamlPecl::class;
    }
    else {

      // Otherwise, fallback to the Symfony implementation.
      static::$serializer = YamlSymfony::class;
    }
  }
  return static::$serializer;
}