1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This is a Anax frontcontroller. |
4
|
|
|
* |
5
|
|
|
*/ |
6
|
|
|
|
7
|
|
|
// Get environment & autoloader. |
8
|
|
|
require __DIR__.'/config.php'; |
9
|
|
|
|
10
|
|
|
|
11
|
|
|
|
12
|
|
|
// Create services and inject into the app. |
13
|
|
|
$di = new \Anax\DI\CDIFactoryDocumentation(); |
14
|
|
|
$app = new \Anax\Kernel\CAnax($di); |
|
|
|
|
15
|
|
|
|
16
|
|
|
//$app->navbar->configure(ANAX_APP_PATH . 'config/navbar_demo.php'); |
17
|
|
|
|
18
|
|
|
// Set title for all pages |
19
|
|
|
$app->theme->setBaseTitle(" - Anax documentation"); |
20
|
|
|
|
21
|
|
|
|
22
|
|
|
|
23
|
|
|
// Valid pages |
24
|
|
|
$pages = [ |
25
|
|
|
'' => ['title' => 'Home', 'file' => 'index.md'], |
26
|
|
|
'http-error-codes' => ['title' => 'Exceptions as HTTP error codes'], |
27
|
|
|
'create-urls' => ['title' => 'Creating urls'], |
28
|
|
|
'create-urls-in-md' => ['title' => 'Creating urls in text or Markdown'], |
29
|
|
|
]; |
30
|
|
|
|
31
|
|
|
|
32
|
|
|
|
33
|
|
|
// Create a default route to catch all |
34
|
|
|
$app->router->add('di', function () use ($app, $di) { |
35
|
|
|
$app->theme->setTitle("Loaded services"); |
36
|
|
|
$app->views->add('helper/services', [ |
37
|
|
|
'di' => $di->getServices(), |
38
|
|
|
]); |
39
|
|
|
}); |
40
|
|
|
|
41
|
|
|
|
42
|
|
|
|
43
|
|
|
// Create a default route to catch all |
44
|
|
|
$app->router->add('*', function () use ($app, $pages) { |
45
|
|
|
|
46
|
|
|
// Get current route |
47
|
|
|
$route = $app->request->getRoute(); |
48
|
|
|
|
49
|
|
|
if (!isset($pages[$route])) { |
50
|
|
|
throw new \Anax\Exception\NotFoundException("The documentation page does not exists."); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
$title = $pages[$route]['title']; |
54
|
|
|
$file = isset($pages[$route]['file']) |
55
|
|
|
? $pages[$route]['file'] |
56
|
|
|
: $route . ".md"; |
57
|
|
|
|
58
|
|
|
$app->theme->setTitle($title); |
59
|
|
|
|
60
|
|
|
$content = $app->documentation->get($file); |
61
|
|
|
$content = $app->textFilter->doFilter($content, 'shortcode, markdown'); |
62
|
|
|
|
63
|
|
|
$app->views->add('default/article', [ |
64
|
|
|
'content' => $content, |
65
|
|
|
]); |
66
|
|
|
|
67
|
|
|
}); |
68
|
|
|
|
69
|
|
|
|
70
|
|
|
|
71
|
|
|
|
72
|
|
|
|
73
|
|
|
|
74
|
|
|
// Check for matching routes and dispatch to controller/handler of route |
75
|
|
|
$app->router->handle(); |
76
|
|
|
|
77
|
|
|
|
78
|
|
|
|
79
|
|
|
// Render the page |
80
|
|
|
$app->theme->render(); |
81
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: