You are here

abstract class BoxPlugin in Boxes 7.2

@file Base Plugin Class

Hierarchy

Expanded class hierarchy of BoxPlugin

1 string reference to 'BoxPlugin'
boxes_boxes_types in ./boxes.module
Implements hook_box_types().

File

plugins/base.inc, line 8
Base Plugin Class

View source
abstract class BoxPlugin implements BoxTypePluginInterface {
  protected $plugin_info;
  public $type;

  /**
   * Get Plugin info
   */
  public function getInfo($key = NULL) {
    if (!empty($key) && isset($this->plugin_info[$key])) {
      return $this->plugin_info[$key];
    }
    return $this->plugin_info;
  }

  /**
   * Build the URL string
   */
  public function buildURL() {
    return str_replace('_', '-', $this->type);
  }

  /**
   * Get the label
   */
  public function getLabel() {
    return $this
      ->getInfo('label');
  }

  /**
   * Get the description
   */
  public function getDescription() {
    return $this
      ->getInfo('description');
  }
  public function __construct($plugin_info) {
    $this->plugin_info = $plugin_info;
    $this->type = $plugin_info['name'];
  }

  /**
   * Define the form values and their defaults
   *
   * Be sure to call combine the results form the parent::values() with yours
   */
  public function values() {
    return array(
      'view_mode' => 'default',
    );
  }
  public function form($box, $form, &$form_state) {
    return array();
  }

  /**
   * Add a Box to the plugin
   */
  public function setBox($box) {
    $this->box = $box;
  }

  /**
   * Is the box type editable
   */
  public function isEditable() {
    return $this
      ->getInfo('editable');
  }

  /**
   * The plugin validation function
   */
  public function validate($values, &$form_state) {
  }

  /**
   * React to the saving of the box
   */
  public function submit(Box $box) {
    return $this;
  }

  /**
   * Return the block content.
   *
   * @param $box
   *   The box object being viewed.
   * @param $content
   *   The default content array created by Entity API.  This will include any
   *   fields attached to the entity.
   * @param $view_mode
   *   The view mode passed into $entity->view().
   * @return
   *   Return a renderable content array.
   */
  public function view($box, $content, $view_mode = 'default', $langcode = NULL) {
    return $content;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
BoxPlugin::$plugin_info protected property
BoxPlugin::$type public property
BoxPlugin::buildURL public function Build the URL string Overrides BoxTypePluginInterface::buildURL
BoxPlugin::form public function The Plugin Form Overrides BoxTypePluginInterface::form 1
BoxPlugin::getDescription public function Get the description Overrides BoxTypePluginInterface::getDescription
BoxPlugin::getInfo public function Get Plugin info Overrides BoxTypePluginInterface::getInfo
BoxPlugin::getLabel public function Get the label Overrides BoxTypePluginInterface::getLabel
BoxPlugin::isEditable public function Is the box type editable Overrides BoxTypePluginInterface::isEditable
BoxPlugin::setBox public function Add a Box to the plugin Overrides BoxTypePluginInterface::setBox
BoxPlugin::submit public function React to the saving of the box Overrides BoxTypePluginInterface::submit
BoxPlugin::validate public function The plugin validation function Overrides BoxTypePluginInterface::validate
BoxPlugin::values public function Define the form values and their defaults Overrides BoxTypePluginInterface::values 1
BoxPlugin::view public function Return the block content. Overrides BoxTypePluginInterface::view
BoxPlugin::__construct public function Constructor Overrides BoxTypePluginInterface::__construct