ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilOrgUnitOperationContextQueries.php
Go to the documentation of this file.
1<?php
2
25{
26 protected static array $instance_by_name = array();
28
29 protected static function getContextRepo()
30 {
31 if (!isset(self::$contextRepo)) {
33 self::$contextRepo = $dic["repo.OperationContexts"];
34 }
35
36 return self::$contextRepo;
37 }
38
42 public static function registerNewContext(string $context_name, ?string $parent_context = null): void
43 {
44 $context = self::getContextRepo()->get($context_name, $parent_context);
45 }
46
47
52 public static function findByName(string $context_name): ilOrgUnitOperationContext
53 {
54 if (!isset(self::$instance_by_name[$context_name])) {
55 $context = self::getContextRepo()->find($context_name);
56 if (!$context) {
57 throw new ilException("Context not found");
58 }
59 self::$instance_by_name[$context_name] = $context;
60 }
61
62 return self::$instance_by_name[$context_name];
63 }
64
69 public static function findById(int $id): ilOrgUnitOperationContext
70 {
71 return self::getContextRepo()->getById($id);
72 }
73
77 public static function findByRefId(int $ref_id): ilOrgUnitOperationContext
78 {
79 $type_context = ilObject2::_lookupType($ref_id, true);
80
81 return self::findByName($type_context);
82 }
83
87 public static function findByObjId(int $obj_id): ilOrgUnitOperationContext
88 {
89 $type_context = ilObject2::_lookupType($obj_id, false);
90
91 return self::findByName($type_context);
92 }
93}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
Base class for ILIAS Exception handling.
static _lookupType(int $id, bool $reference=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static ilOrgUnitOperationContextDBRepository $contextRepo
static registerNewContext(string $context_name, ?string $parent_context=null)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$ref_id
Definition: ltiauth.php:66
$dic
Definition: ltiresult.php:33
$context
Definition: webdav.php:31