3 declare(strict_types=1);
    40         $ilDB = $DIC->database();
    43             "SELECT obj_id, type, title, description, owner, create_date, last_update, import_id, offline" . PHP_EOL
    44             . 
"FROM object_data" . PHP_EOL
    45             . 
"WHERE obj_id = " . 
$ilDB->quote($obj_id, 
'integer') . PHP_EOL
    48         $result = 
$ilDB->query($sql);
    50         return (
bool) $result->numRows();
    59         $ilDB = $DIC->database();
    62             "SELECT object_data.obj_id" . PHP_EOL
    63             . 
"FROM object_data, object_reference" . PHP_EOL
    64             . 
"WHERE object_reference.obj_id = object_data.obj_id" . PHP_EOL
    65             . 
"AND object_data.type = " . 
$ilDB->quote($object_type, 
'text') . PHP_EOL
    66             . 
"AND object_data.owner = " . 
$ilDB->quote($owner_id, 
'integer') . PHP_EOL
    69         $result = 
$ilDB->query($sql);
    73             $obj_ids [] = $row[
"obj_id"];
    87         $objDefinition = $DIC[
"objDefinition"];
    88         $ilDB = $DIC->database();
    91         if (!isset($obj_id)) {
    92             $message = 
"ilObjectFactory::getInstanceByObjId(): No obj_id given!";
    93             if ($stop_on_error === 
true) {
   101             "SELECT obj_id, type, title, description, owner, create_date, last_update, import_id, offline" . PHP_EOL
   102             . 
"FROM object_data" . PHP_EOL
   103             . 
"WHERE obj_id = " . 
$ilDB->quote($obj_id, 
'integer') . PHP_EOL
   105         $result = 
$ilDB->query($sql);
   107         if ($result->numRows() == 0) {
   108             $message = 
"ilObjectFactory::getInstanceByObjId(): Object with obj_id: " . $obj_id . 
" not found!";
   109             if ($stop_on_error === 
true) {
   116         $class_name = 
"ilObj" . $objDefinition->getClassName($row[
"type"]);
   119         if ($class_name == 
"ilObj") {
   120             $message = 
"ilObjectFactory::getInstanceByObjId(): Not able to determine object " .
   121                 "class for type" . $row[
"type"] . 
".";
   122             if ($stop_on_error === 
true) {
   128         (
new self())->includeClassIfNotExists($class_name, $row[
"type"], $objDefinition);
   131         $obj = 
new $class_name(0, 
false);    
   132         $obj->setId($obj_id);
   146         $objDefinition = $DIC[
"objDefinition"];
   147         $ilDB = $DIC->database();
   150         if (!isset($ref_id)) {
   151             if ($stop_on_error === 
true) {
   152                 $message = 
"ilObjectFactory::getInstanceByRefId(): No ref_id given!";
   160             "SELECT object_data.obj_id, object_data.type" . PHP_EOL
   161             . 
"FROM object_data, object_reference" . PHP_EOL
   162             . 
"WHERE object_reference.obj_id = object_data.obj_id" . PHP_EOL
   163             . 
"AND object_reference.ref_id = " . 
$ilDB->quote($ref_id, 
'integer') . PHP_EOL
   166         $result = 
$ilDB->query($sql);
   169         if ($result->numRows() == 0) {
   170             if ($stop_on_error === 
true) {
   171                 $message = 
"ilObjectFactory::getInstanceByRefId(): Object with ref_id " . $ref_id . 
" not found!";
   178         $class_name = 
"ilObj" . $objDefinition->getClassName($row[
"type"]);
   181         if ($class_name == 
"ilObj") {
   182             if ($stop_on_error === 
true) {
   183                 $message = 
"ilObjectFactory::getInstanceByRefId(): Not able to determine object " .
   184                     "class for type" . $row[
"type"] . 
".";
   190         (
new self())->includeClassIfNotExists($class_name, $row[
"type"], $objDefinition);
   193         $obj = 
new $class_name(0, 
false);    
   194         $obj->setId((
int) $row[
"obj_id"]);
   195         $obj->setRefId($ref_id);
   208         $ilDB = $DIC->database();
   211         if (!isset($ref_id)) {
   212             if ($stop_on_error === 
true) {
   213                 $message = 
"ilObjectFactory::getTypeByRefId(): No ref_id given!";
   221             "SELECT object_data.obj_id, object_data.type" . PHP_EOL
   222             . 
"FROM object_data" . PHP_EOL
   223             . 
"LEFT JOIN object_reference ON object_data.obj_id=object_reference.obj_id " . PHP_EOL
   224             . 
"WHERE object_reference.ref_id=" . 
$ilDB->quote($ref_id, 
'integer') . PHP_EOL
   226         $result = 
$ilDB->query($sql);
   228         if ($result->numRows() == 0) {
   229             if ($stop_on_error === 
true) {
   230                 $message = 
"ilObjectFactory::getTypeByRefId(): Object with ref_id " . $ref_id . 
" not found!";
   243         $objDefinition = $DIC[
"objDefinition"];
   245         $class_name = 
"ilObj" . $objDefinition->getClassName($obj_type);
   247         (
new self())->includeClassIfNotExists($class_name, $obj_type, $objDefinition);
   265         if (!class_exists($class_name)) {
   267             include_once(
$location . 
"/class." . $class_name . 
".php");
 
$location
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
includeClassIfNotExists(string $class_name, string $a_obj_type, ilObjectDefinition $objDefinition)
Ensures a class is properly included. 
 
ObjectIdExists(int $obj_id)
check if obj_id exists. 
 
static getTypeByRefId(int $ref_id, bool $stop_on_error=true)
get object type by reference id 
 
parses the objects.xml it handles the xml-description of all ilias objects 
 
static getObjectsForOwner(string $object_type, int $owner_id)
returns all objects of an owner, filtered by type, objects are not deleted! 
 
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id 
 
static getClassByType(string $obj_type)
 
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id 
 
getLocation(string $obj_name)