ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilDBayObjectDefinition.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * To change this template, choose Tools | Templates
5  * and open the template in the editor.
6  */
7 
14 {
15 
16  private $moduleName;
17  private $moduleBasePath;
20 
30  {
31  $this->moduleName = $moduleName;
32  $this->moduleBasePath = rtrim( $moduleBasePath, '/\\' );
33  $this->relativeClassPath = rtrim( $relativeClassPath );
34  $this->relativeTaskPath = rtrim( $relativeTaskPath );
35  }
36 
44  public static function getDefaultDefinition($moduleName)
45  {
46  $object = new self( $moduleName, 'Modules/' . $moduleName . '/' );
47 
48  return $object;
49  }
50 
59  public static function getDefaultDefinitionWithCustomTaskPath($moduleName, $relativeTaskFolder)
60  {
61  $object = new self(
62  $moduleName, 'Modules/' . $moduleName . '/', 'classes', $relativeTaskFolder
63  );
64 
65  return $object;
66  }
67 
74  public function hasTask($task)
75  {
76  return file_exists( $this->getTaskPath( $task ) );
77  }
78 
85  public function loadTask($task)
86  {
87  require_once $this->getTaskPath( $task );
88  }
89 
90 
98  public function buildTask($task, ilDBayObjectGUI $gui)
99  {
100  $className = $this->getTaskClassName( $task );
101  $task = new $className( $gui );
102 
103  return $task;
104  }
105 
112  public function getTaskClassName($task)
113  {
114  return 'il' . $this->moduleName . ucfirst( $task ) . 'Task';
115  }
116 
123  public function getTaskPath($task)
124  {
125  return $this->moduleBasePath . '/' . $this->relativeClassPath . '/' .
126  $this->relativeTaskPath . '/class.' . $this->getTaskClassName( $task ) . '.php';
127  }
128 
129 }
130 
131 ?>