You are here

public function DraggableViews::getDepth in DraggableViews 2.0.x

Same name and namespace in other branches
  1. 8 src/DraggableViews.php \Drupal\draggableviews\DraggableViews::getDepth()

Get depth by index.

File

src/DraggableViews.php, line 54

Class

DraggableViews
Class DraggableViews.

Namespace

Drupal\draggableviews

Code

public function getDepth($index) {
  if (!isset($this->view->result[$index])) {
    return FALSE;
  }
  $row = $this->view->result[$index];

  // If parent is available, set parent's depth +1.
  return !empty($row->draggableviews_structure_parent) ? $this
    ->getDepth($this
    ->getIndex($row->draggableviews_structure_parent)) + 1 : 0;
}