ILIAS  release_8 Revision v8.19-1-g4e8f2f9140c
All Data Structures Namespaces Files Functions Variables Modules Pages
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 57 of file class.ilComponentBuildPluginInfoObjective.php.

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

Referenced by build().

57  : void
58  {
59  $plugin_path = $this->buildPluginPath($type, $component, $slot, $plugin);
60  $plugin_php = $plugin_path . static::PLUGIN_PHP;
61  if (!$this->fileExists($plugin_php)) {
62  throw new \RuntimeException(
63  "Cannot read $plugin_php."
64  );
65  }
66 
67  $plugin_class = $plugin_path . sprintf(static::PLUGIN_CLASS_FILE, $plugin);
68  if (!$this->fileExists($plugin_class)) {
69  throw new \RuntimeException(
70  "Cannot read $plugin_class."
71  );
72  }
73 
74  require_once($plugin_php);
75  if (!isset($id)) {
76  throw new \InvalidArgumentException("$path does not define \$id");
77  }
78  if (!isset($version)) {
79  throw new \InvalidArgumentException("$path does not define \$version");
80  }
81  if (!isset($ilias_min_version)) {
82  throw new \InvalidArgumentException("$path does not define \$ilias_min_version");
83  }
84  if (!isset($ilias_max_version)) {
85  throw new \InvalidArgumentException("$path does not define \$ilias_max_version");
86  }
87 
88  if (isset($data[$id])) {
89  throw new \RuntimeException(
90  "Plugin with id $id already exists."
91  );
92  }
93 
94  $data[$id] = [
95  $type,
96  $component,
97  $slot,
98  $plugin,
99  $version,
102  $responsible ?? "",
103  $responsible_mail ?? "",
104  $learning_progress ?? null,
105  $supports_export ?? null,
106  $supports_cli_setup ?? null
107  ];
108  }
$type
$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 33 of file class.ilComponentBuildPluginInfoObjective.php.

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

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

Referenced by addPlugin().

137  : string
138  {
139  return static::BASE_PATH . "$type/$component/$slot/$plugin/";
140  }
+ Here is the caller graph for this function:

◆ fileExists()

ilComponentBuildPluginInfoObjective::fileExists ( string  $path)
protected

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

Referenced by addPlugin().

122  : bool
123  {
124  return file_exists($path) && is_file($path);
125  }
$path
Definition: ltiservices.php:32
+ Here is the caller graph for this function:

◆ getArtifactPath()

ilComponentBuildPluginInfoObjective::getArtifactPath ( )

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

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

◆ isDir()

ilComponentBuildPluginInfoObjective::isDir ( string  $dir)
protected

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

Referenced by build().

127  : bool
128  {
129  return file_exists($dir) && is_dir($dir);
130  }
+ Here is the caller graph for this function:

◆ isDotFile()

ilComponentBuildPluginInfoObjective::isDotFile ( string  $file)
protected

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

Referenced by build().

132  : bool
133  {
134  return ( substr($file, 0, 1) === '.' );
135  }
+ Here is the caller graph for this function:

◆ scanDir()

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

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

Referenced by build().

113  : array
114  {
115  if (!file_exists($dir)) {
116  return [];
117  }
118  $result = scandir($dir);
119  return array_values(array_diff($result, [".", ".."]));
120  }
+ 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: