ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilObjectPlugin.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once("./Services/Object/classes/class.ilObject2.php");
5require_once('./Services/Component/classes/class.ilPlugin.php');
6require_once('./Services/Repository/classes/class.ilObjectPlugin.php');
7
8/*
9* Object class for plugins. This one wraps around ilObject
10*
11* @author Alex Killing <alex.killing@gmx.de>
12* @version $Id$
13* @ingroup ServicesRepository
14*/
15abstract class ilObjectPlugin extends ilObject2
16{
17 private $object;
18
19 protected $plugin;
20
24 protected static $plugin_by_type = array();
25
26
30 function __construct($a_ref_id = 0)
31 {
32 $this->initType();
33 parent::__construct($a_ref_id, true);
34 $this->plugin = $this->getPlugin();
35 }
36
37
44 public static function getRepoPluginObjectByType($type) {
45 if (!self::$plugin_by_type[$type]) {
47 }
48
49 return self::$plugin_by_type[$type];
50 }
51
52
56 protected static function loadRepoPlugin($type_id) {
58 ilPlugin::lookupNameForId(IL_COMP_SERVICE, "Repository", "robj", $type_id));
59 if (!$plugin) {
60 $plugin = ilPlugin::getPluginObject(IL_COMP_MODULE, "OrgUnit", "orguext",
61 ilPlugin::lookupNameForId(IL_COMP_MODULE, "OrgUnit", "orguext", $type_id));
62 }
63 if (!$plugin) {
64 ilLoggerFactory::getLogger("obj")->log("Try to get repo plugin obj by type: $type_id. No such type exists for Repository and Org Unit pluginss.");
65 }
66 self::$plugin_by_type[$type_id] = $plugin;
67 }
68
74 static function lookupTxtById($plugin_id, $lang_var) {
75 $pl = self::getRepoPluginObjectByType($plugin_id);
76 return $pl->txt($lang_var);
77 }
78
84 protected function getPlugin()
85 {
86 if(!$this->plugin) {
87 $this->plugin =
88 ilPlugin::getPluginObject(IL_COMP_SERVICE, "Repository", "robj",
89 ilPlugin::lookupNameForId(IL_COMP_SERVICE, "Repository", "robj", $this->getType()));
90 if (!is_object($this->plugin)) {
91 throw new ilPluginException("ilObjectPlugin: Could not instantiate plugin object for type " . $this->getType() . ".");
92 }
93 }
94 return $this->plugin;
95 }
96
100 final protected function txt($a_var)
101 {
102 return $this->getPlugin()->txt($a_var);
103 }
104
109 public function getParentTypes() {
110 return $this->plugin->getParentTypes();
111 }
112}
An exception for terminatinating execution or to throw for unit testing.
const IL_COMP_SERVICE
const IL_COMP_MODULE
static getLogger($a_component_id)
Get component logger.
Class ilObject2 This is an intermediate progress of ilObject class.
getType()
get object type @access public
__construct($a_ref_id=0)
Constructor.
getParentTypes()
returns a list of all repository object types which can be a parent of this type.
static getRepoPluginObjectByType($type)
Return either a repoObject plugin or a orgunit extension plugin or null if the type is not a plugin.
static lookupTxtById($plugin_id, $lang_var)
static loadRepoPlugin($type_id)
txt($a_var)
Wrapper for txt function.
getPlugin()
Get plugin object.
static getPluginObject($a_ctype, $a_cname, $a_slot_id, $a_pname)
Get plugin object.
static lookupNameForId($a_ctype, $a_cname, $a_slot_id, $a_plugin_id)
Lookup name for id.