ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilOrgUnitOperationContextQueries.php
Go to the documentation of this file.
1<?php
2
9{
10
18 public static function registerNewContext($context_name, $parent_context = null)
19 {
20 if (ilOrgUnitOperationContext::where(array( 'context' => $context_name ))->hasSets()) {
21 throw new ilException('Context already registered');
22 }
23
24 $parentList = ilOrgUnitOperationContext::where(array( 'context' => $parent_context ));
25 $parent_id = 0;
26 if ($parent_context !== null && $parentList->hasSets()) {
30 $parent = $parentList->first();
31 $parent_id = $parent->getId();
32 }
33
35 $context->setContext($context_name);
36 $context->setParentContextId($parent_id);
37 $context->create();
38 }
39
40
44 protected static $instance_by_name = array();
45
46
52 public static function findByName($context_name)
53 {
54 if (!isset(self::$instance_by_name[$context_name])) {
55 self::$instance_by_name[$context_name] = ilOrgUnitOperationContext::where(array( 'context' => $context_name ))
56 ->first();
57 }
58
59 return self::$instance_by_name[$context_name];
60 }
61
62
68 public static function findById($id)
69 {
70 return ilOrgUnitOperationContext::find($id);
71 }
72
73
79 public static function findByRefId($ref_id)
80 {
81 $type_context = ilObject2::_lookupType($ref_id, true);
82
83 return self::findByName($type_context);
84 }
85
86
92 public static function findByObjId($obj_id)
93 {
94 $type_context = ilObject2::_lookupType($obj_id, false);
95
96 return self::findByName($type_context);
97 }
98}
static where($where, $operator=null)
An exception for terminatinating execution or to throw for unit testing.
Base class for ILIAS Exception handling.
static _lookupType($a_id, $a_reference=false)
lookup object type
Class ilOrgUnitOperationContextQueries.
Class ilOrgUnitOperationContext.
if(!array_key_exists('StateId', $_REQUEST)) $id
$context
Definition: webdav.php:25