You are here

customfilter.module in Custom filter 8

Allows the users with the right permission to define custom filters.

File

customfilter.module
View source
<?php

/**
 * @file
 * Allows the users with the right permission to define custom filters.
 */

// Use the entity.
use Drupal\customfilter\Entity\CustomFilter;

/**
 * Implements hook_filter_info_alter().
 *
 * This function add the filters from customfilter.
 */
function customfilter_filter_info_alter(&$info) {
  $filters = CustomFilter::getFilters();
  foreach ($filters as $filter) {
    $id = 'customfilter_' . $filter
      ->id();
    $info[$id]['description'] = $filter
      ->getDescription();
    $info[$id]['weight'] = 0;
    $info[$id]['status'] = FALSE;
    $info[$id]['cache'] = $filter
      ->getCache();
    $info[$id]['settings'] = array(
      'id' => $filter
        ->id(),
    );
    $info[$id]['id'] = $id;
    $info[$id]['module'] = 'customfilter';
    $info[$id]['title'] = $filter
      ->label();
    $info[$id]['type'] = 2;
    $info[$id]['class'] = 'Drupal\\customfilter\\Plugin\\Filter\\CustomFilterBaseFilter';
    $info[$id]['provider'] = 'customfilter';
  }
}

Functions