ExportResult.php

Namespace

Drupal\Core\DefaultContent

File

core/lib/Drupal/Core/DefaultContent/ExportResult.php

View source
<?php

declare (strict_types=1);
namespace Drupal\Core\DefaultContent;

use Drupal\Core\Serialization\Yaml;

/**
 * The result of exporting a content entity.
 *
 * @internal
 *   This API is experimental.
 */
final readonly class ExportResult {
  public function __construct(public array $data, public ExportMetadata $metadata) {
  }
  
  /**
   * Returns the exported entity data as YAML.
   *
   * @return string
   *   The exported entity data in YAML format.
   */
  public function __toString() : string {
    $data = [
      '_meta' => $this->metadata
        ->get(),
    ] + $this->data;
    return Yaml::encode($data);
  }

}

Classes

Title Deprecated Summary
ExportResult The result of exporting a content entity.

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