ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 {
13  private $moduleName;
14 
19  private $moduleBasePath;
20 
26 
32  private $taskScope;
33 
42  {
43  $this->moduleName = $moduleName;
44  $this->moduleBasePath = rtrim($moduleBasePath, '/\\');
45  $this->relativeClassPath = rtrim($relativeClassPath);
46  $this->taskScope = rtrim($taskScope);
47  }
48 
55  public static function getDefaultDefinition($moduleName)
56  {
57  $object = new self($moduleName, 'Modules/' . $moduleName . '/');
58 
59  return $object;
60  }
61 
70  {
71  $object = new self(
72  $moduleName, 'Modules/' . $moduleName . '/', 'classes', $taskScope
73  );
74 
75  return $object;
76  }
77 
83  public function hasTask($task)
84  {
85  return file_exists($this->getTaskPath($task));
86  }
87 
93  public function loadTask($task)
94  {
95  require_once $this->getTaskPath($task);
96  }
97 
98 
105  public function buildTask($task, ilChatroomObjectGUI $gui)
106  {
107  $className = $this->getTaskClassName($task);
108  $task = new $className($gui);
109 
110  return $task;
111  }
112 
118  public function getTaskClassName($task)
119  {
120  return 'il' . $this->moduleName . ucfirst($this->taskScope) . ucfirst($task) . 'Task';
121  }
122 
128  public function getTaskPath($task)
129  {
130  return $this->moduleBasePath . '/' . $this->relativeClassPath . '/' .
131  $this->taskScope . 'tasks/class.' . $this->getTaskClassName($task) . '.php';
132  }
133 }
__construct($moduleName, $moduleBasePath, $relativeClassPath='classes', $taskScope='')
Sets class parameters using given parameters.
hasTask($task)
Returns true if file exists.
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, $taskScope='')
Returns an Instance of ilChatroomObjectDefinition, using given $moduleName and $taskScope as paramete...
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...
$task
GENERAL INFORMATION: