Moodle PHP Documentation 4.2
Moodle 4.2.8 (Build: 20240610) (2d41ac46f45)
core_reportbuilder\local\report\filter Class Reference

Public Member Functions

 __construct (string $filterclass, string $name, lang_string $header, string $entityname, string $fieldsql='', array $fieldparams=[])
 Filter constructor.
 
 add_join (string $join)
 Add join clause required for this filter to join to existing tables/entities.
 
 add_joins (array $joins)
 Add multiple join clauses required for this filter, passing each to {.
 
 get_entity_name ()
 Return filter entity name.
 
 get_field_params ()
 Get the SQL params for the field being filtered.
 
 get_field_sql ()
 Get SQL expression for the field.
 
 get_field_sql_and_params (int $index=0)
 Retrieve SQL expression and parameters for the field.
 
 get_filter_class ()
 Get filter class path.
 
 get_header ()
 Return header.
 
 get_is_available ()
 Return available state of the filter for the current user.
 
 get_joins ()
 Return joins.
 
 get_name ()
 Get filter name.
 
 get_options ()
 Get the options for the filter, returning via the the previously set options or generated via defined options callback.
 
 get_persistent ()
 Return filter persistent.
 
 get_unique_identifier ()
 Return unique identifier for this filter.
 
 restrict_limited_operators (array $operators)
 Filter given operators to include only those previously defined by {.
 
 set_field_sql (string $sql, array $params=[])
 Set the SQL expression for the field that is being filtered.
 
 set_header (lang_string $header)
 Set header.
 
 set_is_available (bool $available)
 Conditionally set whether the filter is available.
 
 set_limited_operators (array $limitoperators)
 Set a limited subset of operators that should be used for the filter, refer to each filter class to find defined operator constants.
 
 set_options ($options)
 Set the options for the filter in the format that the filter class expected (e.g.
 
 set_options_callback (callable $callback)
 Set the options for the filter to be returned by a callback (that receives no arguments) in the format that the filter class expects.
 
 set_persistent (filter_model $persistent)
 Set filter persistent.
 

Protected Attributes

bool $available = true
 $available
 
string[] $joins = []
 $joins
 
array $limitoperators = []
 $limitoperators
 
mixed $options
 $options
 
filter_model $persistent
 $persistent
 

Constructor & Destructor Documentation

◆ __construct()

core_reportbuilder\local\report\filter::__construct ( string $filterclass,
string $name,
lang_string $header,
string $entityname,
string $fieldsql = '',
array $fieldparams = [] )

Filter constructor.

Parameters
string$filterclassFilter type class to use, must extend {
See also
base} filter class
Parameters
string$nameInternal name of the filter
lang_string$headerTitle of the filter used in reports
string$entitynameName of the entity this filter belongs to. Typically when creating filters within entities this value should be the result of calling {
See also
get_entity_name}, however if creating filters inside reports directly it should be the name of the entity as passed to {
core_reportbuilder\local\report\base\annotate_entity}
Parameters
string$fieldsqlSQL clause to use for filtering, {
See also
set_field_sql}
Parameters
array$fieldparams
Exceptions
moodle_exceptionFor invalid filter class

Member Function Documentation

◆ add_join()

core_reportbuilder\local\report\filter::add_join ( string $join)

Add join clause required for this filter to join to existing tables/entities.

This is necessary in the case where {

See also
set_field_sql} is selecting data from a table that isn't otherwise queried
Parameters
string$join
Return values
self

◆ add_joins()

core_reportbuilder\local\report\filter::add_joins ( array $joins)

Add multiple join clauses required for this filter, passing each to {.

See also
add_join}

Typically when defining filters in entities, you should pass {

See also
core_reportbuilder\local\report\base\get_joins} to this method, so that all entity joins are included in the report when your filter is used in it
Parameters
string[]$joins
Return values
self

◆ get_entity_name()

core_reportbuilder\local\report\filter::get_entity_name ( )

Return filter entity name.

Return values
string

◆ get_field_params()

core_reportbuilder\local\report\filter::get_field_params ( )

Get the SQL params for the field being filtered.

Return values
array

◆ get_field_sql()

core_reportbuilder\local\report\filter::get_field_sql ( )

Get SQL expression for the field.

Return values
string

◆ get_field_sql_and_params()

core_reportbuilder\local\report\filter::get_field_sql_and_params ( int $index = 0)

Retrieve SQL expression and parameters for the field.

Parameters
int$index
Return values
array[$sql, [...$params]]

◆ get_filter_class()

core_reportbuilder\local\report\filter::get_filter_class ( )

Get filter class path.

Return values
string

◆ get_header()

core_reportbuilder\local\report\filter::get_header ( )

Return header.

Return values
string

◆ get_is_available()

core_reportbuilder\local\report\filter::get_is_available ( )

Return available state of the filter for the current user.

Return values
bool

◆ get_joins()

core_reportbuilder\local\report\filter::get_joins ( )

Return joins.

Return values
string[]

◆ get_name()

core_reportbuilder\local\report\filter::get_name ( )

Get filter name.

Return values
string

◆ get_options()

core_reportbuilder\local\report\filter::get_options ( )

Get the options for the filter, returning via the the previously set options or generated via defined options callback.

Return values
mixed

◆ get_persistent()

core_reportbuilder\local\report\filter::get_persistent ( )

Return filter persistent.

Return values
filter_model|null

◆ get_unique_identifier()

core_reportbuilder\local\report\filter::get_unique_identifier ( )

Return unique identifier for this filter.

Return values
string

◆ restrict_limited_operators()

core_reportbuilder\local\report\filter::restrict_limited_operators ( array $operators)

Filter given operators to include only those previously defined by {.

See also
set_limited_operators}
Parameters
array$operatorsAll operators as defined by the filter class
Return values
array

◆ set_field_sql()

core_reportbuilder\local\report\filter::set_field_sql ( string $sql,
array $params = [] )

Set the SQL expression for the field that is being filtered.

It will be passed to the filter class

Parameters
string$sql
array$params
Return values
self

◆ set_header()

core_reportbuilder\local\report\filter::set_header ( lang_string $header)

Set header.

Parameters
lang_string$header
Return values
self

◆ set_is_available()

core_reportbuilder\local\report\filter::set_is_available ( bool $available)

Conditionally set whether the filter is available.

For instance the filter may be added to a report with the expectation that only some users are able to see it

Parameters
bool$available
Return values
self

◆ set_limited_operators()

core_reportbuilder\local\report\filter::set_limited_operators ( array $limitoperators)

Set a limited subset of operators that should be used for the filter, refer to each filter class to find defined operator constants.

Parameters
array$limitoperatorsSimple array of operator values
Return values
self

◆ set_options()

core_reportbuilder\local\report\filter::set_options ( $options)

Set the options for the filter in the format that the filter class expected (e.g.

the "select" filter expects an array)

This method should only be used if the options do not require any calculations/queries, in which case {

See also
set_options_callback} should be used. For performance, {
get_string} shouldn't be used either, use of {
lang_string} is instead encouraged
Parameters
mixed$options
Return values
self

◆ set_options_callback()

core_reportbuilder\local\report\filter::set_options_callback ( callable $callback)

Set the options for the filter to be returned by a callback (that receives no arguments) in the format that the filter class expects.

Parameters
callable$callback
Return values
self

◆ set_persistent()

core_reportbuilder\local\report\filter::set_persistent ( filter_model $persistent)

Set filter persistent.

Parameters
filter_model$persistent
Return values
self

The documentation for this class was generated from the following file: