public function BusinessRulesUtil::getConditionsUsingItem in Business Rules 8
Same name and namespace in other branches
- 2.x src/Util/BusinessRulesUtil.php \Drupal\business_rules\Util\BusinessRulesUtil::getConditionsUsingItem()
Get all conditions using the item.
Parameters
\Drupal\business_rules\ItemInterface $item: The item to look for conditions using it.
Return value
array Conditions using the item.
2 calls to BusinessRulesUtil::getConditionsUsingItem()
- BusinessRulesUtil::getUsedByConditionsDetailsBox in src/
Util/ BusinessRulesUtil.php - Return a details box which conditions using this item.
- BusinessRulesUtil::removeItemReferences in src/
Util/ BusinessRulesUtil.php - Remove the item references after it's deletion.
File
- src/
Util/ BusinessRulesUtil.php, line 870
Class
- BusinessRulesUtil
- Class BusinessRulesUtil.
Namespace
Drupal\business_rules\UtilCode
public function getConditionsUsingItem(ItemInterface $item) {
$conditions = Condition::loadMultiple();
$used_by = [];
/** @var \Drupal\business_rules\Entity\Condition $condition */
if ($item instanceof Variable) {
foreach ($conditions as $condition) {
/** @var \Drupal\business_rules\VariablesSet $variables */
$variables = $condition
->getVariables();
if ($variables
->count()) {
/** @var \Drupal\business_rules\VariableObject $variable */
foreach ($variables
->getVariables() as $variable) {
if ($variable
->getId() == $item
->id()) {
$used_by[$variable
->getId()] = $condition;
}
}
}
}
}
else {
foreach ($conditions as $key => $condition) {
if (in_array($item
->id(), array_keys($condition
->getSuccessItems()))) {
$used_by[$key] = $condition;
}
}
foreach ($conditions as $key => $condition) {
if (in_array($item
->id(), array_keys($condition
->getFailItems()))) {
$used_by[$key] = $condition;
}
}
}
return $used_by;
}