addFilter() 공개 정적인 메소드

Add a filter to the allowed filters array.
public static addFilter ( string $key, string $name, array $wheres, string $group = '', string $setKey = 'filter' )
$key string The key name of the filter. Appears in the query string, should be url-friendly.
$name string The display name of the filter. Usually appears as an option in the UI.
$wheres array The where array query to execute for the filter. Uses
$group string (optional) The nav module will group together any items with the same group name.
$setKey string The key name of the filter set.
 /**
  * Add new filters to the discussion model
  *
  * @param DiscussionModel $sender Sending controller instance.
  * @param array $args Event arguments.
  */
 public function discussionModel_initStatic_handler($sender, $args)
 {
     DiscussionModel::addFilterSet('prefix', 'Prefixes');
     DiscussionModel::addFilter('has-prefix', 'Has prefix', ['d.Prefix IS NOT NULL' => null], 'base-filter', 'prefix');
     DiscussionModel::addFilter('no-prefix', 'No prefix', ['d.Prefix IS NULL' => null], 'base-filter', 'prefix');
     $currentPrefixes = PrefixDiscussionPlugin::getPrefixes();
     unset($currentPrefixes['-']);
     $usedPrefixesResult = Gdn::sql()->select('Prefix')->from('Discussion')->where('Prefix IS NOT NULL')->get()->resultArray();
     foreach ($usedPrefixesResult as $row) {
         $prefix = $row['Prefix'];
         if (!isset($currentPrefixes[$prefix])) {
             $currentPrefixes[$prefix] = $prefix;
         }
     }
     natsort($currentPrefixes);
     foreach ($currentPrefixes as $prefix) {
         DiscussionModel::addFilter('prefix-' . $this->stringToSlug($prefix), $prefix, ['d.Prefix' => $prefix], 'prefix-filter', 'prefix');
     }
 }