Yii Advanced Filters Extension
  • Package
  • Class

Packages

  • advancedfilters
    • components
    • dbhelpers
    • filters

Classes

  • AfBaseFilter
  • AfDefaultFilter
  • AfExactFilter
  • AfRangeFilter
  • AfRegexFilter
  • AfSubstringFilter

Class AfBaseFilter

All filter classes should extend AfBaseFilter. It contains abstract functions that must be implemented by child classes, as well as some helper functions for common filter operations.

CComponent
Extended by AfBaseFilter

Direct known subclasses

AfDefaultFilter, AfExactFilter, AfRangeFilter, AfRegexFilter, AfSubstringFilter

Abstract
Package: advancedfilters\filters
Author: Keith Burton kburton@kappasoft.net
Located at filters/AfBaseFilter.php

Methods summary

public
# __construct( string $columnExpression, string $filterExpression, boolean $invertLogic, CDbConnection $dbConnection, AfBaseDbHelper $dbHelper )

Constructor. Subclasses of AfBaseFilter should not be instantiated directly, but by using methods of the application component.

Constructor. Subclasses of AfBaseFilter should not be instantiated directly, but by using methods of the application component.

Parameters

$columnExpression

the disambiguated column name (or a valid SQL expression).

$filterExpression
the entered filter expression.
$invertLogic

whether the condition logic should be inverted to return the opposite results.

$dbConnection
the database connection object.
$dbHelper
the database helper object.
protected string
# getColumnExpression( )

Gets the column expression, with the result coalesced to an empty string if $this->treatNullAsEmptyString is true.

Gets the column expression, with the result coalesced to an empty string if $this->treatNullAsEmptyString is true.

Returns

string
the column expression.
protected string
# getFilterExpression( )

Gets the filter expression segment entered by the user.

Gets the filter expression segment entered by the user.

Returns

string
the entered filter expression segment.
protected boolean
# getInvertLogic( )

Specifies whether the filter logic should be inverted in the resulting database criteria.

Specifies whether the filter logic should be inverted in the resulting database criteria.

Returns

boolean
whether the filter logic should be inverted.
protected AfBaseDbHelper
# getDbHelper( )

Gets a database helper class to provide database specific syntax for filter criteria.

Gets a database helper class to provide database specific syntax for filter criteria.

Returns

AfBaseDbHelper
the database helper object.
protected CDbConnection
# getDbConnection( )

Gets a connection to the relevant database so that filters can perform queries directly, in order to validate syntax.

Gets a connection to the relevant database so that filters can perform queries directly, in order to validate syntax.

Returns

CDbConnection
the connection object.
public static AfBaseFilter
# createFilter( string $columnExpression, string $filterExpression, boolean $invertLogic, CDbConnection $dbConnection, AfBaseDbHelper $dbHelper, array $filterConfig )

Instantiate and return the first filter that can process the provided filter expression.

Instantiate and return the first filter that can process the provided filter expression.

This is guaranteed to return a valid class as the AfDefaultFilter responds to any expression and is returned if no other filter can process the expression.

Parameters

$columnExpression

the column or expression to which to apply this filter.

$filterExpression
the string containing the filter pattern.
$invertLogic

whether the condition logic should be inverted.

$dbConnection
the database connection object.
$dbHelper

the helper to use when dealing with database specific syntax.

$filterConfig

an array of configuration for all available filter types.

Returns

AfBaseFilter
an instance of a subclass of AfBaseFilter.
protected static boolean|string
# stripPrefixSuffixString( string $string, string $prefix, string $suffix )

A generic helper function to strip a specified prefix and suffix from a string if both are found. The prefix and/or suffix can be an empty string, to allow matching at only one side of the string. Comparison of the prefix and suffix is case insensitive.

A generic helper function to strip a specified prefix and suffix from a string if both are found. The prefix and/or suffix can be an empty string, to allow matching at only one side of the string. Comparison of the prefix and suffix is case insensitive.

If the string is surrounded by the specified prefix and suffix, the stripped string will be returned with any whitespace intact. Otherwise, boolean false is returned.

Parameters

$string
the string to test and strip.
$prefix

the prefix to compare. Use an empty string to ignore the prefix.

$suffix

the suffix to compare. Use an empty string to ignore the suffix.

Returns

boolean|string

the stripped string if the specified prefix and suffix are matched. Boolean false otherwise.

abstract public boolean
# acceptsFilterExpression( )

The implementation of this method should analyse the filter expression to determine whether this filter accepts the expression.

The implementation of this method should analyse the filter expression to determine whether this filter accepts the expression.

Returns

boolean
whether the filter accepts the provided expression.
abstract public CDbCriteria
# getCriteria( )

Gets a CDbCriteria object with the filter conditions applied. The criteria can be merged with an existing criteria object.

Gets a CDbCriteria object with the filter conditions applied. The criteria can be merged with an existing criteria object.

Returns

CDbCriteria
the new criteria object.

Magic methods summary

Properties summary

public boolean $active

whether this filter should be included when processing filter expressions.

whether this filter should be included when processing filter expressions.

# true
public integer $priority

the priority with which this should be processed. Smaller numbers are processed first.

the priority with which this should be processed. Smaller numbers are processed first.

# 0
public boolean $treatNullAsEmptyString

whether null results from column expressions should be coalesced to empty strings. This allows the columns to be included in filter results.

whether null results from column expressions should be coalesced to empty strings. This allows the columns to be included in filter results.

# true
Yii Advanced Filters Extension API documentation generated by ApiGen