ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilObjectGUIFactory.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4
17{
21 protected $obj_definition;
22
26 protected $db;
27
34 {
35 global $DIC;
36
37 if (is_null($obj_definition)) {
38 $obj_definition = $DIC["objDefinition"];
39 }
40 $this->obj_definition = $obj_definition;
41
42 if (is_null($db)) {
43 $db = $DIC->database();
44 }
45 $this->db = $db;
46 }
47
48
57 public function getInstanceByRefId($a_ref_id)
58 {
60 $db = $this->db;
61
62 // check reference id
63 if (!isset($a_ref_id)) {
64 throw new ilObjectNotFoundException("ilObjectGUIFactory::getInstanceByRefId(): No ref_id given!");
65 }
66
67 // check if object exists
68 $set = $db->queryF(
69 "SELECT * FROM object_data,object_reference " .
70 "WHERE object_reference.obj_id = object_data.obj_id " .
71 "AND object_reference.ref_id = %s ",
72 array("integer"),
73 array($a_ref_id)
74 );
75 if (!($rec = $db->fetchAssoc($set))) {
76 throw new ilObjectNotFoundException("ilObjectGUIFactory::getInstanceByRefId(): Object with ref_id " . $a_ref_id . " not found!");
77 }
78
79 // check class name
80 $class_name = "ilObj" . $obj_definition->getClassName($rec["type"]) . "GUI";
81 if ($class_name == "ilObjGUI") {
82 throw new ilObjectException("ilObjectGUIFactory::getInstanceByRefId(): Not able to determine object " .
83 "class for type" . $rec["type"] . ".");
84 }
85
86 // create instance
87 $location = $obj_definition->getLocation($rec["type"]);
88 include_once($location . "/class." . $class_name . ".php");
89 $gui_obj = new $class_name("", $a_ref_id, true, false);
90
91 return $gui_obj;
92 }
93}
$location
Definition: buildRTE.php:44
An exception for terminatinating execution or to throw for unit testing.
parses the objects.xml it handles the xml-description of all ilias objects
Base exception class for object service.
See bug discussion 24472.
__construct(ilObjectDefinition $obj_definition=null, ilDBInterface $db=null)
Constructor.
getInstanceByRefId($a_ref_id)
Get ilObj...GUI instance by reference id.
global $DIC
Definition: goto.php:24
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...