ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilObjectPlugin.php
Go to the documentation of this file.
1<?php
2
24abstract class ilObjectPlugin extends ilObject2
25{
26 protected ?ilPlugin $plugin = null;
28
29 public function __construct(int $a_ref_id = 0)
30 {
31 global $DIC;
32 $this->component_factory = $DIC["component.factory"];
33 $this->initType();
34 parent::__construct($a_ref_id, true);
35 $this->plugin = $this->getPlugin();
36 }
37
38
43 public static function getPluginObjectByType(string $type): ?ilPlugin
44 {
45 global $DIC;
46 $component_factory = $DIC["component.factory"];
47 try {
49 } catch (InvalidArgumentException $e) {
50 ilLoggerFactory::getLogger("obj")->log("There was an error while instantiating repo plugin obj of type: $type. Error: $e");
51 }
52 return null;
53 }
54
55 public static function lookupTxtById(
56 string $plugin_id,
57 string $lang_var
58 ): string {
59 $pl = self::getPluginObjectByType($plugin_id);
60 return $pl->txt($lang_var);
61 }
62
67 protected function getPlugin(): ilPlugin
68 {
69 if (!$this->plugin) {
70 $this->plugin = $this->component_factory->getPlugin($this->getType());
71 }
72 return $this->plugin;
73 }
74
75 final public function txt(string $a_var): string
76 {
77 return $this->getPlugin()->txt($a_var);
78 }
79
84 public function getParentTypes(): array
85 {
86 return $this->plugin->getParentTypes();
87 }
88
97 public static function langExitsById(string $pluginId, string $langVar): bool
98 {
99 global $DIC;
100 $lng = $DIC->language();
101
102 $pl = self::getPluginObjectByType($pluginId);
103 $pl->loadLanguageModule();
104
105 return $lng->exists($pl->getPrefix() . "_" . $langVar);
106 }
107
108 public function getPrefix(): string
109 {
110 return $this->getPlugin()->getPrefix();
111 }
112}
static getLogger(string $a_component_id)
Get component logger.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getParentTypes()
returns a list of all repository object types which can be a parent of this type.
static getPluginObjectByType(string $type)
Return either a repoObject plugin or a orgunit extension plugin or null if the type is not a plugin.
txt(string $a_var)
static langExitsById(string $pluginId, string $langVar)
Is searched lang var available in plugin lang files.
static lookupTxtById(string $plugin_id, string $lang_var)
getPlugin()
Get plugin object.
ilComponentFactory $component_factory
__construct(int $a_ref_id=0)
string $type
getPlugin(string $id)
Get the plugin for the given id.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $lng
Definition: privfeed.php:31
global $DIC
Definition: shib_login.php:26