You are here

public function BusinessRulesUtil::getBusinessRulesUsingThisItem in Business Rules 2.x

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

Get all Business Rules using the item.

Parameters

\Drupal\business_rules\ItemInterface $item: The item to look for business rules using it.

Return value

array Actions using the item.

2 calls to BusinessRulesUtil::getBusinessRulesUsingThisItem()
BusinessRulesUtil::getUsedByBusinessRulesDetailsBox in src/Util/BusinessRulesUtil.php
Return a details box which rules in where this item is being used.
BusinessRulesUtil::removeItemReferences in src/Util/BusinessRulesUtil.php
Remove the item references after it's deletion.

File

src/Util/BusinessRulesUtil.php, line 955

Class

BusinessRulesUtil
Class BusinessRulesUtil.

Namespace

Drupal\business_rules\Util

Code

public function getBusinessRulesUsingThisItem(ItemInterface $item) {
  $rules = BusinessRule::loadMultiple();
  $used_by = [];

  /** @var \Drupal\business_rules\Entity\BusinessRule $rule */
  foreach ($rules as $rule) {
    if (in_array($item
      ->id(), array_keys($rule
      ->getItems()))) {
      $used_by[] = $rule;
    }
  }
  return $used_by;
}