15 private string $documentRoot;
18 private string $viewPath,
19 private string $renderFunctionName,
32 $path = $this->getAbsolutePath();
46 elseif (!str_starts_with(
$path, $this->documentRoot))
51 $pathOnDocumentRoot = substr(
53 strlen($this->documentRoot)
56 return $pathOnDocumentRoot;
59 private function getAbsolutePath(): ?string
61 if (str_starts_with($this->viewPath,
'/'))
63 return $this->documentRoot . $this->viewPath;
66 return $this->getPathToViewOnModule();
69 private function getPathToViewOnModule(): ?string
74 $extension = pathinfo($this->viewPath, PATHINFO_EXTENSION);
75 if ($extension ===
'')
79 elseif ($extension !==
'php')
81 throw new SystemException(
'Invalid extension for view file: ' . $extension);
85 'modules/' .
$moduleId .
'/views/' . $this->viewPath . $postfix,
95 private function getModuleId(): string
97 $trace = Helper::getBackTrace();
98 foreach ($trace as $item)
100 if ($item[
'function'] === $this->renderFunctionName)
103 $parts = explode(
'/',
$path);
105 foreach ($parts as $part)
109 if (isset($prevPart))
120 throw new SystemException(
'Cannot parse module id from path');
__construct(private string $viewPath, private string $renderFunctionName,)
static getLocal($path, $root=null)
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)