You are here

abstract class RestfulFormatterBase in RESTful 7

@file Contains RestfulFormatterBase.

Hierarchy

Expanded class hierarchy of RestfulFormatterBase

File

plugins/formatter/RestfulFormatterBase.php, line 8
Contains RestfulFormatterBase.

View source
abstract class RestfulFormatterBase extends \RestfulPluginBase implements \RestfulFormatterInterface {

  /**
   * The entity handler containing more info about the request.
   *
   * @var \RestfulBase
   */
  protected $handler;

  /**
   * Generic constructor.
   *
   * @param array $plugin
   *   The formatter plugin definition.
   * @param \RestfulBase $handler
   *   The restful handler that will call the output formatter.
   */
  public function __construct(array $plugin, $handler = NULL) {
    $this
      ->setPlugin($plugin);
    $this->handler = $handler;
  }

  /**
   * {@inheritdoc}
   */
  public function format(array $data) {
    return $this
      ->render($this
      ->prepare($data));
  }

  /**
   * {@inheritdoc}
   */
  public function getContentTypeHeader() {

    // Default to the most general content type.
    return 'application/hal+json; charset=utf-8';
  }

}

Members

Namesort descending Modifiers Type Description Overrides
RestfulFormatterBase::$handler protected property The entity handler containing more info about the request.
RestfulFormatterBase::format public function Formats the un-structured data into the output format. Overrides RestfulFormatterInterface::format
RestfulFormatterBase::getContentTypeHeader public function Returns the content type for the selected output format. Overrides RestfulFormatterInterface::getContentTypeHeader 2
RestfulFormatterBase::__construct public function Generic constructor. Overrides RestfulPluginBase::__construct
RestfulFormatterInterface::prepare public function Massages the raw data to create a structured array to pass to the renderer. 2
RestfulFormatterInterface::render public function Renders an array in the selected format. 2
RestfulPluginBase::$plugin protected property The plugin definition array.
RestfulPluginBase::getPlugin public function Gets information about the restful plugin. Overrides RestfulPluginInterface::getPlugin
RestfulPluginBase::getPluginKey public function Gets information about the restful plugin key. Overrides RestfulPluginInterface::getPluginKey
RestfulPluginBase::setPlugin public function Sets information about the restful plugin. Overrides RestfulPluginInterface::setPlugin
RestfulPluginBase::setPluginKey public function Gets information about the restful plugin key. Overrides RestfulPluginInterface::setPluginKey