public function newModel()
{
if ($this->newModel !== null) {
return call_user_func($this->newModel, $this);
} elseif ($this->controller->hasMethod('newModel')) {
return call_user_func([$this->controller, 'newModel'], $this);
} else {
throw new InvalidConfigException('Either "' . get_class($this) . '::newModel" must be set or controller must declare method "newModel()".');
}
}