ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
class.ilTestProcessLockerFactory.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
30{
31 protected ?int $context_id;
32
33 public function __construct(
34 private readonly ilSetting $settings,
35 private readonly ilDBInterface $db,
36 private readonly ilLogger|TestLogger $logger
37 ) {
38 }
39
40 public function getContextId(): ?int
41 {
42 return $this->context_id;
43 }
44
45 public function withContextId(int $contextId): self
46 {
47 $clone = clone $this;
48 $clone->context_id = $contextId;
49
50 return $clone;
51 }
52
53 private function getLockModeSettingValue(): ?string
54 {
55 return $this->settings->get('ass_process_lock_mode', ilObjTestFolder::ASS_PROC_LOCK_MODE_NONE);
56 }
57
58 public function getLocker(): ilTestProcessLocker
59 {
60 switch ($this->getLockModeSettingValue()) {
62 return new ilTestProcessLockerNone();
63
65 $storage = new ilTestProcessLockFileStorage((int) $this->getContextId());
66 $storage->create();
67 return new ilTestProcessLockerFile($storage, $this->logger);
68
70 return new ilTestProcessLockerDb($this->db);
71 }
72 }
73
75 {
76 if ($this->getLocker() instanceof ilTestProcessLockerFile) {
77 return $this->getLocker();
78 }
79
80 return new ilTestProcessLockerNone();
81 }
82}
Component logger with individual log levels by component id.
const ASS_PROC_LOCK_MODE_NONE
const ASS_PROC_LOCK_MODE_FILE
ILIAS Setting Class.
__construct(private readonly ilSetting $settings, private readonly ilDBInterface $db, private readonly ilLogger|TestLogger $logger)
Interface ilDBInterface.