You are here

public function CustomFilter::deleteRule in Custom filter 2.0.x

Same name and namespace in other branches
  1. 8 src/Entity/CustomFilter.php \Drupal\customfilter\Entity\CustomFilter::deleteRule()

Delete a rule.

Parameters

string $rid: The id of the rule.

Return value

$this

File

src/Entity/CustomFilter.php, line 139

Class

CustomFilter
Defines the entity for a filter in customfilter.

Namespace

Drupal\customfilter\Entity

Code

public function deleteRule($rid) {
  $ids[] = $rid;
  $i = 0;
  while ($i < count($ids)) {
    $rules = $this
      ->getRules($ids[$i]);
    foreach ($rules as $rule) {
      $ids[] = $rule['rid'];
    }
    $i++;
  }
  foreach ($ids as $id) {
    unset($this->rules[$id]);
  }
  return $this;
}