public function ConditionsItemsController::addItem in Business Rules 8
Same name and namespace in other branches
- 2.x src/Controller/ConditionsItemsController.php \Drupal\business_rules\Controller\ConditionsItemsController::addItem()
Add item on Condition.
Parameters
string $condition_id: The condition id.
string $condition_item_type: The condition item type: success|fail.
string $item_type: The item type action|condition.
string $item_id: The item id.
Return value
\Zend\Diactoros\Response\RedirectResponse The RedirectResponse.
1 string reference to 'ConditionsItemsController::addItem'
File
- src/
Controller/ ConditionsItemsController.php, line 119
Class
- ConditionsItemsController
- Class ConditionsItemsController.
Namespace
Drupal\business_rules\ControllerCode
public function addItem($condition_id, $condition_item_type, $item_type, $item_id) {
$condition = Condition::load($condition_id);
$weight = $condition
->getMaxItemWeight($condition_item_type == 'success') + 1;
$itemObj = new BusinessRulesItemObject($item_id, $item_type, $weight);
if ($condition_item_type == 'success') {
$condition
->addSuccessItem($itemObj);
}
else {
$condition
->addFailItem($itemObj);
}
$condition
->save();
$url = new Url('entity.business_rules_condition.edit_form', [
'business_rules_condition' => $condition_id,
], [
'fragment' => $condition_item_type . '-' . $item_id,
]);
return new RedirectResponse($url
->toString());
}