protected function SimpleEntityQueueHandler::ensureSubqueue in Entityqueue 7
Makes sure that every simple queue has a subqueue.
2 calls to SimpleEntityQueueHandler::ensureSubqueue()
- SimpleEntityQueueHandler::insert in plugins/
entityqueue/ handler/ SimpleEntityQueueHandler.class.php - Act after a new queue is saved.
- SimpleEntityQueueHandler::loadFromCode in plugins/
entityqueue/ handler/ SimpleEntityQueueHandler.class.php - Act on loading a queue that is defined only in code.
File
- plugins/
entityqueue/ handler/ SimpleEntityQueueHandler.class.php, line 44 - Contains Entityqueue handler for simple queues.
Class
- SimpleEntityQueueHandler
- A simple queue implementation.
Code
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);
}
}
}