You are here

class JsonApiDocumentTopLevel in JSON:API 8

Represents a JSON API document's "top level".

@internal

@todo Add the missing required members: 'error' and 'meta' or document why not. @todo Add support for the missing optional members: 'jsonapi', 'links' and 'included' or document why not.

Hierarchy

Expanded class hierarchy of JsonApiDocumentTopLevel

See also

http://jsonapi.org/format/#document-top-level

8 files declare their use of JsonApiDocumentTopLevel
EntityResource.php in src/Controller/EntityResource.php
EntityResourceTest.php in tests/src/Kernel/Controller/EntityResourceTest.php
EntityToJsonApi.php in src/EntityToJsonApi.php
JsonApiDocumentTopLevelNormalizer.php in src/Normalizer/JsonApiDocumentTopLevelNormalizer.php
JsonApiDocumentTopLevelNormalizerTest.php in tests/src/Kernel/Normalizer/JsonApiDocumentTopLevelNormalizerTest.php

... See full list

File

src/Resource/JsonApiDocumentTopLevel.php, line 15

Namespace

Drupal\jsonapi\Resource
View source
class JsonApiDocumentTopLevel {

  /**
   * The data to normalize.
   *
   * @var \Drupal\Core\Entity\EntityInterface|\Drupal\jsonapi\EntityCollection
   */
  protected $data;

  /**
   * Instantiates a JsonApiDocumentTopLevel object.
   *
   * @param \Drupal\Core\Entity\EntityInterface|\Drupal\jsonapi\EntityCollection $data
   *   The data to normalize. It can be either a straight up entity or a
   *   collection of entities.
   */
  public function __construct($data) {
    $this->data = $data;
  }

  /**
   * Gets the data.
   *
   * @return \Drupal\Core\Entity\EntityInterface|\Drupal\jsonapi\EntityCollection
   *   The data.
   */
  public function getData() {
    return $this->data;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
JsonApiDocumentTopLevel::$data protected property The data to normalize.
JsonApiDocumentTopLevel::getData public function Gets the data.
JsonApiDocumentTopLevel::__construct public function Instantiates a JsonApiDocumentTopLevel object.