You are here

private function Flowchart::getOriginUuid in Business Rules 2.x

Same name and namespace in other branches
  1. 8 src/Util/Flowchart/Flowchart.php \Drupal\business_rules\Util\Flowchart\Flowchart::getOriginUuid()

Get the uuid to the arrow origin.

Parameters

array $cell: The cell with the element.

Return value

string The origin uuid.

1 call to Flowchart::getOriginUuid()
Flowchart::processConnections in src/Util/Flowchart/Flowchart.php
Process the graph connections.

File

src/Util/Flowchart/Flowchart.php, line 414

Class

Flowchart
Class Flowchart.

Namespace

Drupal\business_rules\Util\Flowchart

Code

private function getOriginUuid(array $cell) {
  $root_element = $this->matrix
    ->getRootElement();
  if (empty($cell['element']
    ->getParent()) || $root_element
    ->getItem() == $cell['element']
    ->getParent()
    ->getItem() && $root_element
    ->getItem() instanceof BusinessRule) {
    return $root_element
      ->getUuid();
  }
  else {
    $parent = $cell['element']
      ->getParent();

    /** @var \Drupal\business_rules\Util\Flowchart\Element $element */
    $element = $cell['element'];
    $element_above = $this->matrix
      ->getElementAbove($element);
    if ($element_above instanceof Element && !empty($element_above
      ->getParent()) && $element_above
      ->getParent()
      ->getItem() === $parent
      ->getItem()) {

      // This connection doesn't have label.
      $cell['element']
        ->setArrowLabel('');

      // Connect to the immediate brother above.
      return $element_above
        ->getUuid();
    }
    else {

      // Connect to the parent.
      return $parent
        ->getUuid();
    }
  }
}