-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathautoload.php
36 lines (30 loc) · 1.36 KB
/
autoload.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
declare(strict_types=1);
define('TEMPLATE_DIR', __DIR__.'/templates');
define('PARTIALS_DIR', __DIR__.'/partials');
define('STORAGE_DIR', __DIR__.'/storage');
define('RENDER_ACC_LOGIN', 'renderLogin'); // default in Layout.php
define('RENDER_ACC_VERIFY', 'renderVerify');
define('RENDER_ACC_USERINFO', 'renderUserinfo');
define('RENDER_ACC_REGISTER', 'renderRegister');
define('RENDER_ACC_PW_FORGOTTEN', 'renderPasswortVergessen');
define('RENDER_ACC_PW_CHANGE', 'renderPasswortChange');
define('RENDER_ACC_THANKS', 'renderThanksForRegister');
define('RENDER_BODY_WELCOME', 'renderWelcome'); // default in Layout.php
define('RENDER_BODY_EDIT_REZEPT', 'renderEditRezept');
define('RENDER_BODY_LISTE_REZEPTE', 'renderListeRezepte');
define('RENDER_BODY_SINGLE_REZEPT', 'renderSingleRezept');
$rootDir = __DIR__.'/classes/';
$autoload = function($className) use($rootDir){
$fileName = '';
if($lastNameSpacePosition = strpos($className,'\\')){
$namespace = substr($className, 0,$lastNameSpacePosition);
$className = substr($className,$lastNameSpacePosition+1);
$fileName = str_replace('\\',DIRECTORY_SEPARATOR,$namespace).DIRECTORY_SEPARATOR;
}
$fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className);
if(is_file($rootDir.$fileName.'.php')){
require_once $rootDir.$fileName.'.php';
}
};
spl_autoload_register($autoload);