public function CustomFilter::getRules in Custom filter 2.0.x
Same name and namespace in other branches
- 8 src/Entity/CustomFilter.php \Drupal\customfilter\Entity\CustomFilter::getRules()
Get all rules for same parent rule.
Parameters
string $prid: The parent id of the rules which you want all the childrens.
bool $sort: (optional) sort the rules using sortRules method.
Return value
array An array with all child rules from specified prid.
2 calls to CustomFilter::getRules()
- CustomFilter::deleteRule in src/
Entity/ CustomFilter.php - Delete a rule.
- CustomFilter::getRulesTree in src/
Entity/ CustomFilter.php - Get a tree of rules.
File
- src/
Entity/ CustomFilter.php, line 232
Class
- CustomFilter
- Defines the entity for a filter in customfilter.
Namespace
Drupal\customfilter\EntityCode
public function getRules($prid = '', $sort = FALSE) {
// If rules is not an array(is empty) return a new empty array.
if (!is_array($this->rules)) {
return [];
}
$answer = [];
foreach ($this->rules as $rule) {
if ($rule['prid'] == $prid) {
$answer[$rule['rid']] = $rule;
}
}
if ($sort) {
$this
->sortRules($answer);
}
return $answer;
}