ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilTestProcessLockerFactory.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4require_once 'Modules/Test/classes/class.ilObjAssessmentFolder.php';
5require_once 'Modules/Test/classes/class.ilTestProcessLocker.php';
6require_once 'Modules/Test/classes/class.ilTestProcessLockerNone.php';
7require_once 'Modules/Test/classes/class.ilTestProcessLockerFile.php';
8require_once 'Modules/Test/classes/class.ilTestProcessLockerDb.php';
9
17{
21 protected $settings;
22
26 protected $db;
27
31 protected $contextId;
32
38 {
39 $this->settings = $settings;
40 $this->db = $db;
41 }
42
43 public function getContextId() : ?int
44 {
45 return $this->contextId;
46 }
47
48 public function withContextId(int $contextId) : self
49 {
50 $clone = clone $this;
51 $clone->contextId = $contextId;
52
53 return $clone;
54 }
55
56 private function getLockModeSettingValue()
57 {
58 return $this->settings->get('ass_process_lock_mode', ilObjAssessmentFolder::ASS_PROC_LOCK_MODE_NONE);
59 }
60
64 public function getLocker() : ilTestProcessLocker
65 {
66 switch ($this->getLockModeSettingValue()) {
68
69 $locker = new ilTestProcessLockerNone();
70 break;
71
73
74 $storage = new ilTestProcessLockFileStorage((int) $this->getContextId());
75 $storage->create();
76
77 $locker = new ilTestProcessLockerFile($storage);
78 break;
79
81
82 $locker = new ilTestProcessLockerDb($this->db);
83 break;
84 }
85
86 return $locker;
87 }
88
90 {
91 if ($this->getLocker() instanceof ilTestProcessLockerFile) {
92 return $this->getLocker();
93 }
94
95 return new ilTestProcessLockerNone();
96 }
97}
An exception for terminatinating execution or to throw for unit testing.
ILIAS Setting Class.
__construct(ilSetting $settings, ilDBInterface $db)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
settings()
Definition: settings.php:2