public function factory($module, $type = self::TYPE_DEFAULT)
{
if (isset($this->models[$type][$module])) {
return $this->models[$type][$module];
}
$moduleName = $this->modules->normalizeModuleName($module);
$config = $this->configFactory->factory($module);
$moduleEntity = $this->moduleModel->getModule($moduleName);
$restModel = new DoctrineRestServiceModel($moduleEntity, $this->modules, $config);
$restModel->setEventManager($this->createEventManager());
$restModel->setServiceManager($this->getServiceManager());
switch ($type) {
case self::TYPE_DEFAULT:
$this->models[$type][$module] = $restModel;
return $restModel;
default:
throw new Exception\InvalidArgumentException(sprintf('Model of type "%s" does not exist or cannot be handled by this factory', $type));
}
}