-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathViewGenerator.php
108 lines (94 loc) · 1.94 KB
/
ViewGenerator.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<?php
namespace Pingpong\Generators;
class ViewGenerator extends Generator
{
/**
* Get stub name.
*
* @var string
*/
protected $stub = 'view';
/**
* The array of custom replacements.
*
* @var array
*/
protected $customReplacements = [];
/**
* Setup.
*/
public function setUp()
{
if ($this->master) {
$this->stub = 'views/master';
}
}
/**
* Get base path of destination file.
*
* @return string
*/
public function getBasePath()
{
return base_path().'/resources/views/';
}
/**
* Get destination path for generated file.
*
* @return string
*/
public function getPath()
{
return $this->getBasePath().strtolower($this->getName()).'.blade.php';
}
/**
* Get stub template for generated file.
*
* @return string
*/
public function getStub()
{
if ($this->plain) {
return $this->getPath();
}
if ($template = $this->template) {
return Stub::create($template, $this->getReplacements())->render();
}
return parent::getStub();
}
/**
* Get root namespace.
*
* @return string
*/
public function getRootNamespace()
{
return '';
}
/**
* Get template replacements.
*
* @return array
*/
public function getReplacements()
{
$replaces = [
'extends' => $this->extends,
'section' => $this->section,
'content' => $this->content,
];
return $this->customReplacements + $replaces;
}
/**
* Append a custom replacements to this instance.
*
* @param array $replacements
*
* @return self
*/
public function appendReplacement(array $replacements)
{
$this->customReplacements = $replacements;
return $this;
}
}