You are here

private function Flowchart::itemHasChildren in Business Rules 8

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

Check if item has children.

Parameters

\Drupal\Core\Entity\EntityInterface $item: The item.

Return value

bool True|False.

2 calls to Flowchart::itemHasChildren()
Flowchart::getGraph in src/Util/Flowchart/Flowchart.php
Show the Business Rule workflow for one item.
Flowchart::mountMatrix in src/Util/Flowchart/Flowchart.php
Mount the graph matrix.

File

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

Class

Flowchart
Class Flowchart.

Namespace

Drupal\business_rules\Util\Flowchart

Code

private function itemHasChildren(EntityInterface $item) {
  if ($item instanceof BusinessRule) {
    $children = $item
      ->getItems();
    if (!is_null($children) && count($children)) {
      return TRUE;
    }
  }
  elseif ($item instanceof Action) {
    $children = $item
      ->getSettings('items');
    if (!is_null($children) && count($children)) {
      return TRUE;
    }
  }
  elseif ($item instanceof Condition) {
    $success_items = $item
      ->getSuccessItems();
    $fail_items = $item
      ->getFailItems();
    if (count($success_items) || count($fail_items)) {
      return TRUE;
    }
  }
  return FALSE;
}