ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilWACSecurePath.php
Go to the documentation of this file.
1 <?php
2 // declare(strict_types=1);
3 
4 require_once './Services/ActiveRecord/class.ActiveRecord.php';
5 require_once './Services/WebAccessChecker/class.ilWACException.php';
6 
14 {
15 
21  public static function returnDbTableName()
22  {
23  return 'il_wac_secure_path';
24  }
25 
26 
38  public static function getCheckingInstance(ilWACPath $ilWACPath)
39  {
43  $obj = self::find($ilWACPath->getModuleType());
44  if (!$obj) {
45  throw new ilWACException(ilWACException::CODE_NO_PATH, 'No Checking Instance found for id: ' . $ilWACPath->getSecurePathId());
46  }
47 
48  $secure_path_checking_class = $obj->getComponentDirectory() . '/classes/class.' . $obj->getCheckingClass() . '.php';
49  if (!file_exists($secure_path_checking_class)) {
50  throw new ilWACException(ilWACException::CODE_NO_PATH, 'Checking Instance not found in path: ' . $secure_path_checking_class);
51  }
52 
53  require_once($secure_path_checking_class);
54  $class_name = $obj->getCheckingClass();
55 
56  return new $class_name();
57  }
58 
59 
67  public static function hasCheckingInstanceRegistered(ilWACPath $ilWACPath)
68  {
69  $obj = self::find($ilWACPath->getModuleType());
70  return !is_null($obj);
71  }
72 
73 
77  public function hasCheckingInstance()
78  {
80  }
81 
82 
92  protected $path = '';
100  protected $component_directory = '';
108  protected $checking_class = '';
116  protected $in_sec_folder = false;
120  protected $has_checking_instance = false;
121 
122 
126  public function getPath()
127  {
128  return (string) $this->path;
129  }
130 
131 
136  public function setPath($path)
137  {
138  assert(is_string($path));
139  $this->path = $path;
140  }
141 
142 
146  public function getComponentDirectory()
147  {
148  preg_match("/[\\\|\\/](Services|Modules|Customizing)[\\\|\\/].*/u", $this->component_directory, $matches);
149 
150  return (string) '.' . $matches[0];
151  }
152 
153 
159  {
160  assert(is_string($component_directory));
161  $this->component_directory = $component_directory;
162  }
163 
164 
168  public function getCheckingClass()
169  {
170  return (string) $this->checking_class;
171  }
172 
173 
179  {
180  assert(is_string($checking_class));
181  $this->checking_class = $checking_class;
182  }
183 
184 
190  {
191  assert(is_bool($has_checking_instance));
192  $this->has_checking_instance = $has_checking_instance;
193  }
194 
195 
199  public function getInSecFolder()
200  {
201  return (string) $this->in_sec_folder;
202  }
203 
204 
209  {
210  // assert(is_string($in_sec_folder));
211  $this->in_sec_folder = $in_sec_folder;
212  }
213 }
setInSecFolder($in_sec_folder)
setComponentDirectory($component_directory)
Class ilWACException.
Class ActiveRecord.
setCheckingClass($checking_class)
Class ilWACSecurePath.
Class ilWACPath.
setHasCheckingInstance($has_checking_instance)
static hasCheckingInstanceRegistered(ilWACPath $ilWACPath)
Searches a checking instance for the given wac path.