public function Matrix::getElementAbove in Business Rules 2.x
Same name and namespace in other branches
- 8 src/Util/Flowchart/Matrix.php \Drupal\business_rules\Util\Flowchart\Matrix::getElementAbove()
Get the element above in the matrix.
Parameters
\Drupal\business_rules\Util\Flowchart\Element $element: The element.
Return value
null|\Drupal\business_rules\Util\Flowchart\Element The element.
File
- src/
Util/ Flowchart/ Matrix.php, line 81
Class
- Matrix
- The matrix to handle the Business Rule flowchart.
Namespace
Drupal\business_rules\Util\FlowchartCode
public function getElementAbove(Element $element) {
$cell = $this
->getCellByElementUuid($element
->getUuid());
$x = $cell['index_x'];
$y = $cell['index_y'];
// Check to avoid offset.
if ($y === 0) {
return NULL;
}
$cell_above = $this->matrix[$x][$y - 1];
if ($cell_above['element'] instanceof Element) {
return $cell_above['element'];
}
else {
return NULL;
}
}