/**
  * generate table model file
  *
  * @param string $table_name
  * @param string $table_model_class_name
  * @param string $config_key
  * @param string $out_dir
  */
 private function generateTableConfigFile($table_name, $table_model_class_name, $config_key, $out_dir)
 {
     $file_name = $config_key . ".table_model.ini";
     $lines = NULL;
     $lines[] = ";===================================================================";
     $lines[] = "; (Auto Generated File)";
     $lines[] = "; {$file_name}";
     $lines[] = "; ";
     $lines[] = "; this file is configuration file for the DB table: {$table_name}";
     $lines[] = "; ";
     $lines[] = "; generated by CharcoalPHP ver." . Charcoal_Framework::getVersion();
     $lines[] = ";===================================================================";
     $lines[] = "";
     $lines[] = "class_name    = {$table_model_class_name}";
     $outfile = new Charcoal_File($file_name, $out_dir);
     Charcoal_FileSystemUtil::outputFile($outfile, $lines);
     print "{$outfile} was successfully generated." . PHP_EOL;
 }
 /**
  * イベントを処理する
  */
 public function processEvent($context)
 {
     $event = $context->getEvent();
     // パラメータを取得
     $module_path = $event->getModulePath();
     $app_name = $event->getAppName();
     $project_name = $event->getProjectName();
     $out_dir = $event->getTargetDir();
     //=======================================
     // Confirm input parameters
     //=======================================
     if (!preg_match('/^[@:0-9a-zA-Z_\\-]*$/', $module_path)) {
         _throw(new Charcoal_InvalidArgumentException($module_path));
     }
     if (!preg_match('/^[0-9a-zA-Z_\\-]*$/', $app_name)) {
         _throw(new Charcoal_InvalidArgumentException($app_name));
     }
     if (!preg_match('/^[0-9a-zA-Z_\\-]*$/', $project_name)) {
         _throw(new Charcoal_InvalidArgumentException($project_name));
     }
     //=======================================
     // Make output directory
     //=======================================
     $out_dir = new Charcoal_File($out_dir);
     $out_dir->makeDirectory(self::DIR_MODE);
     //=======================================
     // Make web_app directory
     //=======================================
     $webapp_dir = new Charcoal_File('web_app', $out_dir);
     $webapp_dir->makeDirectory(self::DIR_MODE);
     //=======================================
     // Make project directory
     //=======================================
     $project_dir = new Charcoal_File($project_name, $webapp_dir);
     $project_dir->makeDirectory(self::DIR_MODE);
     //=======================================
     // Make project/app directory
     //=======================================
     $project_app_dir = new Charcoal_File('app', $project_dir);
     $project_app_dir->makeDirectory(self::DIR_MODE);
     //=======================================
     // Make application directory
     //=======================================
     $application_dir = new Charcoal_File($app_name, $project_app_dir);
     $application_dir->makeDirectory(self::DIR_MODE);
     //=======================================
     // Make application/module directory
     //=======================================
     $module_dir = new Charcoal_File('module', $application_dir);
     $module_dir->makeDirectory(self::DIR_MODE);
     //=======================================
     // Make target module directory
     //=======================================
     $module_path = new Charcoal_ObjectPath($module_path);
     $target_module_dir = new Charcoal_File($module_path->getRealPath(), $module_dir);
     $target_module_dir->makeDirectory(self::DIR_MODE);
     //=======================================
     // Make procedure.ini file
     //=======================================
     $lines = NULL;
     $lines[] = "debug_mode        = false";
     $lines[] = "class_name        = Charcoal_SimpleProcedure";
     $lines[] = "task_manager      = default_task_manager";
     $lines[] = "tasks             = ";
     $lines[] = "modules           = ";
     $lines[] = "events            = ";
     $lines[] = "log_enabled       = yes";
     $lines[] = "log_level         = E";
     $lines[] = "log_loggers       = error";
     $outfile = new Charcoal_File('procedure.ini', $target_module_dir);
     Charcoal_FileSystemUtil::outputFile($outfile, $lines);
     echo "Module[{$module_path}] created at: " . $target_module_dir->getAbsolutePath() . PHP_EOL;
     return b(true);
 }
 /**
  * イベントを処理する
  */
 public function processEvent($context)
 {
     $event = $context->getEvent();
     // パラメータを取得
     $task_name = $event->getTaskName();
     $module_path = $event->getModulePath();
     $app_name = $event->getAppName();
     $project_name = $event->getProjectName();
     $out_dir = $event->getTargetDir();
     //=======================================
     // Confirm input parameters
     //=======================================
     if (!preg_match('/^[0-9a-zA-Z_\\-]*$/', $task_name)) {
         _throw(new Charcoal_InvalidArgumentException($task_name));
     }
     if (!preg_match('/^[@:0-9a-zA-Z_\\-]*$/', $module_path)) {
         _throw(new Charcoal_InvalidArgumentException($module_path));
     }
     if (!preg_match('/^[0-9a-zA-Z_\\-]*$/', $app_name)) {
         _throw(new Charcoal_InvalidArgumentException($app_name));
     }
     if (!preg_match('/^[0-9a-zA-Z_\\-]*$/', $project_name)) {
         _throw(new Charcoal_InvalidArgumentException($project_name));
     }
     //=======================================
     // Make output directory
     //=======================================
     $out_dir = new Charcoal_File($out_dir);
     $out_dir->makeDirectory(self::DIR_MODE);
     //=======================================
     // Make web_app directory
     //=======================================
     $webapp_dir = new Charcoal_File('web_app', $out_dir);
     $webapp_dir->makeDirectory(self::DIR_MODE);
     //=======================================
     // Make project directory
     //=======================================
     $project_dir = new Charcoal_File($project_name, $webapp_dir);
     $project_dir->makeDirectory(self::DIR_MODE);
     //=======================================
     // Make project/app directory
     //=======================================
     $project_app_dir = new Charcoal_File('app', $project_dir);
     $project_app_dir->makeDirectory(self::DIR_MODE);
     //=======================================
     // Make application directory
     //=======================================
     $application_dir = new Charcoal_File($app_name, $project_app_dir);
     $application_dir->makeDirectory(self::DIR_MODE);
     //=======================================
     // Make application/module directory
     //=======================================
     $module_dir = new Charcoal_File('module', $application_dir);
     $module_dir->makeDirectory(self::DIR_MODE);
     //=======================================
     // Make target module directory
     //=======================================
     $module_path = new Charcoal_ObjectPath($module_path);
     $target_module_dir = new Charcoal_File($module_path->getRealPath(), $module_dir);
     $target_module_dir->makeDirectory(self::DIR_MODE);
     //=======================================
     // Make task.ini file
     //=======================================
     $task_class_name = str_replace(' ', '', ucwords(str_replace('_', ' ', $task_name))) . 'Task';
     $lines = NULL;
     $lines[] = "class_name        = {$task_class_name}";
     $lines[] = "event_filters     = ";
     $outfile = new Charcoal_File($task_name . '_task.task.ini', $target_module_dir);
     Charcoal_FileSystemUtil::outputFile($outfile, $lines);
     //=======================================
     // Make task class file
     //=======================================
     $lines = NULL;
     $lines[] = "<?php";
     $lines[] = "/**";
     $lines[] = " *   (Auto Generated Class)";
     $lines[] = " *   {$task_class_name} class";
     $lines[] = " *   ";
     $lines[] = " *   generated by CharcoalPHP ver." . Charcoal_Framework::getVersion();
     $lines[] = " *   ";
     $lines[] = " *   @author     your name";
     $lines[] = " *   @copyright  ";
     $lines[] = " */";
     $lines[] = "class {$task_class_name} extends Charcoal_Task";
     $lines[] = "{";
     $lines[] = "    /**";
     $lines[] = "     * Process user/system event";
     $lines[] = "     *";
     $lines[] = "     * @param Charcoal_EventContext \$context       Event context";
     $lines[] = "     * ";
     $lines[] = "     * @return bool|Charcoal_Boolean       Return true if the event is processed. Or you can ";
     $lines[] = "     *        return false if another task should process the event.";
     $lines[] = "     */";
     $lines[] = "    public function processEvent( \$context )";
     $lines[] = "    {";
     $lines[] = "        \$request   = \$context->getRequest();";
     $lines[] = "        \$response  = \$context->getResponse();";
     $lines[] = "        \$sequence  = \$context->getSequence();";
     $lines[] = "        \$procedure = \$context->getProcedure();";
     $lines[] = "        ";
     $lines[] = "        // TODO: write processing event code here";
     $lines[] = "        \$name = \$request->getString('name', 'john');";
     $lines[] = "        ";
     $lines[] = "        return b(true);";
     $lines[] = "    }";
     $lines[] = "}";
     $outfile = new Charcoal_File($task_class_name . '.class.php', $target_module_dir);
     Charcoal_FileSystemUtil::outputFile($outfile, $lines);
     echo "Task[{$task_name}] created at: " . $target_module_dir->getAbsolutePath() . PHP_EOL;
     return b(true);
 }