-
Notifications
You must be signed in to change notification settings - Fork 0
/
Loader.php
52 lines (45 loc) · 1.28 KB
/
Loader.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
<?php
/**
* Load 3rd party libraries located in the directory LMVC\Vendor
*
* @author Andy Daykin
* @copyright Copyright (c) 2012 Andy Daykin
* @license MIT http://www.opensource.org/licenses/mit-license.php
* @version 0.1
* @link https://github.com/adaykin/LMVC/Loader.php
* @package LMVC\Loader
*/
namespace LMVC;
class Loader
{
/**
* Prevent developers from directly creating a Loader object.
*/
private function Loader()
{
}
/**
* Loads a file located in the vendor directory.
*
* @param String $name
*/
public static function loadVendor($name)
{
if(!file_exists(APP_URL . DIRECTORY_SEPARATOR . 'Vendor' . DIRECTORY_SEPARATOR . $name)) {
throw new Exception("Failed to load $name");
}
include APP_URL . DIRECTORY_SEPARATOR . 'Vendor' . DIRECTORY_SEPARATOR . $name;
}
/**
*
*
* @param String $name
*/
public static function loadModel($name)
{
if(!file_exists(APP_URL . DIRECTORY_SEPARATOR . 'application' . DIRECTORY_SEPARATOR . 'models' . DIRECTORY_SEPARATOR . $name . '.php')) {
throw new Exception("Failed to load $name");
}
include APP_URL . DIRECTORY_SEPARATOR . 'application' . DIRECTORY_SEPARATOR . 'models' . DIRECTORY_SEPARATOR . $name . '.php';
}
}