Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Yaml.php

function Yaml::encode

Overrides SerializationInterface::encode

1 call to Yaml::encode()
GenerateTheme::execute in core/lib/Drupal/Core/Command/GenerateTheme.php
Executes the current command.

File

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

Class

Yaml
Provides a YAML serialization implementation using symfony/yaml.

Namespace

Drupal\Component\Serialization

Code

public static function encode($data) {
    try {
        // Set the indentation to 2 to match Drupal's coding standards.
        $yaml = new Dumper(2);
        return $yaml->dump($data, PHP_INT_MAX, 0, SymfonyYaml::DUMP_EXCEPTION_ON_INVALID_TYPE | SymfonyYaml::DUMP_MULTI_LINE_LITERAL_BLOCK);
    } catch (\Exception $e) {
        throw new InvalidDataTypeException($e->getMessage(), $e->getCode(), $e);
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal