mirror of
https://github.com/claradex/nativegallery.git
synced 2024-12-22 16:41:04 +03:00
46 lines
1 KiB
PHP
46 lines
1 KiB
PHP
<?php
|
|
|
|
namespace App\Core;
|
|
|
|
class Page
|
|
{
|
|
private static $cache = [];
|
|
|
|
public static function component($name)
|
|
{
|
|
if (!isset(self::$cache[$name])) {
|
|
self::$cache[$name] = require_once($_SERVER['DOCUMENT_ROOT'] . '/views/components/' . $name . '.php');
|
|
}
|
|
|
|
return self::$cache[$name];
|
|
}
|
|
|
|
public static function rewrite($search, $replace, $rootUrl)
|
|
{
|
|
return str_ireplace($search, $replace, $rootUrl);
|
|
}
|
|
|
|
public static function set($name)
|
|
{
|
|
if (!isset(self::$cache[$name])) {
|
|
self::$cache[$name] = require_once($_SERVER['DOCUMENT_ROOT'] . '/views/pages/' . $name . '.php');
|
|
}
|
|
|
|
return self::$cache[$name];
|
|
}
|
|
|
|
public static function render($name)
|
|
{
|
|
return self::set($name)();
|
|
}
|
|
|
|
public static function method()
|
|
{
|
|
return $_SERVER['REQUEST_METHOD'];
|
|
}
|
|
|
|
public static function exists($name)
|
|
{
|
|
return file_exists($_SERVER['DOCUMENT_ROOT'] . '/views/pages/' . $name . '.php');
|
|
}
|
|
}
|