ILIAS  release_8 Revision v8.24
ilObjectGUIFactory Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Collaboration diagram for ilObjectGUIFactory:

Public Member Functions

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

Protected Attributes

ilObjectDefinition $obj_definition
 
ilDBInterface $db
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning 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 30 of file class.ilObjectGUIFactory.php.

Constructor & Destructor Documentation

◆ __construct()

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

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

36 {
37 global $DIC;
38
39 if (is_null($obj_definition)) {
40 $obj_definition = $DIC["objDefinition"];
41 }
42 $this->obj_definition = $obj_definition;
43
44 if (is_null($db)) {
45 $db = $DIC->database();
46 }
47 $this->db = $db;
48 }
ilObjectDefinition $obj_definition
global $DIC
Definition: feed.php:28

References $db, $DIC, and $obj_definition.

Member Function Documentation

◆ getInstanceByRefId()

ilObjectGUIFactory::getInstanceByRefId ( int  $ref_id)

Get ilObj...GUI instance by reference id.

Exceptions
ilObjectException
ilObjectNotFoundException

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

57 : ilObject
58 {
59 // check reference id
60 if (!isset($ref_id)) {
61 throw new ilObjectNotFoundException("ilObjectGUIFactory::getInstanceByRefId(): No ref_id given!");
62 }
63
64 $sql =
65 "SELECT object_data.type" . PHP_EOL
66 . "FROM object_data,object_reference" . PHP_EOL
67 . "WHERE object_reference.obj_id = object_data.obj_id" . PHP_EOL
68 . "AND object_reference.ref_id = %s" . PHP_EOL
69 ;
70 // check if object exists
71 $result = $this->db->queryF($sql, ["integer"], [$ref_id]);
72 if (!($row = $this->db->fetchAssoc($result))) {
74 "ilObjectGUIFactory::getInstanceByRefId(): Object with ref_id " . $ref_id . " not found!"
75 );
76 }
77
78 // check class name
79 $class_name = "ilObj" . $this->obj_definition->getClassName($row["type"]) . "GUI";
80 if ($class_name == "ilObjGUI") {
81 throw new ilObjectException("ilObjectGUIFactory::getInstanceByRefId(): Not able to determine object " .
82 "class for type" . $row["type"] . ".");
83 }
84
85 // create instance
86 $location = $this->obj_definition->getLocation($row["type"]);
87 include_once($location . "/class." . $class_name . ".php");
88 return new $class_name("", $ref_id, true, false);
89 }
$location
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: buildRTE.php:22
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...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$ref_id
Definition: ltiauth.php:67

References $location, and $ref_id.

Field Documentation

◆ $db

ilDBInterface ilObjectGUIFactory::$db
protected

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

Referenced by __construct().

◆ $obj_definition

ilObjectDefinition ilObjectGUIFactory::$obj_definition
protected

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

Referenced by __construct().


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