ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilAssQuestionProcessLockFileStorage.php
Go to the documentation of this file.
1<?php
25{
26 private string $sub_path;
27
28 public function __construct(int $question_id, int $user_id)
29 {
31
32 $this->initSubPath($user_id);
33 }
34
43 protected function getPathPrefix(): string
44 {
45 return 'ilAssQuestionProcessLocks';
46 }
47
57 protected function getPathPostfix(): string
58 {
59 return 'question';
60 }
61
62 public function getPath(): string
63 {
64 return parent::getPath() . '/' . $this->sub_path;
65 }
66
67 public function create(): void
68 {
69 set_error_handler(function ($severity, $message, $file, $line): void {
70 throw new ErrorException($message, $severity, 0, $file, $line);
71 });
72
73 try {
74 parent::create($this->getPath());
75 restore_error_handler();
76 } catch (Exception $e) {
77 restore_error_handler();
78 }
79
80 if (!$this->getFileSystemService()->has($this->path)) {
81 throw new ErrorException(sprintf('Could not find directory: %s', $this->getPath()));
82 }
83 }
84
85 private function initSubPath(int $user_id): void
86 {
87 $user_id = (string) $user_id;
88
89 $path = [];
90
91 for ($i = 0, $max = strlen($user_id); $i < $max; $i++) {
92 $path[] = substr($user_id, $i, 1);
93 }
94
95 $this->sub_path = implode('/', $path);
96 }
97}
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
has(string $class_name)
$message
Definition: xapiexit.php:31