You are here

class SerializedData in REST Views 2.0.x

Same name and namespace in other branches
  1. 8 src/SerializedData.php \Drupal\rest_views\SerializedData

Wrapper for passing serialized data through render arrays.

Hierarchy

Expanded class hierarchy of SerializedData

See also

\Drupal\rest_views\Normalizer\DataNormalizer

13 files declare their use of SerializedData
BooleanExportFormatter.php in src/Plugin/Field/FieldFormatter/BooleanExportFormatter.php
DataNormalizer.php in src/Normalizer/DataNormalizer.php
EntityFieldExport.php in src/Plugin/views/field/EntityFieldExport.php
EntityFieldExportTest.php in tests/src/Unit/EntityFieldExportTest.php
EntityReferenceExportFormatter.php in src/Plugin/Field/FieldFormatter/EntityReferenceExportFormatter.php

... See full list

File

src/SerializedData.php, line 10

Namespace

Drupal\rest_views
View source
class SerializedData {

  /**
   * The wrapped data.
   *
   * @var mixed
   */
  protected $data;

  /**
   * SerializedData constructor.
   *
   * @param mixed $data
   *   The wrapped data.
   */
  public function __construct($data) {
    $this->data = $data;
  }

  /**
   * Create a serialized data object.
   *
   * @param mixed $data
   *   The wrapped data.
   *
   * @return static
   */
  public static function create($data) {
    if ($data instanceof static) {
      return $data;
    }
    return new static($data);
  }

  /**
   * Convert renderable object to a string.
   *
   * This function needs to return a non-empty string in order to be processed
   * correctly by Drupal's rendering system.
   *
   * @return string
   *   A placeholder string representation.
   */
  public function __toString() {

    // This must not be empty.
    return '[...]';
  }

  /**
   * Extract the wrapped data.
   *
   * @return mixed
   *   The wrapped data.
   */
  public function getData() {
    return $this->data;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
SerializedData::$data protected property The wrapped data.
SerializedData::create public static function Create a serialized data object.
SerializedData::getData public function Extract the wrapped data.
SerializedData::__construct public function SerializedData constructor.
SerializedData::__toString public function Convert renderable object to a string.