Update more modules to throw exceptions

This commit is contained in:
Kijin Sung 2018-09-05 23:12:08 +09:00
parent c1cbc5dbdb
commit be1ce69073
21 changed files with 142 additions and 116 deletions

View file

@ -250,9 +250,18 @@ class editorAdminController extends editor
$args->enabled = $enabled;
$args->site_srl = $site_srl;
// Check if the component exists
if(!$site_srl) $output = executeQuery('editor.isComponentInserted', $args);
else $output = executeQuery('editor.isSiteComponentInserted', $args);
if($output->data->count) return $this->setError('msg_component_is_not_founded');
if(!$site_srl)
{
$output = executeQuery('editor.isComponentInserted', $args);
{
else
{
$output = executeQuery('editor.isSiteComponentInserted', $args);
}
if($output->data->count)
{
return new BaseObject(-1, 'msg_component_is_not_founded');
}
// Inert a component
$args->list_order = getNextSequence();
if(!$site_srl) $output = executeQuery('editor.insertComponent', $args);

View file

@ -47,18 +47,23 @@ class editorController extends editor
{
$component = Context::get('component');
$method = Context::get('method');
if(!$component) return $this->setError('msg_component_is_not_founded', $component);
if(!$component)
{
throw new Rhymix\Framework\Exception('msg_component_is_not_founded', $component);
}
$oEditorModel = getModel('editor');
$oComponent = &$oEditorModel->getComponentObject($component);
if(!$oComponent->toBool()) return $oComponent;
if(!method_exists($oComponent, $method)) return $this->setError('msg_component_is_not_founded', $component);
if(!method_exists($oComponent, $method))
{
throw new Rhymix\Framework\Exception('msg_component_is_not_founded', $component);
}
//$output = call_user_method($method, $oComponent);
//$output = call_user_func(array($oComponent, $method));
if(method_exists($oComponent, $method)) $output = $oComponent->{$method}();
else return $this->setError('%s method is not exists', $method);
$output = $oComponent->{$method}();
if($output instanceof BaseObject && !$output->toBool()) return $output;
@ -93,13 +98,13 @@ class editorController extends editor
$module_info = $oModuleModel->getModuleInfoByModuleSrl($srl);
if (!$module_info->module_srl)
{
return $this->setError('msg_invalid_request');
throw new Rhymix\Framework\Exceptions\InvalidRequest;
}
$module_grant = $oModuleModel->getGrant($module_info, $logged_info);
if (!$module_grant->manager)
{
return $this->setError('msg_not_permitted');
throw new Rhymix\Framework\Exceptions\NotPermitted;
}
$module_srl[] = $srl;

View file

@ -492,11 +492,11 @@ class editorModel extends editor
// Create an object of the component and execute
$class_path = sprintf('%scomponents/%s/', $this->module_path, $component);
$class_file = sprintf('%s%s.class.php', $class_path, $component);
if(!file_exists($class_file)) return $this->setError('msg_component_is_not_founded', $component);
if(!file_exists($class_file)) return new BaseObject(-1, 'msg_component_is_not_founded', $component);
// Create an object after loading the class file
require_once($class_file);
$oComponent = new $component($editor_sequence, $class_path);
if(!$oComponent) return $this->setError('msg_component_is_not_founded', $component);
if(!$oComponent) return new BaseObject(-1, 'msg_component_is_not_founded', $component);
// Add configuration information
$component_info = $this->getComponent($component, $site_srl);
$oComponent->setInfo($component_info);