-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.php
68 lines (60 loc) · 1.87 KB
/
App.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php namespace spitfire;
use ReflectionClass;
use spitfire\core\router\Router;
use spitfire\model\Model;
use spitfire\utils\Strings;
/**
* Spitfire Application Class. This class is the base of every other 'app', an
* app is a wrapper of controllers (this allows to plug them into other SF sites)
* that defines a set of rules to avoid collisions with the rest of the apps.
*
* Every app resides inside of a namespace, this externally defined variable
* defines what calls Spitfire redirects to the app.
*
* @author César de la Cal<[email protected]>
*/
abstract class App
{
/**
*
* @var Router
*/
private $router;
/**
* Instances a new application. The application maps a directory where it's residing
* with it's name-space and the URL it's serving.
*
* Please note that some features need to be 'baked' for the applications to
* properly work (like inline-routes and prebuilt assets). It is recommendable
* that the 'baking' is performed automatically on composer::install or similar.
*
* @param Router $router A scoped router for this application to write it's routes
* to.
*/
public function __construct($router)
{
$this->router = $router;
}
/**
* Gets the URL space this application is serving. Please note that it's highly
* recommended to avoid using nested namespaces since it will often lead to
* broken applications.
*
* @return string
*/
public function url()
{
return $this->router->getPrefix();
}
/**
* Returns the directory this application is watching.
*
* @return string The directory the app resides in and where it's controllers, models, etc directories are located
*/
abstract public function directory();
/**
* Returns the application's class-namespace. This is the namespace in which
* spitfire will look for controllers, models etc for this application.
*/
abstract public function namespace();
}