<?php // Array of node ids. $nids = array('4', '6'); $subqueue_name = 'abc'; // Load the subqueue. $subqueue = entityqueue_subqueue_load($subqueue_name); foreach ($nids as $nid) { $subqueue->eq_node[LANGUAGE_NONE][] = array('target_id' => $nid); } // Save the subqueue. entityqueue_subqueue_save($subqueue);
/** * @Given /^(?:that|those) "([^"]*)" ([\w ]+) is in the "([^"]*)" entityqueue$/ */ public function addEntityToQueue($bundleLabel, $entityTypeLabel, $entityqueueLabel) { $entityTypeLabel = $this->removePluralFromLabel($entityTypeLabel); $entityType = $this->getEntityTypeFromLabel($entityTypeLabel); $entityqueID = $this->getSubqueueID($entityqueueLabel); $subqueue = entityqueue_subqueue_load($entityqueID); foreach ($this->content as $entityType => $bundles) { $entityInfo = entity_get_info($entityType); $idProperty = $entityInfo['entity keys']['id']; foreach ($bundles as $bundleType => $entities) { foreach ($entities as $entity) { $id = $entity->{$idProperty}->value(); // TODO account for all entity types. switch ($entityType) { case 'node': $subqueue->eq_node[LANGUAGE_NONE][] = array('target_id' => $id); break; case 'fieldable_panels_pane': $subqueue->eq_fieldable_panels_pane[LANGUAGE_NONE][] = array('target_id' => $id); break; default: throw new \Exception("Entity type {$entityTypeLabel} cannot be added to an entityqueue at this time."); break; } entityqueue_subqueue_save($subqueue); } } } }