ILIAS  release_7 Revision v7.30-3-g800a261c036
ilObjectGUIFactory Class Reference

See bug discussion 24472. More...

+ Collaboration diagram for ilObjectGUIFactory:

Public Member Functions

 __construct (ilObjectDefinition $obj_definition=null, ilDBInterface $db=null)
 Constructor. More...
 
 getInstanceByRefId ($a_ref_id)
 Get ilObj...GUI instance by reference id. More...
 

Protected Attributes

 $obj_definition
 
 $db
 

Detailed Description

See bug discussion 24472.

Do not use this class yet. This might need a general factory interface first.

This could be moved to $DIC->object() service asap.

Author
killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

Definition at line 16 of file class.ilObjectGUIFactory.php.

Constructor & Destructor Documentation

◆ __construct()

ilObjectGUIFactory::__construct ( ilObjectDefinition  $obj_definition = null,
ilDBInterface  $db = null 
)

Constructor.

Parameters
ilObjectDefinition | null$obj_definition
ilDBInterface | null$db

Definition at line 33 of file class.ilObjectGUIFactory.php.

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 }
global $DIC
Definition: goto.php:24

References $db, $DIC, and $obj_definition.

Member Function Documentation

◆ getInstanceByRefId()

ilObjectGUIFactory::getInstanceByRefId (   $a_ref_id)

Get ilObj...GUI instance by reference id.

Parameters
$a_ref_id
Returns
mixed
Exceptions
ilObjectException
ilObjectNotFoundException

Definition at line 57 of file class.ilObjectGUIFactory.php.

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 }
$location
Definition: buildRTE.php:44
Base exception class for object service.

References $db, $location, and $obj_definition.

Field Documentation

◆ $db

ilObjectGUIFactory::$db
protected

Definition at line 26 of file class.ilObjectGUIFactory.php.

Referenced by __construct(), and getInstanceByRefId().

◆ $obj_definition

ilObjectGUIFactory::$obj_definition
protected

Definition at line 21 of file class.ilObjectGUIFactory.php.

Referenced by __construct(), and getInstanceByRefId().


The documentation for this class was generated from the following file: