|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Maestriam\Samurai\Entities; |
|
4
|
|
|
|
|
5
|
|
|
use Maestriam\FileSystem\Support\FileSystem; |
|
6
|
|
|
|
|
7
|
|
|
class Structure extends Foundation |
|
8
|
|
|
{ |
|
9
|
|
|
/** |
|
10
|
|
|
* Nome do distribuido do tema |
|
11
|
|
|
*/ |
|
12
|
|
|
private string $dist; |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* Nome do tema |
|
16
|
|
|
*/ |
|
17
|
|
|
private string $theme; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* Gerencia os caminhos do tema |
|
21
|
|
|
* |
|
22
|
|
|
* @param Vendor $vendor |
|
23
|
|
|
*/ |
|
24
|
|
|
public function __construct(Vendor $vendor) |
|
25
|
|
|
{ |
|
26
|
|
|
$this->loadVendor($vendor); |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* Retorna o caminho público do projeto |
|
31
|
|
|
* onde os assets do projeto são armazenados |
|
32
|
|
|
* |
|
33
|
|
|
* @return string |
|
34
|
|
|
*/ |
|
35
|
|
|
public function public() : string |
|
36
|
|
|
{ |
|
37
|
|
|
return $this->dir()->public($this->dist, $this->theme); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* Retorna o caminho do diretório onde são armazenados |
|
42
|
|
|
* os arquivos de assets (js/css/imgs) |
|
43
|
|
|
* |
|
44
|
|
|
* @return string |
|
45
|
|
|
*/ |
|
46
|
|
|
public function assets() : string |
|
47
|
|
|
{ |
|
48
|
|
|
return $this->dir()->assets($this->dist, $this->theme); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* Retorna o caminho do diretório onde são armazenados |
|
53
|
|
|
* os arquivos de diretivas (include/component) |
|
54
|
|
|
* |
|
55
|
|
|
* @return string |
|
56
|
|
|
*/ |
|
57
|
|
|
public function source() : string |
|
58
|
|
|
{ |
|
59
|
|
|
return $this->dir()->files($this->dist, $this->theme); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* Retorna o caminho-raiz do tema |
|
64
|
|
|
* |
|
65
|
|
|
* @return string |
|
66
|
|
|
*/ |
|
67
|
|
|
public function root() : string |
|
68
|
|
|
{ |
|
69
|
|
|
return $this->dir()->theme($this->dist, $this->theme); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* Executa a criação dos diretórios principais do tema |
|
74
|
|
|
* |
|
75
|
|
|
* @return void |
|
76
|
|
|
*/ |
|
77
|
|
|
public function init() |
|
78
|
|
|
{ |
|
79
|
|
|
FileSystem::folder($this->source())->create(); |
|
80
|
|
|
FileSystem::folder($this->assets())->create(); |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* Carrega as informações do vendor para gerar os caminhos |
|
85
|
|
|
* do tema específicado |
|
86
|
|
|
* |
|
87
|
|
|
* @param Vendor $vendor |
|
88
|
|
|
* @return Structure |
|
89
|
|
|
*/ |
|
90
|
|
|
private function loadVendor(Vendor $vendor) : Structure |
|
91
|
|
|
{ |
|
92
|
|
|
$this->dist = $vendor->distributor(); |
|
93
|
|
|
|
|
94
|
|
|
$this->theme = $vendor->name(); |
|
95
|
|
|
|
|
96
|
|
|
return $this; |
|
97
|
|
|
} |
|
98
|
|
|
} |
|
99
|
|
|
|