Remove unnecessary use of BaseObject

- 트리거 등 반환값이 필요하지 않은 곳에서 new BaseObject()를 반환하는 것 삭제
- 모듈 설치, 업데이트 후 무의미한 new BaseObject()를 반환하는 것 삭제
- 사용자에게 에러 메시지를 돌려주는 용도로 new BaseObject(-1, '에러메시지')를
  사용하는 경우는 대부분 $this->setError()로 변경함. 언어 변환과 sprintf()
  처리까지 한 번에 이루어지므로 이쪽이 더 편리함.
This commit is contained in:
Kijin Sung 2017-12-01 00:54:51 +09:00
parent 03d74a984f
commit 84e5542d77
103 changed files with 692 additions and 862 deletions

View file

@ -59,9 +59,9 @@ class trashAdminController extends trash
//module relation data delete...
$output = $this->_relationDataDelete($isAll, $is_type, $trashSrls);
if(!$output->toBool()) return new BaseObject(-1, $output->message);
if(!$output->toBool()) return $this->setError($output->message);
if(!$this->_emptyTrash($trashSrls)) return new BaseObject(-1, $lang->fail_empty);
if(!$this->_emptyTrash($trashSrls)) return $this->setError($lang->fail_empty);
$this->setMessage('success_deleted', 'info');
@ -84,10 +84,9 @@ class trashAdminController extends trash
$args = new stdClass();
$args->originModule = $is_type;
$output = $oTrashModel->getTrashAllList($args);
if(!$output->toBool())
{
return new BaseObject(-1, $output->message);
return $output;
}
if(is_array($output->data))
@ -105,7 +104,7 @@ class trashAdminController extends trash
$output = $oTrashModel->getTrashList($args);
if(!$output->toBool())
{
return new BaseObject(-1, $output->message);
return $output;
}
}
@ -115,20 +114,21 @@ class trashAdminController extends trash
{
//class file check
$classPath = ModuleHandler::getModulePath($oTrashVO->getOriginModule());
if(!is_dir(FileHandler::getRealPath($classPath))) return new BaseObject(-1, 'not exist restore module directory');
if(!is_dir(FileHandler::getRealPath($classPath))) return $this->setError('not exist restore module directory');
$classFile = sprintf('%s%s.admin.controller.php', $classPath, $oTrashVO->getOriginModule());
$classFile = FileHandler::getRealPath($classFile);
if(!file_exists($classFile)) return new BaseObject(-1, 'not exist restore module class file');
if(!file_exists($classFile)) return $this->setError('not exist restore module class file');
$oAdminController = getAdminController($oTrashVO->getOriginModule());
if(!method_exists($oAdminController, 'emptyTrash')) return new BaseObject(-1, 'not exist restore method in module class file');
if(!method_exists($oAdminController, 'emptyTrash')) return $this->setError('not exist restore method in module class file');
$output2 = $oAdminController->emptyTrash($oTrashVO->getSerializedObject());
if(!$output2->toBool()) return new BaseObject(-1, $output2->message);
if(!$output2->toBool()) return $output;
}
}
return new BaseObject(0, lang('success_deleted'));
return new BaseObject(0, 'success_deleted');
}
/**
@ -150,18 +150,18 @@ class trashAdminController extends trash
{
$oTrashModel = getModel('trash');
$output = $oTrashModel->getTrash($value);
if(!$output->toBool()) return new BaseObject(-1, $output->message);
if(!$output->toBool()) return $output;
//class file check
$classPath = ModuleHandler::getModulePath($output->data->getOriginModule());
if(!is_dir(FileHandler::getRealPath($classPath))) return new BaseObject(-1, 'not exist restore module directory');
if(!is_dir(FileHandler::getRealPath($classPath))) return $this->setError('not exist restore module directory');
$classFile = sprintf('%s%s.admin.controller.php', $classPath, $output->data->getOriginModule());
$classFile = FileHandler::getRealPath($classFile);
if(!file_exists($classFile)) return new BaseObject(-1, 'not exist restore module class file');
if(!file_exists($classFile)) return $this->setError('not exist restore module class file');
$oAdminController = getAdminController($output->data->getOriginModule());
if(!method_exists($oAdminController, 'restoreTrash')) return new BaseObject(-1, 'not exist restore method in module class file');
if(!method_exists($oAdminController, 'restoreTrash')) return $this->setError('not exist restore method in module class file');
$originObject = unserialize($output->data->getSerializedObject());
$output = $oAdminController->restoreTrash($originObject);
@ -169,14 +169,14 @@ class trashAdminController extends trash
if(!$output->toBool())
{
$oDB->rollback();
return new BaseObject(-1, $output->message);
return $output;
}
}
// restore object delete in trash box
if(!$this->_emptyTrash($trashSrlList)) {
$oDB->rollback();
return new BaseObject(-1, $lang->fail_empty);
return $this->setError($lang->fail_empty);
}
$oDB->commit();
}
@ -193,7 +193,7 @@ class trashAdminController extends trash
*/
function procTrashAdminGetList()
{
if(!Context::get('is_logged')) return new BaseObject(-1,'msg_not_permitted');
if(!Context::get('is_logged')) return $this->setError('msg_not_permitted');
$trashSrls = Context::get('trash_srls');
if($trashSrls) $trashSrlList = explode(',', $trashSrls);

View file

@ -98,7 +98,7 @@ class trashAdminView extends trash
$oTrashModel = getModel('trash');
$output = $oTrashModel->getTrash($trash_srl);
if(!$output->data->getTrashSrl()) return new BaseObject(-1, 'msg_invalid_request');
if(!$output->data->getTrashSrl()) return $this->setError('msg_invalid_request');
$originObject = unserialize($output->data->getSerializedObject());
if(is_array($originObject)) $originObject = (object)$originObject;

View file

@ -18,7 +18,7 @@ class trash extends ModuleObject
*/
function moduleInstall()
{
return new BaseObject();
}
/**
@ -27,9 +27,6 @@ class trash extends ModuleObject
*/
function checkUpdate()
{
//$oDB = &DB::getInstance();
//$oModuleModel = getModel('module');
return false;
}
@ -39,10 +36,7 @@ class trash extends ModuleObject
*/
function moduleUpdate()
{
//$oDB = &DB::getInstance();
//$oModuleModel = getModel('module');
return new BaseObject(0,'success_updated');
}
}
/* End of file trash.class.php */