Yii filter filter ()

each controller must have method filters (), there you can specify some classes, I want to know how these classes are included in the framework? how are these classes set up, and when, maybe someone can give me a template for this way of using filters () and include some classes?

+3
source share
1 answer

Controller filters are classes derived from CFilter.

As the sample documentation shows, you configure them inside your controller as follows:

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 1you indicate the path for the hypothetical class PerformanceFilter; Yii loads it like any other component.

2 3 . /; .

+8

All Articles