protected function getModel($mName = 'Default', $shared = true, $forceNew = false)
However I'm having a concern what is the best way to instantiate models.
When checking framework app repos, I usually see something like this:
$model = new $modelClass($this->container->get('db'), $modelState);
This assumes that all models are instance of AbstractDatabaseModel so I decided to use DI's buildObject method to auto provide required services:
// Get or instantiate model
$model = $container->get($mClass, $forceNew);
$model = $container->buildObject($mClass, $shared);
// Set model state
$state = $this->modelState;
if ($state instanceof Registry)
However In that case the model state is not available in the constructor.
Moreover, if an instance of same model already exists in DI, the state is overwritten.
There is another possibility to handle the dependencies: All my models could extend directly AbstractModel and be DatabaseAware, InputAware or WhateverAware like my Controllers are ContainerAware and LoggerAware.