diff --git a/services/Category.php b/services/Category.php index 84c838ca43d1be13961b3a9a57c77a4f44b70cbf..637a5d7baace0bf77fe3e338a38c3a84c50f4b48 100644 --- a/services/Category.php +++ b/services/Category.php @@ -27,7 +27,7 @@ class Category extends Service * $storagePrex , $storage , $storagePath 为找到当前的storage而设置的配置参数 * 可以在配置中更改,更改后,就会通过容器注入的方式修改相应的配置值 */ - public $storage = 'CategoryMysqldb'; // CategoryMongodb | CategoryMysqldb 当前的storage,如果在config中配置,那么在初始化的时候会被注入修改 + public $storage = 'CategoryMongodb'; // CategoryMongodb | CategoryMysqldb 当前的storage,如果在config中配置,那么在初始化的时候会被注入修改 /** * 设置storage的path路径, @@ -58,7 +58,22 @@ class Category extends Service } */ } - + // 动态更改为mongodb model + public function changeToMongoStorage() + { + $this->storage = 'CategoryMongodb'; + $currentService = $this->getStorageService($this); + $this->_category = new $currentService(); + } + + // 动态更改为mongodb model + public function changeToMysqlStorage() + { + $this->storage = 'CategoryMysqldb'; + $currentService = $this->getStorageService($this); + $this->_category = new $currentService(); + } + protected function actionGetCategoryEnableStatus() { return $this->_category->getCategoryEnableStatus(); @@ -140,21 +155,7 @@ class Category extends Service } - // 动态更改为mongodb model - public function changeToMongoStorage() - { - $this->storage = 'CategoryMongodb'; - $currentService = $this->getStorageService($this); - $this->_category = new $currentService(); - } - // 动态更改为mongodb model - public function changeToMysqlStorage() - { - $this->storage = 'CategoryMysqldb'; - $currentService = $this->getStorageService($this); - $this->_category = new $currentService(); - } /** * 得到分类的树数组。