1 | <?php |
||
51 | class ServerFacade |
||
52 | { |
||
53 | /** |
||
54 | * Server instance |
||
55 | * |
||
56 | * @var \Apparat\Server\Domain\Model\Server |
||
57 | */ |
||
58 | protected static $server = null; |
||
59 | |||
60 | /** |
||
61 | * Register the default routes for a particular repository |
||
62 | * |
||
63 | * @param string $repositoryPath Repository path |
||
64 | * @param int $enable Enable / disable default routes |
||
65 | * @api |
||
66 | */ |
||
67 | 1 | public static function enableObjectRoute($repositoryPath = '', $enable = ObjectRoute::ALL) |
|
71 | |||
72 | /** |
||
73 | * Create and return the server instance |
||
74 | * |
||
75 | * @return Server Server instance |
||
76 | */ |
||
77 | 80 | protected static function getServer() |
|
78 | { |
||
79 | 80 | if (self::$server === null) { |
|
80 | 2 | self::$server = Kernel::create(Server::class); |
|
81 | } |
||
82 | 80 | return self::$server; |
|
83 | } |
||
84 | |||
85 | /** |
||
86 | * Register a route |
||
87 | * |
||
88 | * @param RouteInterface $route |
||
89 | * @api |
||
90 | */ |
||
91 | 3 | public static function registerRoute(RouteInterface $route) |
|
95 | |||
96 | /** |
||
97 | * Dispatch a request |
||
98 | * |
||
99 | * @param ServerRequestInterface $request |
||
100 | * @return ResponseInterface $response |
||
101 | * @api |
||
102 | */ |
||
103 | 5 | public static function dispatchRequest(ServerRequestInterface $request) |
|
114 | |||
115 | /** |
||
116 | * Set the view resources |
||
117 | * |
||
118 | * @param array $viewResources View resources |
||
119 | */ |
||
120 | public static function setViewResources(array $viewResources) |
||
121 | { |
||
122 | self::getServer()->setViewResources($viewResources); |
||
123 | } |
||
124 | |||
125 | /** |
||
126 | * Return view resources |
||
127 | * |
||
128 | * @param string|null $name Optional: view resource name |
||
129 | * @return array View resources |
||
130 | */ |
||
131 | 78 | public static function getViewResources($name = null) |
|
135 | |||
136 | /** |
||
137 | * Reset the server |
||
138 | */ |
||
139 | 1 | public static function reset() |
|
143 | } |
||
144 |