Making CakePHP controller independent of how parameters are sent

Recently, I felt the need to make my CakePHP based controllers independent of how  parameters are sent. For instance, in Memento, I can handle parameters sent either in traditional way or using CakePHP style or even using the form (see usage below)
       Example (see how owner value is sent differently in the URL below)
           Traditional Way:  
           CakePHP way:  
 To make my controllers independent of how parameters are sent, I implemented this (below) small function in my app_controller class. This function takes care of how input (URL or form) parmeters are sent and returns the value, making your controllers independent of the logic to retrieve parameters.
  * retrieves a parameter value sent either in traditional way or using
  * cakephp way or using form
  * @param String/Array $parameters – (required)
  * @param String $dataKey – (optional) for retrieving data sent using form
  * returns Value/Array of values
  * Sample Usage:  getParameterValues(“id”)   , getParameterValues(array(“id”, “id2″)),  
  *                             getParameterValues(“id”, “User”), getParameterValues(array(“id”, “id2″), “User”)
 function getParameterValues($parameters, $dataKey = null){
  $isMultiple = true;
  //Check if single parameter or multiple parameters
      $parameters = array($parameters);
      $isMultiple = false;
  $values = array();
  //fetch parameters
  foreach($parameters as $key){
                  $values[$key] = $this->params['pass'][$key];
      else if(!empty($this->params['url'][$key]))
                 $values[$key] = $this->params['url'][$key];
     else if(!empty($dataKey) && isset($this->data[$dataKey][$key]))
                $values[$key] = $this->data[$dataKey][$key];
             return null;
  //if single parameter, then directly send the value. If multiple parameters, then send the value array
           return $values[$key];
          return $values;
Usage: (in your controller class)
1. If you want to retrieve single parameter
$owner = $this->getParameterValues(“owner”);  //here I want get “owner” parameter value
2. If you want to retrieve multiple parameters
$values = $this->getParameterValues(array(“owner”, “viewer”));
echo “owner = ” , $values['owner'] // contains owner value
echo “viewer = “, $values['viewer'] // contains viewer value
3. If values are sent using form
$data['User']['owner']  = 2
$data['User']['viewer'] = 10
Then you can use the second optional parameter to get values from the form
$values  = $this->getParameterValues(array(“owner”, “viewer”), “User”);
echo “owner = ” , $values['owner'] // contains owner value
echo “viewer = “, $values['viewer'] // contains viewer value