Same name in other branches
  1. 8.x-1.x src/QuickContent.php \Drupal\quicktabs\QuickContent

Abstract base class for content plugins.

Hierarchy

Expanded class hierarchy of QuickContent

File

./quicktabs.classes.inc, line 369

View source
abstract class QuickContent implements QuickContentRenderable {
    
    /**
     * Used as the title of the tab.
     * @var string
     */
    protected $title;
    
    /**
     * An array containing the information that defines the tab content, specific
     * to its type.
     * @var array
     */
    protected $settings;
    
    /**
     * A render array of the contents.
     * @var array
     */
    protected $rendered_content;
    
    /**
     * Constructor
     */
    public function __construct($item) {
        $this->title = isset($item['title']) ? $item['title'] : '';
        // We do not need to store title, type or weight in the settings array, which
        // is for type-specific settings.
        unset($item['title'], $item['type'], $item['weight']);
        $this->settings = $item;
    }
    
    /**
     * Accessor for the tab title.
     */
    public function getTitle() {
        return $this->title;
    }
    
    /**
     * Accessor for the tab settings.
     */
    public function getSettings() {
        return $this->settings;
    }
    
    /**
     * Instantiate a content type object.
     *
     * @param $name
     *   The type name of the plugin.
     *
     * @param $item
     *   An array containing the item definition
     *  
     */
    public static function factory($name, $item) {
        ctools_include('plugins');
        if ($class = ctools_plugin_load_class('quicktabs', 'contents', $name, 'handler')) {
            // We now need to check the plugin's dependencies, to make sure they're installed.
            // This info has already been statically cached at this point so there's no
            // harm in making a call to ctools_get_plugins().
            $plugin = ctools_get_plugins('quicktabs', 'contents', $name);
            if (isset($plugin['dependencies'])) {
                foreach ($plugin['dependencies'] as $dep) {
                    // If any dependency is missing we cannot instantiate our class.
                    if (!module_exists($dep)) {
                        return NULL;
                    }
                }
            }
            return new $class($item);
        }
        return NULL;
    }
    
    /**
     * Method for returning the form elements to display for this tab type on
     * the admin form.
     *
     * @param $delta Integer representing this tab's position in the tabs array.
     *
     * @param $qt An object representing the Quicktabs instance that the tabs are
     * being built for.
     */
    public abstract function optionsForm($delta, $qt);

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title Overrides
QuickContent::$rendered_content protected property A render array of the contents.
QuickContent::$settings protected property An array containing the information that defines the tab content, specific
to its type.
QuickContent::$title protected property Used as the title of the tab.
QuickContent::factory public static function Instantiate a content type object.
QuickContent::getSettings public function Accessor for the tab settings. Overrides QuickContentRenderable::getSettings
QuickContent::getTitle public function Accessor for the tab title. Overrides QuickContentRenderable::getTitle
QuickContent::optionsForm abstract public function Method for returning the form elements to display for this tab type on
the admin form.
5
QuickContent::__construct public function Constructor 2
QuickContentRenderable::getAjaxKeys public function Returns an array of keys to use for constructing the correct arguments for
an ajax callback to retrieve content of this type. The order of the keys
returned affects the order of the args passed in to the render method when
called via ajax (see theā€¦
6
QuickContentRenderable::getType public static function Returns the short type name of the content plugin, e.g. 'block', 'node',
'prerendered'.
6
QuickContentRenderable::getUniqueKeys public function Returns an array of keys, sufficient to represent the content uniquely. 6
QuickContentRenderable::render public function Renders the content. 6