# Custom stream filter


Available only in Professional and Business licenses

All custom scripts must be stored in directory application/filters.

# Creating filter script

Create a new file application/filters/example.php with code example:

namespace Filters;
use Core\Filter\AbstractFilter;
use Core\Locale\LocaleService;
use Traffic\Model\StreamFilter;
use Traffic\RawClick;
class example extends AbstractFilter
    public function getModes()
        return [
            StreamFilter::ACCEPT => LocaleService::t('filters.binary_options.' . StreamFilter::ACCEPT),
            StreamFilter::REJECT => LocaleService::t('filters.binary_options.' . StreamFilter::REJECT),
     * Filter settings template
    public function getTemplate()
        return '<input class="form-control" ng-model="filter.payload" />';
     * Check if $rawClick passes the filter (true - passed, false - failed)
    public function isPass(StreamFilter $filter, RawClick $rawClick)
        $value = $filter->getPayload();
        return ($filter->getMode() == StreamFilter::ACCEPT && $rawClick->getSubIdN(1) == $value)
            || ($filter->getMode() == StreamFilter::REJECT && $rawClick->getSubId(1) == $value);

You must reimplement these methods:

Method Description
getModes Return hash with available filter modes
getTemplate Template for filter settings. More about template syntax here angular.js.
isPass Method checks if click passes conditions or not. Return true if yes, false if no.

# Methods of $filter

Method Description
$filter->getPayload() Filter values
$filter->getMode() Current filter mode

# How to get request parameters

$this->getServerRequest() will return an object of the PSR-7 ServerRequest class

# Document character encoding standard

UTF-8 is obligatory.

Last Updated: 12/15/2020, 8:10:07 PM