every controller should have method filters(), there you can specify some classes, i want to know, how those classes are include by framework ? how those classes are configuring, and when, and maybe someone can give me a pattern for this way of using filters() and including some classes ?
The controller filters are classes deriving from CFilter.
As the documentation example shows, you configure them inside your controller like this:
public function filters()
{
return array(
'postOnly + edit, create',
array(
'application.filters.PerformanceFilter - edit, create', // 1
'unit'=>'second', // 2
'amount'=>42, // 3
),
);
}
In the line marked 1 you provide the path for the hypothetical class PerformanceFilter; Yii loads that as any other component.
In the line marked 2 and 3 you initialize properties. You can go on with any number of key/value pairs; they will all get used to set the filter's properties with the corresponding names.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With