public function BusinessRulesUtil::getUsedByActionsDetailsBox in Business Rules 8
Same name and namespace in other branches
- 2.x src/Util/BusinessRulesUtil.php \Drupal\business_rules\Util\BusinessRulesUtil::getUsedByActionsDetailsBox()
Return a details box which actions using this item.
Parameters
\Drupal\business_rules\ItemInterface $item: The item to get the actions using it.
Return value
array The render array.
File
- src/
Util/ BusinessRulesUtil.php, line 1068
Class
- BusinessRulesUtil
- Class BusinessRulesUtil.
Namespace
Drupal\business_rules\UtilCode
public function getUsedByActionsDetailsBox(ItemInterface $item) {
$used_by = $this
->getActionsUsingItem($item);
$details = [];
/** @var \Drupal\business_rules\Entity\Condition $action */
if (count($used_by)) {
$action = $used_by[array_keys($used_by)[0]];
$storage = $this->entityTypeManager
->getStorage('business_rules_action');
$list = new ActionListBuilder($action
->getEntityType(), $storage);
$details = [
'#type' => 'details',
'#title' => $this
->t('Actions using this item'),
'#collapsed' => TRUE,
'#collapsable' => TRUE,
];
$header = $list
->buildHeader();
$rows = [];
foreach ($used_by as $action) {
$rows[] = $list
->buildRow($action);
}
$details['used_by'] = [
'#type' => 'table',
'#header' => $header,
'#rows' => $rows,
];
}
return $details;
}