public function EntitySubqueue::getItemPosition in Entityqueue 8
Gets the position (delta) of the given subqueue item.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The item in the subqueue.
Return value
int|bool The position of the given item in the subqueue, or FALSE if not found.
Overrides EntitySubqueueInterface::getItemPosition
2 calls to EntitySubqueue::getItemPosition()
- EntitySubqueue::hasItem in src/
Entity/ EntitySubqueue.php - Checks whether the subqueue has a given item.
- EntitySubqueue::removeItem in src/
Entity/ EntitySubqueue.php - Removes an entity from a subqueue.
File
- src/
Entity/ EntitySubqueue.php, line 305
Class
- EntitySubqueue
- Defines the EntitySubqueue entity class.
Namespace
Drupal\entityqueue\EntityCode
public function getItemPosition(EntityInterface $entity) {
$subqueue_items = $this
->get('items')
->getValue();
$subqueue_items_ids = array_map(function ($item) {
return $item['target_id'];
}, $subqueue_items);
return array_search($entity
->id(), $subqueue_items_ids);
}