Skip to content

Commit c257f9f

Browse files
Support for templates from other vendors (#886)
* fix(templates): #882 support for templates from other vendors * Apply fixes from StyleCI (#885) Co-authored-by: Mitul Golakiya <[email protected]> Co-authored-by: Mitul Golakiya <[email protected]>
1 parent 63d397e commit c257f9f

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

src/Commands/Publish/PublishTemplateCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function publishScaffoldTemplates()
5555
{
5656
$templateType = config('infyom.laravel_generator.templates', 'adminlte-templates');
5757

58-
$templatesPath = base_path('vendor/infyomlabs/'.$templateType.'/templates/scaffold');
58+
$templatesPath = get_templates_package_path($templateType).'/templates/scaffold';
5959

6060
return $this->publishDirectory($templatesPath, $this->templatesDir.'scaffold', 'infyom-generator-templates/scaffold', true);
6161
}

src/helpers.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,25 @@ function get_template_file_path($templateName, $templateType)
100100
return $path;
101101
}
102102

103-
return base_path('vendor/infyomlabs/'.$templateType.'/templates/'.$templateName.'.stub');
103+
return get_templates_package_path($templateType).'/templates/'.$templateName.'.stub';
104+
}
105+
}
106+
107+
if (!function_exists('get_templates_package_path')) {
108+
/**
109+
* Finds templates package's full path.
110+
*
111+
* @param string $templateType
112+
*
113+
* @return string
114+
*/
115+
function get_templates_package_path($templateType)
116+
{
117+
if (strpos($templateType, '/') === false) {
118+
$templateType = base_path('vendor/infyomlabs/').$templateType;
119+
}
120+
121+
return $templateType;
104122
}
105123
}
106124

0 commit comments

Comments
 (0)