I think it would be useful to have a standard filter that loaded and error-checked parameters to a Controller’s action. Something like how rules() handles form parameters for CModel. There would be analogs to the various CValidator and a few things specific to Controller parameters. For example, instead of ‘safe’/‘unsafe’ the rules would also define the assignments themselves. In particular, a parameter could have ‘assign’ or ‘assignByPk’ with the latter used when the parameter is a primary key.
So the user could make a function in the controller like this:
public function parameters()
{
return array(
array('mode','assign'), // $this->mode=$_GET['mode'] or null if it didn't exist
array('mode','numerical','integerOnly'=>true,'min'=>1,'max'=>7), // validation
array('category','assign','allowEmpty'=>false,'source'=>'post'), // $this->category=$_POST['category'] with an exception if it didn't exist
array('category','length','min'=>1,'max'=>7), // validation
array('companyId','assign','name'=>'company'), // $this->companyId=$_GET['company']
array('companyId','required'), // validation
array('employee','assignFromPk','name'=>'id','allowEmpty'=>false,actions=>'view,update',
criteria=>('condition'=>'companyId={controller}->companyId','with'=>'Projects'), // employee is a model from $_GET['id']
);
}
Note that {controller} would be replaced by the controller instance in the last case. Why is this better than action parameter binding? It centralizes things more and it’s more flexible.
Greg