/** * This will either lazy load a multi injector or find the specific adapter factory on the class and allow * the user to override the factory class loader to their app structure. * * @param $type * @return GenericInstanceFactory|MultiInstanceFactory */ public function getAdapterFactory($type) { $adapterFactory = $this->config->getAdapterFactory(); if ($adapterFactory instanceof GenericInstanceFactory) { return $adapterFactory; } // if they have used the namespaces option in the config load up the namespace chain $namespaces = $this->getConfig()->getNamespaces(); if (is_array($namespaces) && !empty($namespaces)) { $adapterFactory = MultiInstanceFactory::createFromNamespaceList($namespaces, array()); } else { $namespace = Introspection::getNamespaceBase(get_class($this)); $type = ucwords($type); $modelClass = $namespace . "\\Storage\\Adapter\\{$type}"; $adapterFactory = new MultiInstanceFactory($modelClass); } return $adapterFactory; }
/** * @return mixed */ public function getAdapterFactory() { if ($this->adapterFactory) { return $this->adapterFactory; } $factory = null; // use a default based on application settings if (isset($this->app['namespace.mysql.adapter'])) { $factory = new MultiInstanceFactory($this->app['namespace.mysql.adapter']); $factory->pushNamespace("Common\\Storage\\Adapter\\Mysql"); return $factory; } else { return new GenericInstanceFactory("Common\\Storage\\Adapter\\Mysql"); } }