forked from Gregwar/RST
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Kernel.php
86 lines (74 loc) · 1.65 KB
/
Kernel.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php
namespace Gregwar\RST;
use Gregwar\RST\Builder;
use Gregwar\RST\Document;
abstract class Kernel
{
/**
* Get the name of the kernel
*/
abstract function getName();
/**
* Gets the class for the given name
*/
public function getClass($name)
{
return 'Gregwar\RST\\'.$this->getName().'\\'.$name;
}
/**
* Create an instance of some class
*/
public function build($name, $arg1 = null, $arg2 = null, $arg3 = null, $arg4 = null)
{
$class = $this->getClass($name);
if ($class) {
return new $class($arg1, $arg2, $arg3, $arg4);
}
return null;
}
/**
* Gets the available directives
*/
public function getDirectives()
{
return array(
new Directives\Dummy,
new Directives\Code,
new Directives\CodeBlock,
new Directives\Raw,
new Directives\Replace,
new Directives\Toctree,
new Directives\Document,
new Directives\RedirectionTitle,
);
}
/**
* Document references
*/
public function getReferences()
{
return array(
new References\Doc,
new References\Doc('ref'),
);
}
/**
* Allowing the kernel to tweak document after the build
*/
public function postParse(Document $document)
{
}
/**
* Allowing the kernel to tweak the builder
*/
public function initBuilder(Builder $builder)
{
}
/**
* Get the output files extension
*/
public function getFileExtension()
{
return 'txt';
}
}