1 | <?php |
||
21 | class Stitcher |
||
22 | { |
||
23 | /** |
||
24 | * @var string |
||
25 | */ |
||
26 | private $srcDir; |
||
27 | |||
28 | /** |
||
29 | * @var string |
||
30 | */ |
||
31 | private $publicDir; |
||
32 | |||
33 | /** |
||
34 | * @var string |
||
35 | */ |
||
36 | private $templateDir; |
||
37 | |||
38 | /** |
||
39 | * @var array |
||
40 | */ |
||
41 | private $cdn; |
||
42 | |||
43 | /** |
||
44 | * @var bool |
||
45 | */ |
||
46 | private $cdnCache; |
||
47 | |||
48 | /** |
||
49 | * @var SiteParser |
||
50 | */ |
||
51 | private $siteParser; |
||
52 | |||
53 | /** |
||
54 | * @var Htaccess |
||
55 | */ |
||
56 | private $htaccess; |
||
57 | |||
58 | /** |
||
59 | * @param string $srcDir |
||
60 | * @param string $publicDir |
||
61 | * @param string $templateDir |
||
62 | * @param array $cdn |
||
63 | * @param bool $cdnCache |
||
64 | * @param SiteParser $siteParser |
||
65 | * @param Htaccess $htaccess |
||
66 | */ |
||
67 | public function __construct( |
||
84 | |||
85 | /** |
||
86 | * The core stitcher function. This function will compile the configured site and return an array of parsed |
||
87 | * data. |
||
88 | * |
||
89 | * Compiling a site is done in the following steps. |
||
90 | * |
||
91 | * - Load the site configuration @see \Brendt\Stitcher\Stitcher::loadSite() |
||
92 | * - Load all available templates @see \Brendt\Stitcher\Stitcher::loadTemplates() |
||
93 | * - Loop over all pages and transform every page with the configured adapters (in any are set) @see |
||
94 | * \Brendt\Stitcher\Stitcher::parseAdapters() |
||
95 | * - Loop over all transformed pages and parse the variables which weren't parsed by the page's adapters. @see |
||
96 | * \Brendt\Stitcher\Stitcher::parseVariables() |
||
97 | * - Add all variables to the template engine and render the HTML for each page. |
||
98 | * |
||
99 | * This function takes two optional parameters which are used to render pages on the fly when using the |
||
100 | * developer controller. The first one, `routes` will take a string or array of routes which should be rendered, |
||
101 | * instead of all available routes. The second one, `filterValue` is used to provide a filter when the |
||
102 | * CollectionAdapter is used, and only one entry page should be rendered. |
||
103 | * |
||
104 | * @param string|array $routes |
||
105 | * @param string $filterValue |
||
106 | * |
||
107 | * @return array |
||
108 | * @throws TemplateNotFoundException |
||
109 | * |
||
110 | * @see \Brendt\Stitcher\Stitcher::save() |
||
111 | * @see \Brendt\Stitcher\Application\DevController::run() |
||
112 | * @see \Brendt\Stitcher\Adapter\CollectionAdapter::transform() |
||
113 | */ |
||
114 | public function stitch($routes = [], string $filterValue = null) : array { |
||
123 | |||
124 | /** |
||
125 | * @param array $routes |
||
126 | * |
||
127 | * @return Site |
||
128 | */ |
||
129 | public function loadSite(array $routes = []) : Site { |
||
132 | |||
133 | /** |
||
134 | * This function will save a stitched output to HTML files in the `directories.public` directory. |
||
135 | * |
||
136 | * @param array $blanket |
||
137 | * |
||
138 | * @see \Brendt\Stitcher\Stitcher::stitch() |
||
139 | */ |
||
140 | public function save(array $blanket) { |
||
153 | |||
154 | /** |
||
155 | * Parse CDN resources and libraries |
||
156 | */ |
||
157 | public function prepareCdn() { |
||
176 | } |
||
177 | |||
179 |