Better way to create a class

Hello friends

My project has two class, both use the same function. How better way to create other class to implement this function and reuse?

For example I have the class ClientController.php and ProductController.php, in this class I have this function:

protected function getAdministradores() 


            $a = array();

            $adms = Usuarios::model()->administrativo()->findAll();

            foreach($adms as $k => $adm) { $a[] = $adm->usuario; }

            return $a;


So I want create a class with this function and use on my functions ClientController.php and ProductController.php

You don’t need to. Just move the method to the base controller Gii created for you (components/Controller.php).


Thank you. I get it.

I don’t understand

all that is in the component controller is inherited by the other controller. So when I put my function in component controller, I only need call the function in my other class: $this->myFunction()