ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilAssQuestionProcessLockFileStorage.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 'Services/FileSystem/classes/class.ilFileSystemStorage.php';
5
13{
14 private $subPath;
15
16 public function __construct($questionId, $userId)
17 {
19
20 $this->initSubPath($userId);
21 }
22
31 protected function getPathPrefix()
32 {
33 return 'ilAssQuestionProcessLocks';
34 }
35
45 protected function getPathPostfix()
46 {
47 return 'question';
48 }
49
50 public function getPath()
51 {
52 return parent::getPath() . '/' . $this->subPath;
53 }
54
55 public function create()
56 {
57 set_error_handler(function ($severity, $message, $file, $line) {
58 throw new ErrorException($message, $severity, 0, $file, $line);
59 });
60
61 try {
63 restore_error_handler();
64 } catch (Exception $e) {
65 restore_error_handler();
66 }
67
68 if (!file_exists($this->getPath())) {
69 throw new ErrorException(sprintf('Could not find directory: %s', $this->getPath()));
70 }
71
72 return true;
73 }
74
75 private function initSubPath($userId)
76 {
77 $userId = (string) $userId;
78
79 $path = array();
80
81 for ($i = 0, $max = strlen($userId); $i < $max; $i++) {
82 $path[] = substr($userId, $i, 1);
83 }
84
85 $this->subPath = implode('/', $path);
86 }
87}
An exception for terminatinating execution or to throw for unit testing.
static makeDirParents($a_dir)
Create a new directory and all parent directories.
$i
Definition: metadata.php:24
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$message
Definition: xapiexit.php:14