ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilComponentBuildPluginInfoObjective Class Reference
+ Inheritance diagram for ilComponentBuildPluginInfoObjective:
+ Collaboration diagram for ilComponentBuildPluginInfoObjective:

Public Member Functions

 getArtifactPath ()
 
 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 = "./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 64 of file class.ilComponentBuildPluginInfoObjective.php.

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

Referenced by build().

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

◆ build()

ilComponentBuildPluginInfoObjective::build ( )

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

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

34  : Setup\Artifact
35  {
36  $data = [];
37  foreach (["Modules", "Services"] as $type) {
38  $components = $this->scanDir(static::BASE_PATH . $type);
39  foreach ($components as $component) {
40  if ($this->isDotFile($component)
41  || ! $this->isDir(static::BASE_PATH . "$type/$component")) {
42  continue;
43  }
44  $slots = $this->scanDir(static::BASE_PATH . "$type/$component");
45  foreach ($slots as $slot) {
46  if ($this->isDotFile($slot)
47  || ! $this->isDir(static::BASE_PATH . "$type/$component/$slot")) {
48  continue;
49  }
50  $plugins = $this->scanDir(static::BASE_PATH . "$type/$component/$slot");
51  foreach ($plugins as $plugin) {
52  if ($this->isDotFile($plugin)
53  || ! $this->isDir(static::BASE_PATH . "$type/$component/$slot/$plugin")) {
54  continue;
55  }
56  $this->addPlugin($data, $type, $component, $slot, $plugin);
57  }
58  }
59  }
60  }
61  return new Setup\Artifact\ArrayArtifact($data);
62  }
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 144 of file class.ilComponentBuildPluginInfoObjective.php.

Referenced by addPlugin().

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

◆ fileExists()

ilComponentBuildPluginInfoObjective::fileExists ( string  $path)
protected

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

Referenced by addPlugin().

129  : bool
130  {
131  return file_exists($path) && is_file($path);
132  }
$path
Definition: ltiservices.php:32
+ Here is the caller graph for this function:

◆ getArtifactPath()

ilComponentBuildPluginInfoObjective::getArtifactPath ( )

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

28  : string
29  {
30  return \ilArtifactComponentRepository::PLUGIN_DATA_PATH;
31  }

◆ isDir()

ilComponentBuildPluginInfoObjective::isDir ( string  $dir)
protected

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

Referenced by build().

134  : bool
135  {
136  return file_exists($dir) && is_dir($dir);
137  }
+ Here is the caller graph for this function:

◆ isDotFile()

ilComponentBuildPluginInfoObjective::isDotFile ( string  $file)
protected

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

Referenced by build().

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

◆ scanDir()

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

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

Referenced by build().

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

Field Documentation

◆ BASE_PATH

const ilComponentBuildPluginInfoObjective::BASE_PATH = "./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: