ILIAS  release_8 Revision v8.24
class.ilTestProcessLockerFactory.php
Go to the documentation of this file.
1<?php
2
26{
30 protected $settings;
31
35 protected $db;
36
40 protected $contextId;
41
47 {
48 $this->settings = $settings;
49 $this->db = $db;
50 }
51
52 public function getContextId(): ?int
53 {
54 return $this->contextId;
55 }
56
57 public function withContextId(int $contextId): self
58 {
59 $clone = clone $this;
60 $clone->contextId = $contextId;
61
62 return $clone;
63 }
64
65 private function getLockModeSettingValue(): ?string
66 {
67 return $this->settings->get('ass_process_lock_mode', ilObjAssessmentFolder::ASS_PROC_LOCK_MODE_NONE);
68 }
69
73 public function getLocker(): ilTestProcessLocker
74 {
75 switch ($this->getLockModeSettingValue()) {
77
78 $locker = new ilTestProcessLockerNone();
79 break;
80
82
83 $storage = new ilTestProcessLockFileStorage((int) $this->getContextId());
84 $storage->create();
85
86 $locker = new ilTestProcessLockerFile($storage);
87 break;
88
90
91 $locker = new ilTestProcessLockerDb($this->db);
92 break;
93 }
94
95 return $locker;
96 }
97
99 {
100 if ($this->getLocker() instanceof ilTestProcessLockerFile) {
101 return $this->getLocker();
102 }
103
104 return new ilTestProcessLockerNone();
105 }
106}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(ilSetting $settings, ilDBInterface $db)
Interface ilDBInterface.