1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* Copyright (C) 2019 Mazarini <[email protected]>. |
5
|
|
|
* This file is part of mazarini/design. |
6
|
|
|
* |
7
|
|
|
* mazarini/design is free software: you can redistribute it and/or |
8
|
|
|
* modify it under the terms of the GNU General Public License as published by |
9
|
|
|
* the Free Software Foundation, either version 3 of the License, or (at your |
10
|
|
|
* option) any later version. |
11
|
|
|
* |
12
|
|
|
* mazarini/design is distributed in the hope that it will be useful, |
13
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
14
|
|
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
15
|
|
|
* more details. |
16
|
|
|
* |
17
|
|
|
* You should have received a copy of the GNU General Public License |
18
|
|
|
*/ |
19
|
|
|
|
20
|
|
|
namespace Mazarini\DesignBundle\Tools; |
21
|
|
|
|
22
|
|
|
class Folder |
23
|
|
|
{ |
24
|
|
|
private $layout; |
25
|
|
|
private $stepRoot; |
26
|
|
|
|
27
|
4 |
|
public function __construct(string $projectRoot) |
28
|
|
|
{ |
29
|
4 |
|
$this->layout = $projectRoot.'/templates/layout.html.twig'; |
30
|
4 |
|
$this->stepRoot = \dirname(__DIR__).'/Resources/views/steps'; |
31
|
4 |
|
} |
32
|
|
|
|
33
|
3 |
|
public function getLayout(): string |
34
|
|
|
{ |
35
|
3 |
|
return $this->layout; |
36
|
|
|
} |
37
|
|
|
|
38
|
1 |
|
public function getStepRoot(): string |
39
|
|
|
{ |
40
|
1 |
|
return $this->stepRoot; |
41
|
|
|
} |
42
|
|
|
|
43
|
2 |
|
public function hasLayout(): bool |
44
|
|
|
{ |
45
|
2 |
|
return file_exists($this->getLayout()); |
46
|
|
|
} |
47
|
|
|
|
48
|
1 |
|
public function getSteps(): array |
49
|
|
|
{ |
50
|
1 |
|
$dirs = glob($this->stepRoot.'/??-*'); |
51
|
1 |
|
$steps = []; |
52
|
1 |
|
if (\is_array($dirs)) { |
53
|
1 |
|
foreach ($dirs as $dir) { |
54
|
1 |
|
$step = basename($dir); |
55
|
1 |
|
$steps[$step] = mb_substr($step, 3); |
56
|
|
|
} |
57
|
|
|
} |
58
|
|
|
|
59
|
1 |
|
return $steps; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
public function getPages(string $step): array |
63
|
|
|
{ |
64
|
|
|
$dirs = glob($this->stepRoot.'/'.$step.'/??-*\.html\.twig'); |
65
|
|
|
$pages = []; |
66
|
|
|
if (\is_array($dirs)) { |
67
|
|
|
foreach ($dirs as $dir) { |
68
|
|
|
$pages[basename($dir)] = mb_substr(basename($dir, '.html.twig'), 3); |
69
|
|
|
} |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
return $pages; |
73
|
|
|
} |
74
|
|
|
} |
75
|
|
|
|