<?php
/**
* アクション管理クラス
*
* 実行するアクションクラスを動的に管理
*/
class action_manager {
/**
* 実行アクションクラスの振り分けを行う
*
*/
public function dispatch($model, $screen, $process) {
$config = config::get_instance();
$app_action_file = $config->search('app_action_file');
// 実行対象アクションクラス名とファイル名を決定
$action_file = controller::create_include_file_path($screen, $process, $app_action_file);
$action_class = controller::create_class_file_name($screen, $process, $app_action_file);
// 実行対象アクションファイルの存在チェック
if(check::check_exist_file($action_file)) {
// 対象アクションファイル読み込み
require_once($action_file);
} else {
throw new custom_exception('アクションの読み込み不可', 1);
}
// 実行対象アクションクラスの存在チェック
if(check::check_exist_class($action_class)) {
// 対象アクションクラスインスタンス作成
$obj = new $action_class;
// モデルインスタンスのセット
$obj->set_model($model);
// DBを使う設定の時にはDBハンドルを設定
if (0 === strcmp('true', $config->search('db_used'))) {
$obj->set_db_handle(db_manager::get_handle());
}
} else {
throw new custom_exception('アクションクラスインスタンスの生成不可', 1);
}
// dispatchメソッドの存在チェック
if(check::check_exist_dispatch($obj)) {
// 実行対象アクションクラスのdispatchメソッド実行
$obj->dispatch();
} else {
throw new custom_exception('アクションのdispatchメソッドの実行不可', 1);
}
}
}
?>
Author:kitoku
「奇特」を目指しているITエンジニアです。ホームページ:http://www.kitoku-magic.net/