public function BusinessRulesItemsController::removeItem in Business Rules 8
Same name and namespace in other branches
- 2.x src/Controller/BusinessRulesItemsController.php \Drupal\business_rules\Controller\BusinessRulesItemsController::removeItem()
Remove one item from the Business Rule.
Parameters
string $business_rule: The business rule id.
string $item_type: The item type: action|condition.
string $item_id: The item id.
string $method: The method ajax|nojs.
Return value
\Drupal\Core\Ajax\AjaxResponse|\Symfony\Component\HttpFoundation\RedirectResponse The AjaxResponse or the RedirectResponse.
1 string reference to 'BusinessRulesItemsController::removeItem'
File
- src/
Controller/ BusinessRulesItemsController.php, line 362
Class
- BusinessRulesItemsController
- Class BusinessRulesItemsController.
Namespace
Drupal\business_rules\ControllerCode
public function removeItem($business_rule, $item_type, $item_id, $method) {
$rule = BusinessRule::load($business_rule);
$itemObj = new BusinessRulesItemObject($item_id, $item_type, 0);
$rule
->removeItem($itemObj);
$rule
->save();
if ($method == 'ajax') {
$chart_definition = $this->flowchart
->getGraphDefinition($rule);
$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_rule.edit_form', [
'business_rule' => $business_rule,
]);
$string_url = $url
->toString() . '#business_rule-add_buttons';
return new RedirectResponse($string_url);
}
}