SerializedData.php in REST Views 8
Same filename and directory in other branches
Namespace
Drupal\rest_viewsFile
src/SerializedData.phpView source
<?php
namespace Drupal\rest_views;
/**
* Wrapper for passing serialized data through render arrays.
*
* @see \Drupal\rest_views\Normalizer\DataNormalizer
*/
class SerializedData {
/**
* The wrapped data.
*
* @var string
*/
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;
}
}
Classes
Name | Description |
---|---|
SerializedData | Wrapper for passing serialized data through render arrays. |