Same name and namespace in other branches
  1. 7.x-3.x quicktabs.classes.inc \QuickContent::factory()

Instantiate a content type object.

Parameters

$name: The type name of the plugin.

$item: An array containing the item definition

2 calls to QuickContent::factory()
QuickSet::getContentRenderer in src/QuickSet.php
Returns a reference to an object that implements the QuickContentRenderableInterface.
quick_content_factory in ./quicktabs.module
Returns an object that implements the QuickContent interface.

File

src/QuickContent.php, line 67

Class

QuickContent
Abstract base class for content plugins.

Namespace

Drupal\quicktabs

Code

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 (!Drupal::moduleHandler()->moduleExists($dep)) {
                    return NULL;
                }
            }
        }
        return new $class($item);
    }
    return NULL;
}