You are here

public static function EntityQueueHandlerBase::getInstance in Entityqueue 7

Factory function: creates a new instance of this handler for a queue.

Parameters

EntityQueue $queue: An EntityQueue object.

Return value

EntityQueueHandlerInterface

Overrides EntityQueueHandlerInterface::getInstance

1 method overrides EntityQueueHandlerBase::getInstance()
BrokenEntityQueueHandler::getInstance in plugins/entityqueue/handler/base.inc
Factory function: creates a new instance of this handler for a queue.

File

plugins/entityqueue/handler/base.inc, line 113
Contains Entityqueue handler interface and base class.

Class

EntityQueueHandlerBase
An abstract implementation of EntityQueueHandlerInterface.

Code

public static function getInstance(EntityQueue $queue) {
  $entity_type = $queue->target_type;

  // Check if the entity type does exist and has a base table.
  $entity_info = entity_get_info($entity_type);
  if (empty($entity_info['base table'])) {
    return BrokenEntityQueueHandler::getInstance($queue);
  }

  // Check if the queue handler exists.
  ctools_include('plugins');
  $plugin = ctools_get_plugins('entityqueue', 'handler', $queue->handler);
  if (empty($plugin)) {
    return BrokenEntityQueueHandler::getInstance($queue);
  }
  return new $plugin['class']($queue);
}