예제 #1
0
 /**
  * load a rask
  *
  * @param Charcoal_ObjectPath $obj_path
  * @param Charcoal_String|string $path
  * @param Charcoal_ITaskManager $task_manager
  *
  * @return Charcoal_ITask|NULL
  */
 private function loadTask($obj_path, $path, $task_manager)
 {
     //        Charcoal_ParamTrait::validateObjectPath( 1, $obj_path );
     //        Charcoal_ParamTrait::validateString( 2, $path );
     //        Charcoal_ParamTrait::validateImplements( 3, 'Charcoal_ITaskManager', $task_manager );
     // file base name
     $base_name = basename($path);
     // retrieve class name from file name
     $pos = strpos($base_name, '.class.php');
     $class_name = substr($base_name, 0, $pos);
     // include source file
     Charcoal_Framework::loadSourceFile($path);
     // create new instance
     $klass = new Charcoal_Class($class_name);
     $task = $klass->newInstance();
     // check if th object implements Charcoal_Task interface
     if (!$task instanceof Charcoal_Task) {
         // Invoke Exception
         _throw(new Charcoal_InterfaceImplementException($task, 'Charcoal_Task'));
     }
     log_info('system, event, debug', "created task[{$task}] in module[{$obj_path}]");
     // build object path for the task
     $obj_name = $task->getObjectName();
     $task_path = s($obj_name . '@' . $obj_path->getVirtualPath());
     // set task property
     $task->setObjectPath($task_path);
     $task->setTypeName('task');
     $task->setSandbox($this->getSandbox());
     // load object config
     $config = Charcoal_ConfigLoader::loadConfig($this->getSandbox(), $task_path, 'task');
     $config = new Charcoal_Config($this->getSandbox()->getEnvironment(), $config);
     // configure task
     $task->configure($config);
     //        log_info( 'system, event, debug', "task[$task] configured.");
     // regiser task
     $task_manager->registerTask($task_path, $task);
     log_info('system, event, debug', "task[{$class_name}] registered as: [{$task_path}]");
     return $task;
 }
예제 #2
0
 /**
  *  returns event queue
  *
  * @return Charcoal_IEventQueue
  */
 public function getEventQueue()
 {
     return $this->task_manager->getEventQueue();
 }