/**
  * Akce pro odebrání pravidel z rulesetu
  * @param int $id
  * @param string|int $rules
  * @param string $result = "simple" (varianty "simple", "rules")
  */
 public function actionRemoveRules($id, $rules, $result = "simple")
 {
     //najití RuleSetu a kontroly
     $ruleSet = $this->ruleSetsFacade->findRuleSet($id);
     $this->ruleSetsFacade->checkRuleSetAccess($ruleSet, $this->user->id);
     /** @var int[] $ruleIdsArr */
     $ruleIdsArr = explode(',', str_replace(';', ',', $rules));
     if (!empty($ruleIdsArr)) {
         foreach ($ruleIdsArr as $ruleId) {
             if (!$ruleId) {
                 continue;
             }
             try {
                 $rule = $this->rulesFacade->findRule($ruleId);
                 $this->ruleSetsFacade->removeRuleFromRuleSet($rule, $ruleSet);
             } catch (\Exception $e) {
                 continue;
             }
         }
     }
     $this->ruleSetsFacade->updateRuleSetRulesCount($ruleSet);
     if ($result == "rules") {
         $result = ['ruleset' => $ruleSet->getDataArr(), 'rules' => []];
         $result['rules'] = $this->prepareRulesResult($ruleIdsArr, $ruleSet);
         $this->sendJsonResponse($result);
     } else {
         $this->sendJsonResponse(['state' => 'ok']);
     }
 }
 /**
  * Akce pro odebrání pravidel z rulesetu
  * @param int $id
  * @param int|string $rules
  * @throws \Nette\Application\BadRequestException
  * @SWG\Delete(
  *   tags={"RuleSets"},
  *   path="/rule-sets/{id}/rules",
  *   summary="Remove rules from the selected rule set",
  *   security={{"apiKey":{}},{"apiKeyHeader":{}}},
  *   produces={"application/json","application/xml"},
  *   @SWG\Parameter(
  *     name="id",
  *     description="RuleSet ID",
  *     required=true,
  *     type="integer",
  *     in="path"
  *   ),
  *   @SWG\Parameter(
  *     name="rules",
  *     description="IDs of rules (optinally multiple - separated with , or ;)",
  *     required=true,
  *     type="array",
  *     @SWG\items(
  *       type="integer"
  *     ),
  *     collectionFormat="csv",
  *     in="query"
  *   ),
  *   @SWG\Response(
  *     response=200,
  *     description="Rules have been removed from the rule set.",
  *     @SWG\Schema(ref="#/definitions/StatusResponse"),examples={"code":200,"status":"OK"}
  *   ),
  *   @SWG\Response(response=404, description="Requested rule set was not found.")
  * )
  */
 public function actionDeleteRules($id, $rules)
 {
     /** @var RuleSet $ruleSet */
     $ruleSet = $this->findRuleSetWithCheckAccess($id);
     /** @var int[] $ruleIdsArr */
     $ruleIdsArr = explode(',', str_replace(';', ',', $rules));
     if (!empty($ruleIdsArr)) {
         foreach ($ruleIdsArr as $ruleId) {
             if (!$ruleId) {
                 continue;
             }
             try {
                 $rule = $this->rulesFacade->findRule($ruleId);
                 $this->ruleSetsFacade->removeRuleFromRuleSet($rule, $ruleSet);
             } catch (\Exception $e) {
                 continue;
             }
         }
     }
     $this->ruleSetsFacade->updateRuleSetRulesCount($ruleSet);
     $this->resource = ['code' => 200, 'status' => 'ok'];
     $this->sendResource();
 }