public function LoopThroughViewResultController::removeItem in Business Rules 2.x
Same name and namespace in other branches
- 8 src/Controller/LoopThroughViewResultController.php \Drupal\business_rules\Controller\LoopThroughViewResultController::removeItem()
Remove item from condition.
Parameters
string $action_id: The action id.
string $item_type: The item type action|condition.
string $item_id: The item id.
string $method: The method name: ajax|nojs.
Return value
\Drupal\Core\Ajax\AjaxResponse|\Zend\Diactoros\Response\RedirectResponse The AjaxResponse or the RedirectResponse.
1 string reference to 'LoopThroughViewResultController::removeItem'
File
- src/
Controller/ LoopThroughViewResultController.php, line 313
Class
- LoopThroughViewResultController
- Class LoopThroughViewResultController.
Namespace
Drupal\business_rules\ControllerCode
public function removeItem($action_id, $item_type, $item_id, $method) {
$action = Action::load($action_id);
$items = $action
->getSettings('items');
unset($items[$item_id]);
$items = is_null($items) ? [] : $items;
$action
->setSetting('items', $items);
$action
->save();
if ($method == 'ajax') {
$response = new AjaxResponse();
$response
->addCommand(new RemoveCommand('#' . $item_id));
return $response;
}
else {
$url = new Url('entity.business_rules_action.edit_form', [
'business_rule_action' => $action_id,
]);
$string_url = $url
->toString() . '#business_rule-add_buttons';
return new RedirectResponse($string_url);
}
}