ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilTestProcessLockerFactory.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
28{
32 protected $settings;
33
37 protected $db;
38
42 protected $contextId;
43
49 {
50 $this->settings = $settings;
51 $this->db = $db;
52 }
53
54 public function getContextId(): ?int
55 {
56 return $this->contextId;
57 }
58
59 public function withContextId(int $contextId): self
60 {
61 $clone = clone $this;
62 $clone->contextId = $contextId;
63
64 return $clone;
65 }
66
67 private function getLockModeSettingValue(): ?string
68 {
69 return $this->settings->get('ass_process_lock_mode', ilObjTestFolder::ASS_PROC_LOCK_MODE_NONE);
70 }
71
75 public function getLocker(): ilTestProcessLocker
76 {
77 switch ($this->getLockModeSettingValue()) {
79
80 $locker = new ilTestProcessLockerNone();
81 break;
82
84
85 $storage = new ilTestProcessLockFileStorage((int) $this->getContextId());
86 $storage->create();
87
88 $locker = new ilTestProcessLockerFile($storage);
89 break;
90
92
93 $locker = new ilTestProcessLockerDb($this->db);
94 break;
95 }
96
97 return $locker;
98 }
99
101 {
102 if ($this->getLocker() instanceof ilTestProcessLockerFile) {
103 return $this->getLocker();
104 }
105
106 return new ilTestProcessLockerNone();
107 }
108}
const ASS_PROC_LOCK_MODE_NONE
const ASS_PROC_LOCK_MODE_FILE
ILIAS Setting Class.
__construct(ilSetting $settings, ilDBInterface $db)
Interface ilDBInterface.