ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
class.ilAssQuestionProcessLockFileStorage.php
Go to the documentation of this file.
1<?php
2
26{
27 private string $sub_path;
28
29 public function __construct(int $question_id, int $user_id)
30 {
32
33 $this->initSubPath($user_id);
34 }
35
44 protected function getPathPrefix(): string
45 {
46 return 'ilAssQuestionProcessLocks';
47 }
48
58 protected function getPathPostfix(): string
59 {
60 return 'question';
61 }
62
63 public function getAbsolutePath(): string
64 {
65 return rtrim($this->getLegacyAbsolutePath(), '/') . '/' . $this->sub_path;
66 }
67
68
69 public function getPath(): string
70 {
71 return parent::getPath() . '/' . $this->sub_path;
72 }
73
74 public function create(): void
75 {
76 set_error_handler(function ($severity, $message, $file, $line): void {
77 throw new ErrorException($message, $severity, 0, $file, $line);
78 });
79
80 try {
81 if (!$this->getFileSystemService()->has($this->getPath())) {
82 $this->getFileSystemService()->createDir($this->getPath());
83 }
84 restore_error_handler();
85 } catch (Exception $e) {
86 restore_error_handler();
87 }
88
89 if (!$this->getFileSystemService()->has($this->path)) {
90 throw new ErrorException(sprintf('Could not find directory: %s', $this->getPath()));
91 }
92 }
93
94 private function initSubPath(int $user_id): void
95 {
96 $user_id = (string) $user_id;
97
98 $path = [];
99
100 for ($i = 0, $max = strlen($user_id); $i < $max; $i++) {
101 $path[] = substr($user_id, $i, 1);
102 }
103
104 $this->sub_path = implode('/', $path);
105 }
106}
getAbsolutePath()
Calculates the full path on the filesystem.
getLegacyAbsolutePath()
Calculates the absolute filesystem storage location.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
has(string $class_name)