I have one method in several models, implemented in different ways. I only know the name of table in database. I must find model of this table. How to do?
interface BaseIndexedModel
{
public function writeSometext();
}
and some models implement it. Example
class First extends \yii\db\ActiveRecord implements BaseIndexedModel
{
public function writeSometext(){
return "1";
}
}
class Second extends \yii\db\ActiveRecord implements BaseIndexedModel
{
public function writeSometext(){
return "2";
}
}
Next on a certain event I need to call the desired model and this method. But when I call, I will only know the database table, but not the model.
If table "first", First::writeSometext();
If table "second", Second:: writeSometext();