16 private static $workspaces =
null;
17 private static $availableComponents =
null;
19 private static function getWorkspaces(): array
21 if (self::$workspaces ==
null)
23 self::$workspaces = [];
25 foreach ($events as $event)
27 $path = ExecuteModuleEventEx($event);
28 if (!in_array($path, self::$workspaces))
30 self::$workspaces[] = $path;
35 return self::$workspaces;
42 private static function fetchComponents(): ?array
44 if (self::$availableComponents ==
null)
46 self::$availableComponents = [];
47 $rawComponentList = [];
48 $workspaces = self::getWorkspaces();
49 foreach ($workspaces as $path)
52 if (!$componentDir->isExists())
57 $namespaces = $componentDir->getChildren();
58 foreach ($namespaces as $NSDir)
60 if (!$NSDir->isDirectory())
65 $namespaceItems = $NSDir->getChildren();
66 $namespace = $NSDir->getName();
67 foreach ($namespaceItems as $item)
71 $component =
new Component($item->getPath(), $namespace);
72 $name = $item->getName();
73 $name = ($namespace ==
'bitrix' ? $name : $namespace .
':' . $name);
74 $rawComponentList[$name] = $component;
75 }
catch (Exception $e)
83 self::$availableComponents = $rawComponentList;
87 return self::$availableComponents;
97 $extensionPath =
null;
98 $workspaces = self::getWorkspaces();
99 foreach ($workspaces as $path)
102 if ($extensionDir->isExists())
104 $extensionPath = $extensionDir->getPath();
108 return $extensionPath;
113 $extList = is_array($ext) ? $ext : [$ext];
116 $alreadyResolved = [];
118 foreach ($extList as $ext)
133 foreach ($extensions as $extName)
136 $result[
'messages'] = array_merge($result[
'messages'], $extension->getLangMessages());
137 $result[
'js'][] = $extension->getRelativePathToFile();
153 return $component->getVersion();
169 return $component->getPublicPath();
181 return self::fetchComponents();
190 $name = str_replace(
"bitrix:",
"", $name);
191 $components = self::fetchComponents();
192 if (array_key_exists($name, $components)) {
193 return $components[$name];