ILIAS  trunk Revision v11.0_alpha-1723-g8e69f309bab
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilComponentBuildPluginInfoObjective Class Reference
+ Inheritance diagram for ilComponentBuildPluginInfoObjective:
+ Collaboration diagram for ilComponentBuildPluginInfoObjective:

Public Member Functions

 getArtifactName ()
 
 build ()
 

Protected Member Functions

 addPlugin (array &$data, string $type, string $component, string $slot, string $plugin)
 
 scanDir (string $dir)
 
 fileExists (string $path)
 
 isDir (string $dir)
 
 isDotFile (string $file)
 
 buildPluginPath (string $type, string $component, string $slot, string $plugin)
 

Protected Attributes

const BASE_PATH = "./public/Customizing/global/plugins/"
 
const PLUGIN_PHP = "plugin.php"
 
const PLUGIN_CLASS_FILE = "classes/class.il%sPlugin.php"
 

Detailed Description

Member Function Documentation

◆ addPlugin()

ilComponentBuildPluginInfoObjective::addPlugin ( array &  $data,
string  $type,
string  $component,
string  $slot,
string  $plugin 
)
protected

Definition at line 67 of file class.ilComponentBuildPluginInfoObjective.php.

References $id, $ilias_max_version, $ilias_min_version, $learning_progress, XapiProxy\$plugin, $responsible, $responsible_mail, $supports_export, $version, buildPluginPath(), fileExists(), and null.

Referenced by build().

67  : void
68  {
69  $plugin_path = $this->buildPluginPath($type, $component, $slot, $plugin);
70  $plugin_php = $plugin_path . static::PLUGIN_PHP;
71  if (!$this->fileExists($plugin_php)) {
72  throw new \RuntimeException(
73  "Cannot read $plugin_php."
74  );
75  }
76 
77  $plugin_class = $plugin_path . sprintf(static::PLUGIN_CLASS_FILE, $plugin);
78  if (!$this->fileExists($plugin_class)) {
79  throw new \RuntimeException(
80  "Cannot read $plugin_class."
81  );
82  }
83 
84  require_once($plugin_php);
85  if (!isset($id)) {
86  throw new \InvalidArgumentException("$plugin does not define \$id");
87  }
88  if (!isset($version)) {
89  throw new \InvalidArgumentException("$plugin does not define \$version");
90  }
91  if (!isset($ilias_min_version)) {
92  throw new \InvalidArgumentException("$plugin does not define \$ilias_min_version");
93  }
94  if (!isset($ilias_max_version)) {
95  throw new \InvalidArgumentException("$plugin does not define \$ilias_max_version");
96  }
97 
98  if (isset($data[$id])) {
99  throw new \RuntimeException(
100  "Plugin with id $id already exists."
101  );
102  }
103 
104  $data[$id] = [
105  $type,
106  $component,
107  $slot,
108  $plugin,
109  $version,
112  $responsible ?? "",
113  $responsible_mail ?? "",
116  $supports_cli_setup ?? null
117  ];
118  }
$supports_export
Definition: plugin.php:30
$responsible_mail
Definition: plugin.php:28
$version
Definition: plugin.php:24
$ilias_max_version
Definition: plugin.php:26
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
$ilias_min_version
Definition: plugin.php:25
$learning_progress
Definition: plugin.php:29
buildPluginPath(string $type, string $component, string $slot, string $plugin)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
$responsible
Definition: plugin.php:27
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ build()

ilComponentBuildPluginInfoObjective::build ( )

Definition at line 33 of file class.ilComponentBuildPluginInfoObjective.php.

References $components, $data, XapiProxy\$plugin, addPlugin(), isDir(), isDotFile(), and scanDir().

33  : Setup\Artifact
34  {
35  $data = [];
36  foreach (['Modules', 'Services'] as $type) {
37  $base_path = static::BASE_PATH . $type . '/';
38  if (! $this->isDir($base_path)) {
39  continue;
40  }
41  $components = $this->scanDir($base_path);
42  foreach ($components as $component) {
43  if ($this->isDotFile($component)
44  || ! $this->isDir($base_path . "$component")) {
45  continue;
46  }
47  $slots = $this->scanDir($base_path . "$component");
48  foreach ($slots as $slot) {
49  if ($this->isDotFile($slot)
50  || ! $this->isDir($base_path . "$component/$slot")) {
51  continue;
52  }
53  $plugins = $this->scanDir($base_path . "$component/$slot");
54  foreach ($plugins as $plugin) {
55  if ($this->isDotFile($plugin)
56  || ! $this->isDir($base_path . "$component/$slot/$plugin")) {
57  continue;
58  }
59  $this->addPlugin($data, $type, $component, $slot, $plugin);
60  }
61  }
62  }
63  }
64  return new Setup\Artifact\ArrayArtifact($data);
65  }
$components
addPlugin(array &$data, string $type, string $component, string $slot, string $plugin)
+ Here is the call graph for this function:

◆ buildPluginPath()

ilComponentBuildPluginInfoObjective::buildPluginPath ( string  $type,
string  $component,
string  $slot,
string  $plugin 
)
protected

Definition at line 147 of file class.ilComponentBuildPluginInfoObjective.php.

Referenced by addPlugin().

147  : string
148  {
149  return static::BASE_PATH . "$type/$component/$slot/$plugin/";
150  }
+ Here is the caller graph for this function:

◆ fileExists()

ilComponentBuildPluginInfoObjective::fileExists ( string  $path)
protected

Definition at line 132 of file class.ilComponentBuildPluginInfoObjective.php.

Referenced by addPlugin().

132  : bool
133  {
134  return file_exists($path) && is_file($path);
135  }
$path
Definition: ltiservices.php:29
+ Here is the caller graph for this function:

◆ getArtifactName()

ilComponentBuildPluginInfoObjective::getArtifactName ( )

Definition at line 28 of file class.ilComponentBuildPluginInfoObjective.php.

28  : string
29  {
30  return "plugin_data";
31  }

◆ isDir()

ilComponentBuildPluginInfoObjective::isDir ( string  $dir)
protected

Definition at line 137 of file class.ilComponentBuildPluginInfoObjective.php.

Referenced by build().

137  : bool
138  {
139  return file_exists($dir) && is_dir($dir);
140  }
+ Here is the caller graph for this function:

◆ isDotFile()

ilComponentBuildPluginInfoObjective::isDotFile ( string  $file)
protected

Definition at line 142 of file class.ilComponentBuildPluginInfoObjective.php.

Referenced by build().

142  : bool
143  {
144  return (substr($file, 0, 1) === '.');
145  }
+ Here is the caller graph for this function:

◆ scanDir()

ilComponentBuildPluginInfoObjective::scanDir ( string  $dir)
protected
Returns
string[]

Definition at line 123 of file class.ilComponentBuildPluginInfoObjective.php.

Referenced by build().

123  : array
124  {
125  if (!file_exists($dir)) {
126  return [];
127  }
128  $result = scandir($dir);
129  return array_values(array_diff($result, [".", ".."]));
130  }
+ Here is the caller graph for this function:

Field Documentation

◆ BASE_PATH

const ilComponentBuildPluginInfoObjective::BASE_PATH = "./public/Customizing/global/plugins/"
protected

◆ PLUGIN_CLASS_FILE

const ilComponentBuildPluginInfoObjective::PLUGIN_CLASS_FILE = "classes/class.il%sPlugin.php"
protected

◆ PLUGIN_PHP

const ilComponentBuildPluginInfoObjective::PLUGIN_PHP = "plugin.php"
protected

The documentation for this class was generated from the following file: