Skip to content

Commit ebf7b1d

Browse files
authored
Merge pull request #41 from jpagny/fix-bug
Fix symlink, title_case bugs
2 parents 42ffe52 + 2ff1ad9 commit ebf7b1d

File tree

3 files changed

+18
-14
lines changed

3 files changed

+18
-14
lines changed

src/Console/ThemeGeneratorCommand.php

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Illuminate\Config\Repository;
66
use Illuminate\Console\Command;
77
use Illuminate\Filesystem\Filesystem as File;
8+
use Illuminate\Support\Str;
89

910
class ThemeGeneratorCommand extends Command
1011
{
@@ -89,10 +90,11 @@ public function handle()
8990
$this->themePath = $this->config->get('theme.theme_path');
9091
$this->theme['name'] = strtolower($this->argument('name'));
9192

92-
if(empty($this->theme['name'])) {
93+
if (empty($this->theme['name'])) {
9394
$this->theme['name'] = $this->ask('What is your theme name?');
94-
if(empty($this->theme['name'])) {
95-
$this->error("Theme is not Generated, Theme name required !!!");
95+
if (empty($this->theme['name'])) {
96+
$this->error('Theme is not Generated, Theme name required !!!');
97+
9698
return;
9799
}
98100
}
@@ -101,7 +103,7 @@ public function handle()
101103
}
102104

103105
/**
104-
* Theme Initialize
106+
* Theme Initialize.
105107
*
106108
* @return void
107109
*/
@@ -143,10 +145,10 @@ public function consoleAsk()
143145
$this->theme['title'] = $this->ask('What is theme title?');
144146

145147
$this->theme['description'] = $this->ask('What is theme description?', false);
146-
$this->theme['description'] = !$this->theme['description'] ? '' : title_case($this->theme['description']);
148+
$this->theme['description'] = !$this->theme['description'] ? '' : Str::title($this->theme['description']);
147149

148150
$this->theme['author'] = $this->ask('What is theme author name?', false);
149-
$this->theme['author'] = !$this->theme['author'] ? '' : title_case($this->theme['author']);
151+
$this->theme['author'] = !$this->theme['author'] ? '' : Str::title($this->theme['author']);
150152

151153
$this->theme['version'] = $this->ask('What is theme version?', false);
152154
$this->theme['version'] = !$this->theme['version'] ? '1.0.0' : $this->theme['version'];
@@ -174,8 +176,10 @@ public function createStubs($themeStubFiles, $createdThemePath)
174176
} elseif ($filename == 'theme') {
175177
$filename = pathinfo($storePath, PATHINFO_EXTENSION);
176178
} elseif ($filename == 'css' || $filename == 'js') {
177-
$this->theme[$filename] = ltrim($storePath,
178-
rtrim($this->config->get('theme.folders.assets'), '/').'/');
179+
$this->theme[$filename] = ltrim(
180+
$storePath,
181+
rtrim($this->config->get('theme.folders.assets'), '/').'/'
182+
);
179183
}
180184
$themeStubFile = $this->themeStubPath.'/'.$filename.'.stub';
181185
$this->makeFile($themeStubFile, $createdThemePath.'/'.$storePath);

src/Managers/Theme.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -203,17 +203,17 @@ public function getFullPath($path)
203203

204204
$themeInfo = $this->getThemeInfo($themeName);
205205

206-
if ( $this->config[ 'theme.symlink' ] ) {
207-
$themePath = 'Themes'. DIRECTORY_SEPARATOR . $themeName . DIRECTORY_SEPARATOR;
206+
if ($this->config['theme.symlink']) {
207+
$themePath = str_replace(base_path('public').DIRECTORY_SEPARATOR, '', $this->config['theme.symlink_path']).DIRECTORY_SEPARATOR.$themeName.DIRECTORY_SEPARATOR;
208208
} else {
209-
$themePath = str_replace(base_path('public') . DIRECTORY_SEPARATOR, '', $themeInfo->get('path')) . DIRECTORY_SEPARATOR;
209+
$themePath = str_replace(base_path('public').DIRECTORY_SEPARATOR, '', $themeInfo->get('path')).DIRECTORY_SEPARATOR;
210210
}
211211

212212
$assetPath = $this->config['theme.folders.assets'].DIRECTORY_SEPARATOR;
213213
$fullPath = $themePath.$assetPath.$path;
214214

215215
if (!file_exists($fullPath) && $themeInfo->has('parent') && !empty($themeInfo->get('parent'))) {
216-
$themePath = str_replace(base_path().DIRECTORY_SEPARATOR, '', $this->getThemeInfo($themeInfo->get('parent'))->get('path') ).DIRECTORY_SEPARATOR;
216+
$themePath = str_replace(base_path().DIRECTORY_SEPARATOR, '', $this->getThemeInfo($themeInfo->get('parent'))->get('path')).DIRECTORY_SEPARATOR;
217217
$fullPath = $themePath.$assetPath.$path;
218218

219219
return $fullPath;
@@ -226,7 +226,7 @@ public function getFullPath($path)
226226
* Get the current theme path to a versioned Mix file.
227227
*
228228
* @param string $path
229-
* @param string $manifestDirectory
229+
* @param string $manifestDirectory
230230
*
231231
* @return \Illuminate\Support\HtmlString|string
232232
*/

src/Providers/ThemevelServiceProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class ThemevelServiceProvider extends ServiceProvider
1818
*/
1919
public function boot()
2020
{
21-
if (!File::exists(public_path('Themes')) && config('theme.symlink') && File::exists(config('theme.theme_path'))) {
21+
if (!File::exists(public_path('Themes')) && !File::exists(config('theme.symlink_path')) && config('theme.symlink') && File::exists(config('theme.theme_path'))) {
2222
App::make('files')->link(config('theme.theme_path'), config('theme.symlink_path', public_path('Themes')));
2323
}
2424
}

0 commit comments

Comments
 (0)