public function ActionSetController::removeItem in Business Rules 8
Same name and namespace in other branches
- 2.x src/Controller/ActionSetController.php \Drupal\business_rules\Controller\ActionSetController::removeItem()
Remove item from condition.
Parameters
string $action_id: The action id.
string $item_id: The item id.
string $method: The method name: ajax|nojs.
Return value
\Drupal\Core\Ajax\AjaxResponse|\Symfony\Component\HttpFoundation\RedirectResponse The AjaxResponse or the RedirectResponse.
1 string reference to 'ActionSetController::removeItem'
File
- src/
Controller/ ActionSetController.php, line 300
Class
- ActionSetController
- Class ActionSetController.
Namespace
Drupal\business_rules\ControllerCode
public function removeItem($action_id, $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') {
$chart_definition = $this->util->flowchart
->getGraphDefinition($action);
$textarea = '<textarea id="graph_definition" style="display: none;">' . $chart_definition . '</textarea>';
$response = new AjaxResponse();
$response
->addCommand(new RemoveCommand('#' . $item_id));
$response
->addCommand(new ReplaceCommand('#graph_definition', $textarea));
$response
->addCommand(new UpdateFlowchartCommand());
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);
}
}