1 | <?php |
||
51 | class Extension extends Twig_Extension implements ExtensionInterface, Twig_Extension_GlobalsInterface |
||
52 | { |
||
53 | /** |
||
54 | * @var ProjectDescriptor |
||
55 | */ |
||
56 | protected $data; |
||
57 | |||
58 | /** @var Renderer */ |
||
59 | protected $routeRenderer; |
||
60 | |||
61 | /** |
||
62 | * Registers the structure and transformation with this extension. |
||
63 | * |
||
64 | * @param ProjectDescriptor $project Represents the complete Abstract Syntax Tree. |
||
65 | * @param Transformation $transformation Represents the transformation meta data used in the current generation |
||
66 | * cycle. |
||
67 | */ |
||
68 | public function __construct(ProjectDescriptor $project, Transformation $transformation) |
||
73 | |||
74 | /** |
||
75 | * Sets the router used to render the URL where a Descriptor can be found. |
||
76 | */ |
||
77 | public function setRouters(Queue $routers): void |
||
81 | |||
82 | /** |
||
83 | * Sets the destination directory relative to the Project's Root. |
||
84 | * |
||
85 | * The destination is the target directory containing the resulting |
||
86 | * file. This destination is relative to the Project's root and can |
||
87 | * be used for the calculation of nesting depths, etc. |
||
88 | * |
||
89 | * @see Writer\Twig for the invocation of this method. |
||
90 | */ |
||
91 | public function setDestination(string $destination): void |
||
95 | |||
96 | /** |
||
97 | * Returns the target directory relative to the Project's Root. |
||
98 | */ |
||
99 | public function getDestination(): string |
||
103 | |||
104 | /** |
||
105 | * Returns an array of global variables to inject into a Twig template. |
||
106 | * |
||
107 | * @return mixed[] |
||
108 | */ |
||
109 | public function getGlobals(): array |
||
115 | |||
116 | /** |
||
117 | * Returns a listing of all functions that this extension adds. |
||
118 | * |
||
119 | * This method is automatically used by Twig upon registering this |
||
120 | * extension (which is done automatically by phpDocumentor) to determine |
||
121 | * an additional list of functions. |
||
122 | * |
||
123 | * See the Class' DocBlock for a listing of functionality added by this |
||
124 | * Extension. |
||
125 | * |
||
126 | * @return Twig_SimpleFunction[] |
||
127 | */ |
||
128 | public function getFunctions(): array |
||
134 | |||
135 | /** |
||
136 | * Returns a list of all filters that are exposed by this extension. |
||
137 | * |
||
138 | * @return Twig_SimpleFilter[] |
||
139 | */ |
||
140 | public function getFilters(): array |
||
195 | |||
196 | /** |
||
197 | * Converts the given path to be relative to the root of the documentation |
||
198 | * target directory. |
||
199 | * |
||
200 | * It is not possible to use absolute paths in documentation templates since |
||
201 | * they may be used locally, or in a subfolder. As such we need to calculate |
||
202 | * the number of levels to go up from the current document's directory and |
||
203 | * then append the given path. |
||
204 | * |
||
205 | * For example: |
||
206 | * |
||
207 | * Suppose you are in <root>/classes/my/class.html and you want open |
||
208 | * <root>/my/index.html then you provide 'my/index.html' to this method |
||
209 | * and it will convert it into ../../my/index.html (<root>/classes/my is |
||
210 | * two nesting levels until the root). |
||
211 | * |
||
212 | * This method does not try to normalize or optimize the paths in order to |
||
213 | * save on development time and performance, and because it adds no real |
||
214 | * value. |
||
215 | */ |
||
216 | public function convertToRootPath(string $relative_path): string |
||
220 | } |
||
221 |