You are here

public static function QuickContent::factory in Quick Tabs 7.3

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 ./quicktabs.classes.inc
Returns a reference to an object that implements the QuickContentRenderable interface.
quick_content_factory in ./quicktabs.module
Returns an object that implements the QuickContent interface.

File

./quicktabs.classes.inc, line 427

Class

QuickContent
Abstract base class for content plugins.

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