ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilChatroomObjectDefinition.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
25 {
30  private string $moduleName;
31 
36  private string $moduleBasePath;
37 
42  private string $relativeClassPath;
43 
49  private string $guiScope;
50 
51  public function __construct(
52  string $moduleName,
53  string $moduleBasePath,
54  string $relativeClassPath = 'classes',
55  string $guiScope = ''
56  ) {
57  $this->moduleName = $moduleName;
58  $this->moduleBasePath = rtrim($moduleBasePath, '/\\');
59  $this->relativeClassPath = rtrim($relativeClassPath);
60  $this->guiScope = rtrim($guiScope);
61  }
62 
69  public static function getDefaultDefinition(string $moduleName): self
70  {
71  return new self($moduleName, 'Modules/' . $moduleName . '/');
72  }
73 
81  public static function getDefaultDefinitionWithCustomGUIPath(string $moduleName, string $guiScope = ''): self
82  {
83  return new self(
85  'Modules/' . $moduleName . '/',
86  'classes',
87  $guiScope
88  );
89  }
90 
96  public function hasGUI(string $gui): bool
97  {
98  return is_file($this->getGUIPath($gui));
99  }
100 
106  public function getGUIPath(string $gui): string
107  {
108  return (
109  $this->moduleBasePath . '/' .
110  $this->relativeClassPath . '/' .
111  $this->guiScope . 'gui/class.' . $this->getGUIClassName($gui) . '.php'
112  );
113  }
114 
120  public function getGUIClassName(string $gui): string
121  {
122  return 'il' . $this->moduleName . ucfirst($this->guiScope) . ucfirst($gui) . 'GUI';
123  }
124 
130  public function loadGUI(string $gui): void
131  {
132  require_once $this->getGUIPath($gui);
133  }
134 
141  public function buildGUI(string $gui, ilChatroomObjectGUI $chatroomObjectGUI): ilChatroomGUIHandler
142  {
143  $className = $this->getGUIClassName($gui);
144  return new $className($chatroomObjectGUI);
145  }
146 }
loadGUI(string $gui)
Requires file, whereby given $gui is used as parameter in getGUIPath method to build the filename of ...
getGUIPath(string $gui)
Builds gui path using given $gui and returns it.
static getDefaultDefinitionWithCustomGUIPath(string $moduleName, string $guiScope='')
Returns an Instance of ilChatroomObjectDefinition, using given $moduleName and $guiScope as parameter...
hasGUI(string $gui)
Returns true if file exists.
Class ilChatroomGUIHandler.
__construct(string $moduleName, string $moduleBasePath, string $relativeClassPath='classes', string $guiScope='')
static getDefaultDefinition(string $moduleName)
Returns an Instance of ilChatroomObjectDefinition, using given $moduleName as parameter.
buildGUI(string $gui, ilChatroomObjectGUI $chatroomObjectGUI)
Builds and returns new gui using given $gui and $gui.
getGUIClassName(string $gui)
Builds gui classname using given $gui and returns it.