You are here

interface FormatterInterface in RESTful 7.2

Hierarchy

  • interface \Drupal\restful\Plugin\formatter\FormatterInterface extends \Drupal\Component\Plugin\PluginInspectionInterface \Drupal\Component\Plugin\ConfigurablePluginInterface

Expanded class hierarchy of FormatterInterface

All classes that implement FormatterInterface

3 files declare their use of FormatterInterface
FormatterHalXml.php in modules/restful_example/src/Plugin/formatter/FormatterHalXml.php
Contains \Drupal\restful\Plugin\formatter\FormatterHalJson.
FormatterManager.php in src/Formatter/FormatterManager.php
Contains \Drupal\restful\Formatter\FormatterManager
FormatterManagerInterface.php in src/Formatter/FormatterManagerInterface.php
Contains \Drupal\restful\Formatter\FormatterManagerInterface

File

src/Plugin/formatter/FormatterInterface.php, line 16
Contains \Drupal\restful\Plugin\formatter\FormatterInterface

Namespace

Drupal\restful\Plugin\formatter
View source
interface FormatterInterface extends PluginInspectionInterface, ConfigurablePluginInterface {

  /**
   * Massages the raw data to create a structured array to pass to the renderer.
   *
   * @param ResourceFieldInterface[] $data
   *   The raw data to return.
   *
   * @return array
   *   The data prepared to be rendered.
   */
  public function prepare(array $data);

  /**
   * Renders an array in the selected format.
   *
   * @param array $structured_data
   *   The data prepared to be rendered as returned by
   *   \RestfulFormatterInterface::prepare().
   *
   * @return string
   *   The body contents for the HTTP response.
   */
  public function render(array $structured_data);

  /**
   * Formats the un-structured data into the output format.
   *
   * @param array $data
   *   The raw data to return.
   *
   * @return string
   *   The body contents for the HTTP response.
   *
   * @see \RestfulFormatterInterface::prepare()
   * @see \RestfulFormatterInterface::render()
   */
  public function format(array $data);

  /**
   * Returns the content type for the selected output format.
   *
   * @return string
   *   The contents for the ContentType header in the response.
   */
  public function getContentTypeHeader();

  /**
   * Gets the underlying resource.
   *
   * @return ResourceInterface
   *   The resource.
   */
  public function getResource();

  /**
   * Sets the underlying resource.
   *
   * @param ResourceInterface $resource
   *   The resource to set.
   */
  public function setResource(ResourceInterface $resource);

  /**
   * Parses the body string into the common format.
   *
   * @param string $body
   *   The string sent from the consumer.
   *
   * @return array
   *   The parsed object following the expected structure.
   *
   * @throws \Drupal\restful\Exception\ServerConfigurationException
   * @throws \Drupal\restful\Exception\BadRequestException
   */
  public function parseBody($body);

}

Members

Namesort descending Modifiers Type Description Overrides
FormatterInterface::format public function Formats the un-structured data into the output format. 1
FormatterInterface::getContentTypeHeader public function Returns the content type for the selected output format. 1
FormatterInterface::getResource public function Gets the underlying resource. 1
FormatterInterface::parseBody public function Parses the body string into the common format. 1
FormatterInterface::prepare public function Massages the raw data to create a structured array to pass to the renderer. 3
FormatterInterface::render public function Renders an array in the selected format. 3
FormatterInterface::setResource public function Sets the underlying resource. 1