This repository has been archived by the owner on Apr 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SiteSpecificAutoloadSample.php
53 lines (48 loc) · 2.24 KB
/
SiteSpecificAutoloadSample.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
/**
* Class SiteSpecificAutoloadSample
* DO NOT USE YOUR SITE SPECIFIC AUTOLOADER TO INCLUDE CORE CLASSES!!!!!
* INCLUDE ONLY MAPINGS TO YOUR SITE SPECIFIC CLASSES INSTEAD!!!!
*
* @author Simon Mitchell <[email protected]?
*
* @version 1.0.0 An example autoloader that can be used for site specific classes.
* This should be renamed to "SiteSpecificAutoload.php" in order for the index.php in
* the root directory to find it.
*/
require_once('SunsetCodersClassAutoloader.php');
class SampleSiteSpecificAutoloadSample
{
/**
* SiteSpecificAutoloadSample constructor.
*/
public function __construct()
{
foreach (self::getClassMap() as $namespacePrefix => $baseDir) {
$SunsetCodersAutoloader = new SunsetCodersClassAutoloader();
// SM: Specify which class files we are covering.
// SM: Map the namespace to the base path.
$SunsetCodersAutoloader->addNamespace($namespacePrefix, $baseDir);
$SunsetCodersAutoloader->register();
}
}
/**
* @return array Array of classes and physical locations to map namespaces.
*/
private static function getClassMap(): array
{
// SM: At the very least, you should have this:
return [
'SunsetCoders\SiteSpecific\Models' => $_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR.'SunsetCoders'.DIRECTORY_SEPARATOR.'SiteSpecific'.DIRECTORY_SEPARATOR.'Models'
];
/*
return [
'SunsetCoders\Config' => $_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR.'SunsetCoders'.DIRECTORY_SEPARATOR.'Config',
'SunsetCoders\Core\Models' => $_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR.'SunsetCoders'.DIRECTORY_SEPARATOR.'Core'.DIRECTORY_SEPARATOR.'Models',
'SunsetCoders\DataAccess' => $_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR.'SunsetCoders'.DIRECTORY_SEPARATOR.'DataAccess',
'SunsetCoders\Exception' => $_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR.'SunsetCoders'.DIRECTORY_SEPARATOR.'Exception',
'SunsetCoders\PageRender' => $_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR.'SunsetCoders'.DIRECTORY_SEPARATOR.'PageRender',
];
*/
}
}