Rev 318 | Rev 321 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 318 | Rev 320 | ||
---|---|---|---|
Line 436... | Line 436... | ||
436 | return self::$disabledObjectTypes; |
436 | return self::$disabledObjectTypes; |
437 | } |
437 | } |
438 | 438 | ||
439 | # --- Plugin handling functions |
439 | # --- Plugin handling functions |
440 | 440 | ||
- | 441 | public static function getAllPlugins()/*: array*/ { |
|
- | 442 | $res = array(); |
|
- | 443 | $res = array_merge($res, self::$pagePlugins); |
|
- | 444 | $res = array_merge($res, self::$authPlugins); |
|
- | 445 | $res = array_merge($res, self::$loggerPlugins); |
|
- | 446 | $res = array_merge($res, self::$objectTypePlugins); |
|
- | 447 | $res = array_merge($res, self::$dbPlugins); |
|
- | 448 | $res = array_merge($res, self::$sqlSlangPlugins); |
|
- | 449 | return $res; |
|
- | 450 | } |
|
- | 451 | ||
- | 452 | public static function getPluginByOid($oid, $pluginFolderMask='*')/*: ?OIDplusPlugin*/ { |
|
- | 453 | $manifests = self::getAllPluginManifests($pluginFolderMask, true); |
|
- | 454 | $plugins = self::getAllPlugins(); |
|
- | 455 | foreach ($manifests as $manifest) { |
|
- | 456 | if (oid_dotnotation_equal($manifest->getOid(), $oid)) { |
|
- | 457 | foreach ($plugins as $plugin) { |
|
- | 458 | if (get_class($plugin) == $manifest->getPhpMainClass()) return $plugin; |
|
- | 459 | } |
|
- | 460 | } |
|
- | 461 | } |
|
- | 462 | return null; |
|
- | 463 | } |
|
- | 464 | ||
441 | public static function getPluginManifest($class_name)/*: ?OIDplusPluginManifest*/ { |
465 | public static function getPluginManifest($class_name)/*: ?OIDplusPluginManifest*/ { |
442 | $reflector = new ReflectionClass($class_name); |
466 | $reflector = new ReflectionClass($class_name); |
443 | $ini = dirname($reflector->getFileName()).'/manifest.xml'; |
467 | $ini = dirname($reflector->getFileName()).'/manifest.xml'; |
444 | $manifest = new OIDplusPluginManifest(); |
468 | $manifest = new OIDplusPluginManifest(); |
445 | return $manifest->loadManifest($ini) ? $manifest : null; |
469 | return $manifest->loadManifest($ini) ? $manifest : null; |
Line 471... | Line 495... | ||
471 | } |
495 | } |
472 | 496 | ||
473 | public static function registerAllPlugins($pluginDirName, $expectedPluginClass, $registerCallback): array { |
497 | public static function registerAllPlugins($pluginDirName, $expectedPluginClass, $registerCallback): array { |
474 | $out = array(); |
498 | $out = array(); |
475 | $ary = self::getAllPluginManifests($pluginDirName, false); |
499 | $ary = self::getAllPluginManifests($pluginDirName, false); |
- | 500 | $known_plugin_oids = array(); |
|
476 | foreach ($ary as $plugintype_folder => $bry) { |
501 | foreach ($ary as $plugintype_folder => $bry) { |
477 | foreach ($bry as $pluginname_folder => $cry) { |
502 | foreach ($bry as $pluginname_folder => $cry) { |
478 | $class_name = $cry->getPhpMainClass(); |
503 | $class_name = $cry->getPhpMainClass(); |
479 | if (!$class_name) { |
504 | if (!$class_name) { |
480 | throw new OIDplusException("Plugin '$plugintype_folder/$pluginname_folder' is errornous: Manifest does not declare a PHP main class"); |
505 | throw new OIDplusException("Plugin '$plugintype_folder/$pluginname_folder' is errornous: Manifest does not declare a PHP main class"); |
Line 493... | Line 518... | ||
493 | } |
518 | } |
494 | if (($cry->getTypeClass()!=$expectedPluginClass) && (!is_subclass_of($cry->getTypeClass(),$expectedPluginClass))) { |
519 | if (($cry->getTypeClass()!=$expectedPluginClass) && (!is_subclass_of($cry->getTypeClass(),$expectedPluginClass))) { |
495 | throw new OIDplusException("Plugin '$plugintype_folder/$pluginname_folder' is errornous: Class declared in manifest is '".$cry->getTypeClasS()."' does not fit expected class for this plugin type '$expectedPluginClass'"); |
520 | throw new OIDplusException("Plugin '$plugintype_folder/$pluginname_folder' is errornous: Class declared in manifest is '".$cry->getTypeClasS()."' does not fit expected class for this plugin type '$expectedPluginClass'"); |
496 | } |
521 | } |
497 | 522 | ||
- | 523 | $plugin_oid = $cry->getOid(); |
|
- | 524 | if (!$plugin_oid) { |
|
- | 525 | throw new OIDplusException("Plugin '$plugintype_folder/$pluginname_folder' is errornous: Does not have an OID"); |
|
- | 526 | } |
|
- | 527 | if (!oid_valid_dotnotation($plugin_oid, false, false, 2)) { |
|
- | 528 | throw new OIDplusException("Plugin '$plugintype_folder/$pluginname_folder' is errornous: Plugin OID '$plugin_oid' is invalid (needs to be valid dot-notation)"); |
|
- | 529 | } |
|
- | 530 | if (isset($known_plugin_oids[$plugin_oid])) { |
|
- | 531 | throw new OIDplusException("Plugin '$plugintype_folder/$pluginname_folder' is errornous: The OID '$plugin_oid' is already used by the plugin '".$known_plugin_oids[$plugin_oid]."'"); |
|
- | 532 | } else { |
|
- | 533 | $known_plugin_oids[$plugin_oid] = $plugintype_folder.'/'.$pluginname_folder; |
|
- | 534 | } |
|
- | 535 | ||
498 | $out[] = $class_name; |
536 | $out[] = $class_name; |
499 | if (!is_null($registerCallback)) { |
537 | if (!is_null($registerCallback)) { |
500 | call_user_func($registerCallback, new $class_name()); |
538 | call_user_func($registerCallback, new $class_name()); |
501 | } |
539 | } |
502 | } |
540 | } |