How To Get Short Code ?

Dear all,

I have 2 controllers which must authenticate login before access,but I repeat the filters code to much, how can we have short for this, here is my code:


class CategoriesController extends Controller

{ 	

	

	public function filters() {

		return array (

				'checkLogin + index, create,edit',

		);

	}

	public function filterCheckLogin($filterChain) {

		if(isset(Yii::app()->request->cookies['loginSuccess']))

			$filterChain->run();

		else

			$this->redirect(array('/admin/login'));

	}

}




class ProductsController extends Controller

{ 	

	

	public function filters() {

		return array (

				'checkLogin + index, create,edit,delete,detail,changeStatus',

		);

	}

	public function filterCheckLogin($filterChain) {

		if(isset(Yii::app()->request->cookies['loginSuccess']))

			$filterChain->run();

		else

			$this->redirect(array('/admin/login'));

	}

}




how Can we declair the filters in one class for that the controllers can call filters function, it will not repeat code for filters

thankyou very much

Hi

you could make your own filter and use it

check this

http://www.yiiframework.com/doc/guide/1.1/en/extension.create#filter

yes, it has worked, thankyou very much