You are here

class SimpleEntityQueueHandler in Entityqueue 7

A simple queue implementation.

Hierarchy

Expanded class hierarchy of SimpleEntityQueueHandler

1 string reference to 'SimpleEntityQueueHandler'
simple.inc in plugins/entityqueue/handler/simple.inc

File

plugins/entityqueue/handler/SimpleEntityQueueHandler.class.php, line 11
Contains Entityqueue handler for simple queues.

View source
class SimpleEntityQueueHandler extends EntityQueueHandlerBase {

  /**
   * {@inheritdoc}
   */
  public function getSubqueueLabel(EntitySubqueue $subqueue) {
    return $this->queue->label;
  }

  /**
   * {@inheritdoc}
   */
  public function canDeleteSubqueue(EntitySubqueue $subqueue) {
    return FALSE;
  }

  /**
   * {@inheritdoc}
   */
  public function loadFromCode() {
    $this
      ->ensureSubqueue();
  }

  /**
   * {@inheritdoc}
   */
  public function insert() {
    $this
      ->ensureSubqueue();
  }

  /**
   * Makes sure that every simple queue has a subqueue.
   */
  protected function ensureSubqueue() {
    global $user;
    static $queues = array();
    if (!isset($queues[$this->queue->name])) {
      $queues[$this->queue->name] = TRUE;
      $transaction = db_transaction();
      $query = new EntityFieldQuery();
      $query
        ->entityCondition('entity_type', 'entityqueue_subqueue')
        ->entityCondition('bundle', $this->queue->name);
      $result = $query
        ->execute();

      // If we don't have a subqueue already, create one now.
      if (empty($result['entityqueue_subqueue'])) {
        $subqueue = entityqueue_subqueue_create();
        $subqueue->queue = $this->queue->name;
        $subqueue->name = $this->queue->name;
        $subqueue->label = $this
          ->getSubqueueLabel($subqueue);
        $subqueue->module = 'entityqueue';
        $subqueue->uid = $user->uid;
        entity_get_controller('entityqueue_subqueue')
          ->save($subqueue, $transaction);
      }
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
EntityQueueHandlerBase::$plugin protected property The handler plugin definition.
EntityQueueHandlerBase::$queue protected property The EntityQueue object.
EntityQueueHandlerBase::create public function Act on creating a queue. Overrides EntityQueueHandlerInterface::create
EntityQueueHandlerBase::getHandlerLabel public function Returns the label of the queue's handler. Overrides EntityQueueHandlerInterface::getHandlerLabel 1
EntityQueueHandlerBase::getInstance public static function Factory function: creates a new instance of this handler for a queue. Overrides EntityQueueHandlerInterface::getInstance 1
EntityQueueHandlerBase::getTargetTypeLabel public function Returns the entity type label of a queue target type. Overrides EntityQueueHandlerInterface::getTargetTypeLabel
EntityQueueHandlerBase::load public function Act on loading a queue. Overrides EntityQueueHandlerInterface::load
EntityQueueHandlerBase::postDelete public function Act after deleting a queue. Overrides EntityQueueHandlerInterface::postDelete
EntityQueueHandlerBase::preDelete public function Act before deleting a queue. Overrides EntityQueueHandlerInterface::preDelete
EntityQueueHandlerBase::preSave public function Act before a queue is saved. Overrides EntityQueueHandlerInterface::preSave
EntityQueueHandlerBase::settingsForm public function Generates a settings form for this handler. Overrides EntityQueueHandlerInterface::settingsForm 1
EntityQueueHandlerBase::subqueueForm public function Generates an add/edit subqueue form for this handler. Overrides EntityQueueHandlerInterface::subqueueForm 2
EntityQueueHandlerBase::update public function Act after a queue is updated. Overrides EntityQueueHandlerInterface::update
EntityQueueHandlerBase::__construct protected function
SimpleEntityQueueHandler::canDeleteSubqueue public function Returns TRUE if subqueue can be deleted, otherwise returns FALSE. Overrides EntityQueueHandlerBase::canDeleteSubqueue 1
SimpleEntityQueueHandler::ensureSubqueue protected function Makes sure that every simple queue has a subqueue.
SimpleEntityQueueHandler::getSubqueueLabel public function Returns the label of a given subqueue. Overrides EntityQueueHandlerBase::getSubqueueLabel
SimpleEntityQueueHandler::insert public function Act after a new queue is saved. Overrides EntityQueueHandlerBase::insert 1
SimpleEntityQueueHandler::loadFromCode public function Act on loading a queue that is defined only in code. Overrides EntityQueueHandlerBase::loadFromCode 1