Answer the question
In order to leave comments, you need to log in
How to use $this->module in static methods?
actually in my extension I'm trying to implement a connection either to the database through migration, or if the user has his own table for settings, then the user's table is actually the code
public static function tableName()
{
$module=self::module;
if(empty($module->modelDb)){
return '{{%menu_table}}';
}else{
return $module->dbName->name;
}
}
Undefined class constant 'module'
Answer the question
In order to leave comments, you need to log in
First of all, $this->module is not a static property, so it cannot be used in static methods. Secondly, as far as I understand the code that you brought to be in the model, and the module property in the controller.
In your case, the easiest way to get to the module properties is like this:MyModule::getInstanse()->propertyName
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question