function ComponentGenerator::encode

Same name and namespace in other branches
  1. 10 composer/Generator/ComponentGenerator.php \Drupal\Composer\Generator\ComponentGenerator::encode()
  2. 11.x composer/Generator/ComponentGenerator.php \Drupal\Composer\Generator\ComponentGenerator::encode()

Utility function to encode package json in a consistent way.

Parameters

array $composer_json_data: Data to encode into a json string.

Return value

string Encoded version of provided json data.

1 call to ComponentGenerator::encode()
ComponentGenerator::generateComponentPackage in composer/Generator/ComponentGenerator.php
Generate the component JSON files.

File

composer/Generator/ComponentGenerator.php, line 210

Class

ComponentGenerator
Reconciles Drupal component dependencies with core.

Namespace

Drupal\Composer\Generator

Code

public static function encode(array $composer_json_data) : string {
    return json_encode($composer_json_data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . "\n";
}

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