ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilChatroomObjectDefinition.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
8 {
12  private $moduleName;
13 
17  private $moduleBasePath;
18 
23 
28 
37  {
38  $this->moduleName = $moduleName;
39  $this->moduleBasePath = rtrim($moduleBasePath, '/\\');
40  $this->relativeClassPath = rtrim($relativeClassPath);
41  $this->relativeTaskPath = rtrim($relativeTaskPath);
42  }
43 
50  public static function getDefaultDefinition($moduleName)
51  {
52  $object = new self($moduleName, 'Modules/' . $moduleName . '/');
53 
54  return $object;
55  }
56 
64  public static function getDefaultDefinitionWithCustomTaskPath($moduleName, $relativeTaskFolder)
65  {
66  $object = new self(
67  $moduleName, 'Modules/' . $moduleName . '/', 'classes', $relativeTaskFolder
68  );
69 
70  return $object;
71  }
72 
78  public function hasTask($task)
79  {
80  return file_exists($this->getTaskPath($task));
81  }
82 
88  public function loadTask($task)
89  {
90  require_once $this->getTaskPath($task);
91  }
92 
93 
100  public function buildTask($task, ilChatroomObjectGUI $gui)
101  {
102  $className = $this->getTaskClassName($task);
103  $task = new $className($gui);
104 
105  return $task;
106  }
107 
113  public function getTaskClassName($task)
114  {
115  return 'il' . $this->moduleName . ucfirst($task) . 'Task';
116  }
117 
123  public function getTaskPath($task)
124  {
125  return $this->moduleBasePath . '/' . $this->relativeClassPath . '/' .
126  $this->relativeTaskPath . '/class.' . $this->getTaskClassName($task) . '.php';
127  }
128 }