ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f87
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 }
hasTask($task)
Returns true if file exists.
__construct($moduleName, $moduleBasePath, $relativeClassPath='classes', $relativeTaskPath='tasks')
Sets class parameters using given parameters.
buildTask($task, ilChatroomObjectGUI $gui)
Builds and returns new task using given $task and $gui.
static getDefaultDefinition($moduleName)
Returns an Instance of ilChatroomObjectDefinition, using given $moduleName as parameter.
static getDefaultDefinitionWithCustomTaskPath($moduleName, $relativeTaskFolder)
Returns an Instance of ilChatroomObjectDefinition, using given $moduleName and $relativeTaskFolder as...
getTaskClassName($task)
Builds task classname using given $task and returns it.
getTaskPath($task)
Builds task path using given $task and returns it.
loadTask($task)
Requires file, whereby given $task is used as parameter in getTaskPath method to build the filename o...