ILIAS  trunk Revision v11.0_alpha-1689-g66c127b4ae8
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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 }
$context
Definition: webdav.php:31
static registerNewContext(string $context_name, ?string $parent_context=null)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
$ref_id
Definition: ltiauth.php:65
static ilOrgUnitOperationContextDBRepository $contextRepo
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
$dic
Definition: result.php:31
static _lookupType(int $id, bool $reference=false)