ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
class.ilOrgUnitOperationContextQueries.php
Go to the documentation of this file.
1 <?php
2 
26 {
27  protected static array $instance_by_name = array();
29 
30  protected static function getContextRepo()
31  {
32  if (!isset(self::$contextRepo)) {
34  self::$contextRepo = $dic["repo.OperationContexts"];
35  }
36 
37  return self::$contextRepo;
38  }
39 
43  public static function registerNewContext(string $context_name, ?string $parent_context = null): void
44  {
45  $context = self::getContextRepo()->get($context_name, $parent_context);
46  }
47 
48 
53  public static function findByName(string $context_name): ilOrgUnitOperationContext
54  {
55  if (!isset(self::$instance_by_name[$context_name])) {
56  $context = self::getContextRepo()->find($context_name);
57  if (!$context) {
58  throw new ilException("Context not found");
59  }
60  self::$instance_by_name[$context_name] = $context;
61  }
62 
63  return self::$instance_by_name[$context_name];
64  }
65 
70  public static function findById(int $id): ilOrgUnitOperationContext
71  {
72  return self::getContextRepo()->getById($id);
73  }
74 
78  public static function findByRefId(int $ref_id): ilOrgUnitOperationContext
79  {
80  $type_context = ilObject2::_lookupType($ref_id, true);
81 
82  return self::findByName($type_context);
83  }
84 
88  public static function findByObjId(int $obj_id): ilOrgUnitOperationContext
89  {
90  $type_context = ilObject2::_lookupType($obj_id, false);
91 
92  return self::findByName($type_context);
93  }
94 }
$context
Definition: webdav.php:31
static registerNewContext(string $context_name, ?string $parent_context=null)
$ref_id
Definition: ltiauth.php:66
static ilOrgUnitOperationContextDBRepository $contextRepo
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:24
$dic
Definition: ltiresult.php:33
static _lookupType(int $id, bool $reference=false)