I don't believe it's possible. I think getSource()
is only called once, when initializing the model. I think this because when I watch my query log - the queries to get table structure are only run once. Therefore any subsequent changes to it's output would have no effect.
I'd examine how to make 1 model per table. Maybe something like a generic wrapper:
class Super{
private $ActiveModel;
public setActiveModel($ActiveModel){
$this->ActiveModel = $ActiveModel;
}
// forward on any undefined method calls to the active model
public function __call($name,$arguments){
return $this->ActiveModel->name(...$arguments);
}
// return any undefined variables from the active model
public function __get($name){
return $this->ActiveModel->$name;
}
}
$MainObject = new Super();
$MainObject->setActiveModel(Table1Model::findFirst(['conditions here']));
$MainObject->someMethodCall();
$MainObject->setActiveModel(Table2Model::findFirst(['more conditions here']));
$MailObject->someOtherMethodCall();
$someVariable = $MailObject->someVariable;