ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.arFieldCache.php
Go to the documentation of this file.
1<?php
2
25{
26 protected static array $cache = [];
27
28 public static function isCached(ActiveRecord $activeRecord): bool
29 {
30 return array_key_exists($activeRecord::class, self::$cache);
31 }
32
33 public static function store(ActiveRecord $activeRecord): void
34 {
35 self::$cache[$activeRecord::class] = arFieldList::getInstance($activeRecord);
36 }
37
38 public static function storeFromStorage(string $storage_class_name, ActiveRecord $activeRecord): void
39 {
40 self::$cache[$storage_class_name] = arFieldList::getInstanceFromStorage($activeRecord);
41 }
42
43 public static function get(ActiveRecord $activeRecord): \arFieldList
44 {
45 if (!self::isCached($activeRecord)) {
46 self::store($activeRecord);
47 }
48
49 return self::$cache[$activeRecord::class];
50 }
51
52 public static function purge(ActiveRecord $activeRecord): void
53 {
54 unset(self::$cache[$activeRecord::class]);
55 }
56
57 public static function getPrimaryFieldName(ActiveRecord $activeRecord): string
58 {
59 return self::get($activeRecord)->getPrimaryFieldName();
60 }
61
65 public static function getPrimaryFieldType(ActiveRecord $activeRecord): string
66 {
67 return self::get($activeRecord)->getPrimaryFieldType();
68 }
69}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static storeFromStorage(string $storage_class_name, ActiveRecord $activeRecord)
static isCached(ActiveRecord $activeRecord)
static get(ActiveRecord $activeRecord)
static store(ActiveRecord $activeRecord)
static array $cache
static getPrimaryFieldType(ActiveRecord $activeRecord)
static getPrimaryFieldName(ActiveRecord $activeRecord)
static purge(ActiveRecord $activeRecord)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getInstance(ActiveRecord $activeRecord)
static getInstanceFromStorage(\ActiveRecord $activeRecord)