Can't access class members from controller

If i have a module and i have a class member


public $test = 'test';

I can’t access it within a controller. If i do inside a controller $this->test; it throws an error. Of course that is because the controller does not extend the module but the CController.

So how can we access class members from the controller that were defined in the module?

OK doing this inside a controller works


public $settings;

	public function actionIndex()

	{

	    $this->settings = $this->getModule()->settings;

	    

		$this->render('index');

	}

But i will need to do that in each controller for each class member. And that’s not a really good practice. Any other way? Or alternative of how can i inherit the controllers from one main controller?

Thanks.

Sorted by some really cool controller class hierarchy

I am not understanding well. Where are you defining this variables? Inside module or controller?

If you define it at the module, in controller you will have to do $this->getModule()->variable

Yes as the example i gave above does it i figured it out, Though since i don’t want to do that in each controller i made some other adjustments.