|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
if (false === function_exists('get_artomator_template_file_path')) { |
|
4
|
|
|
/** |
|
5
|
|
|
* get path for template file. |
|
6
|
|
|
* |
|
7
|
|
|
* @param string $templateName |
|
8
|
|
|
* @param string $templateType |
|
9
|
|
|
* |
|
10
|
|
|
* @return string |
|
11
|
|
|
*/ |
|
12
|
|
|
function get_artomator_template_file_path($templateName, $templateType) |
|
13
|
|
|
{ |
|
14
|
|
|
$templateName = str_replace('.', '/', $templateName); |
|
15
|
|
|
|
|
16
|
|
|
$templatesPath = config( |
|
17
|
|
|
'infyom.laravel_generator.path.templates_dir', |
|
18
|
|
|
resource_path('infyom/infyom-generator-templates/') |
|
19
|
|
|
); |
|
20
|
|
|
|
|
21
|
|
|
$path = $templatesPath.$templateName.'.stub'; |
|
22
|
|
|
|
|
23
|
|
|
if (file_exists($path)) { |
|
24
|
|
|
return $path; |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
if (file_exists(base_path('vendor/pwweb/'.$templateType.'/templates/'.$templateName.'.stub'))) { |
|
28
|
|
|
return base_path('vendor/pwweb/'.$templateType.'/templates/'.$templateName.'.stub'); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
return base_path('vendor/infyomlabs/'.$templateType.'/templates/'.$templateName.'.stub'); |
|
32
|
|
|
} |
|
33
|
|
|
}//end if |
|
34
|
|
|
|
|
35
|
|
|
if (false === function_exists('get_artomator_template')) { |
|
36
|
|
|
/** |
|
37
|
|
|
* get template contents. |
|
38
|
|
|
* |
|
39
|
|
|
* @param string $templateName |
|
40
|
|
|
* @param string $templateType |
|
41
|
|
|
* |
|
42
|
|
|
* @return string |
|
43
|
|
|
*/ |
|
44
|
|
|
function get_artomator_template($templateName, $templateType = 'artomator') |
|
45
|
|
|
{ |
|
46
|
|
|
$path = get_artomator_template_file_path($templateName, $templateType); |
|
47
|
|
|
|
|
48
|
|
|
return file_get_contents($path); |
|
49
|
|
|
} |
|
50
|
|
|
}//end if |
|
51
|
|
|
|
|
52
|
|
|
if (false === function_exists('license_authors')) { |
|
53
|
|
|
/** |
|
54
|
|
|
* format authors for codeblock. |
|
55
|
|
|
* |
|
56
|
|
|
* @param string|array $authors |
|
57
|
|
|
* |
|
58
|
|
|
* @return string |
|
59
|
|
|
*/ |
|
60
|
|
|
function license_authors($authors) |
|
61
|
|
|
{ |
|
62
|
|
|
if (true === is_array($authors)) { |
|
63
|
|
|
return implode("\n * @author ", $authors); |
|
64
|
|
|
} else { |
|
65
|
|
|
return $authors; |
|
66
|
|
|
} |
|
67
|
|
|
} |
|
68
|
|
|
}// end if |
|
69
|
|
|
|