Skip to content

Commit

Permalink
services方法去掉action开头的形式,全部改为public函数,以及代码格式的调整
Browse files Browse the repository at this point in the history
  • Loading branch information
fancyecommerce committed May 8, 2020
1 parent 78b818e commit b999199
Show file tree
Hide file tree
Showing 26 changed files with 459 additions and 361 deletions.
11 changes: 11 additions & 0 deletions services/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,48 +47,56 @@ class Admin extends Service
* @return string 得到编辑器上传图片upload url
*/
public function getXhEditorUploadImgUrl(){

return $this->xhEditorUploadImgUrl;
}
/**
* @return string 得到编辑器上传图片允许的文件格式
*/
public function getXhEditorUploadImgForamt(){

return $this->xhEditorUploadImgForamt;
}
/**
* @return string 得到编辑器上传Flash upload url
*/
public function getXhEditorUploadFlashUrl(){

return $this->xhEditorUploadFlashUrl;
}
/**
* @return string 得到编辑器上传Flash允许的文件格式
*/
public function getXhEditorUploadFlashFormat(){

return $this->xhEditorUploadFlashFormat;
}
/**
* @return string 得到编辑器上传Link upload url
*/
public function getXhEditorUploadLinkUrl(){

return $this->xhEditorUploadLinkUrl;
}
/**
* @return string 得到编辑器上传Link允许的文件格式
*/
public function getXhEditorUploadLinkFormat(){

return $this->xhEditorUploadLinkFormat;
}
/**
* @return string 得到编辑器上传Media upload url
*/
public function getXhEditorUploadMediaUrl(){

return $this->xhEditorUploadMediaUrl;
}
/**
* @return string 得到编辑器上传Media允许的文件格式
*/
public function getXhEditorUploadMediaFormat(){

return $this->xhEditorUploadMediaFormat;
}
/**
Expand All @@ -112,11 +120,13 @@ protected function initLangCode(){
$currentLangCode = Yii::$service->fecshoplang->defaultLangCode;
}
if (!$currentLangCode) {

throw new InvalidConfigException('default lang code must config');
}
if ($this->setTranslateLang($currentLangCode)) {
$this->_currentLangCode = $currentLangCode;
} else {

throw new InvalidConfigException('lang code: '.$currentLangCode.' can not find in fecshoplang service config, you should add this language config');
}
}
Expand All @@ -126,6 +136,7 @@ public function getCurrentLangCode(){
if (!$this->_currentLangCode) {
$this->initLangCode();
}

return $this->_currentLangCode;
}

Expand Down
2 changes: 1 addition & 1 deletion services/AdminUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function init()
* @param $data|array
* 数组格式:['username'=>'[email protected]','password'=>'xxxx']
*/
protected function actionLogin($data)
public function login($data)
{
return Yii::$service->adminUser->userLogin->login($data);
}
Expand Down
2 changes: 2 additions & 0 deletions services/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,11 @@ public function getChildService($childServiceName)
if (!isset($service['enableService']) || $service['enableService']) {
$this->_childService[$childServiceName] = Yii::createObject($service);
} else {

throw new InvalidConfigException('Child Service ['.$childServiceName.'] is disabled in '.get_called_class().', you must enable it! ');
}
} else {

throw new InvalidConfigException('Child Service ['.$childServiceName.'] does not exist in '.get_called_class().', you must config it! ');
}
}
Expand Down
18 changes: 9 additions & 9 deletions services/Blog.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,39 +17,39 @@
*/
class Blog extends Service
{
protected function actionGetCategoryMenu()
public functiongetCategoryMenu()
{
}

protected function actionGetArticleList()
public function getArticleList()
{
}

protected function actionGetCategoryArticleList()
public function getCategoryArticleList()
{
}

protected function actionGetArticleById()
public function getArticleById()
{
}

protected function actionSaveArticle()
public function saveArticle()
{
}

protected function actionDeleteArticle()
public function deleteArticle()
{
}

protected function actionSaveCategory()
public function saveCategory()
{
}

protected function actionDeleteCategory()
public function deleteCategory()
{
}

protected function actionGetCategoryById()
public function getCategoryById()
{
}
}
12 changes: 11 additions & 1 deletion services/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,14 @@ public function getCacheConfig()
$appName = Yii::$service->helper->getAppName();
$cacheConfig = Yii::$app->store->get($appName.'_cache');
if (!$cacheConfig || !is_array($cacheConfig)) {

return null;
}
if (isset($cacheConfig['allPageCache']) && $cacheConfig['allPageCache'] == Yii::$app->store->enable) {
$this->enable = true;
$this->enable = true;
}
$this->_cache_config = $cacheConfig;

return true;
}
public function init()
Expand All @@ -70,8 +72,10 @@ public function isEnable($cacheKey)
if ($this->enable && isset($this->_cache_config[$cacheConfigKey]) &&
$this->_cache_config[$cacheConfigKey] == Yii::$app->store->enable
) {

return true;
} else {

return false;
}
}
Expand All @@ -84,8 +88,10 @@ public function isEnable($cacheKey)
public function timeout($cacheKey)
{
if (isset($this->cacheConfig[$cacheKey]['timeout'])) {

return $this->cacheConfig[$cacheKey]['timeout'];
} else {

return 0;
}
}
Expand All @@ -97,8 +103,10 @@ public function timeout($cacheKey)
public function disableUrlParam($cacheKey)
{
if (isset($this->cacheConfig[$cacheKey]['disableUrlParam'])) {

return $this->cacheConfig[$cacheKey]['disableUrlParam'];
} else {

return '';
}
}
Expand All @@ -111,8 +119,10 @@ public function disableUrlParam($cacheKey)
public function cacheUrlParam($cacheKey)
{
if (isset($this->cacheConfig[$cacheKey]['cacheUrlParam'])) {

return $this->cacheConfig[$cacheKey]['cacheUrlParam'];
} else {

return '';
}
}
Expand Down
Loading

0 comments on commit b999199

Please sign in to comment.