This repository was archived by the owner on Jan 16, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap.php
More file actions
113 lines (103 loc) · 3.05 KB
/
bootstrap.php
File metadata and controls
113 lines (103 loc) · 3.05 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<?php
/**
* The bootstrap class takes care of providing all necessary data required in the bootstrap process.
*
* @author Frank Kleine <mikey@stubbles.net>
* @package stubbles
* @version $Id: bootstrap.php 3298 2011-12-27 15:17:10Z mikey $
*/
/**
* The bootstrap class takes care of providing all necessary data required in the bootstrap process.
*
* @package stubbles
*/
class stubBootstrap
{
/**
* path to php source files
*
* @var string
*/
private static $sourcePath = null;
/**
* current project
*
* @var string
*/
private static $project = null;
/**
* returns path where common files are stored
*
* @return string
*/
public static function getCommonPath()
{
return dirname(__FILE__) . DIRECTORY_SEPARATOR . 'projects' . DIRECTORY_SEPARATOR . 'common';
}
/**
* returns name of current project
*
* @return string
* @since 1.7.0
*/
public static function getCurrentProjectPath()
{
return self::getRootPath() . '/projects/' . self::$project;
}
/**
* returns root path of the installation
*
* @return string
*/
public static function getRootPath()
{
return dirname(__FILE__);
}
/**
* returns path to php source files
* @return string
*/
public static function getSourcePath()
{
if (null == self::$sourcePath) {
self::$sourcePath = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'main';
}
return self::$sourcePath;
}
/**
* loads stubbles core classes and initializes pathes
*
* @param string $projectPath path to project
* @param string $classFile optional defaults to stubbles.php
*/
public static function init($projectPath, $classFile = 'stubbles.php')
{
if (null === self::$project) {
$lastString = strstr($projectPath, 'projects' . DIRECTORY_SEPARATOR);
if (false === $lastString) {
$lastString = strstr($projectPath, 'projects/');
}
self::$project = substr($lastString, 9);
}
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . $classFile;
stubClassLoader::load('net::stubbles::lang::stubPathRegistry');
stubPathRegistry::setProjectPath($projectPath);
}
/**
* run an application
*
* @param string $appClass full qualified class name of the app to run
* @param string $project path to project files
* @param string $classFile optional defaults to stubbles.php
* @since 1.7.0
*/
public static function run($appClass, $project, $classFile = 'stubbles.php')
{
self::$project = $project;
self::init(array('project' => self::getCurrentProjectPath()), $classFile);
stubClassLoader::load('net::stubbles::ioc::stubApp');
stubApp::createInstance($appClass, self::getCurrentProjectPath())
->run();
}
}
?>