Skip to content

Commit ec2f7ea

Browse files
Merge pull request #24 from hexadog/develop
feat(asset): add version hash to assets url
2 parents d1e2f03 + ea1feb4 commit ec2f7ea

29 files changed

+407
-556
lines changed

.github/workflows/php-cs-fixer.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ jobs:
1515
ref: ${{ github.head_ref }}
1616

1717
- name: Run php-cs-fixer
18-
uses: docker://oskarstark/php-cs-fixer-ga
18+
uses: docker://oskarstark/php-cs-fixer-ga:3.0.0
1919
with:
20-
args: --config=.php_cs.dist --allow-risky=yes
20+
args: --config=.php-cs-fixer.dist.php --allow-risky=yes
2121

2222
- name: Commit changes
2323
uses: stefanzweifel/git-auto-commit-action@v4.10.0

.php-cs-fixer.dist.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
$finder = PhpCsFixer\Finder::create()
4+
->notPath('vendor/*')
5+
->notPath('resources/*')
6+
->notPath('database/*')
7+
->notPath('storage/*')
8+
->notPath('node_modules/*')
9+
->in([
10+
__DIR__ . '/config',
11+
__DIR__ . '/src',
12+
])
13+
->name('*.php')
14+
->notName('*.blade.php')
15+
->ignoreDotFiles(true)
16+
->ignoreVCS(true);
17+
18+
$config = new PhpCsFixer\Config();
19+
return $config
20+
->setRules([
21+
'@PSR2' => true,
22+
'@PhpCsFixer' => true,
23+
])
24+
->setFinder($finder);

.php_cs.dist

Lines changed: 0 additions & 45 deletions
This file was deleted.

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"illuminate/view": "^7.0|^8.0"
1717
},
1818
"require-dev": {
19-
"friendsofphp/php-cs-fixer": "^2.18",
19+
"friendsofphp/php-cs-fixer": "^2.19",
2020
"squizlabs/php_codesniffer": "3.*",
2121
"phpunit/phpunit": "^7.0|^8.0|^9.0",
2222
"orchestra/testbench": "~5.2"

helpers/helpers.php

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -3,46 +3,46 @@
33
use Illuminate\Support\Facades\View;
44

55
if (!function_exists('page_title')) {
6-
/**
7-
* Get formatted page title
8-
*
9-
* @param bool $with_app_name
10-
* @param string $separator
11-
* @return string
12-
*/
13-
function page_title(string $title, bool $withAppName = true, $separator = '-', $invert = false): string
14-
{
15-
if (View::hasSection('title')) {
16-
$title = View::getSection('title');
17-
}
6+
/**
7+
* Get formatted page title
8+
*
9+
* @param bool $with_app_name
10+
* @param string $separator
11+
* @return string
12+
*/
13+
function page_title(string $title, bool $withAppName = true, $separator = '-', $invert = false): string
14+
{
15+
if (View::hasSection('title')) {
16+
$title = View::getSection('title');
17+
}
1818

19-
if (!empty($title) && $withAppName) {
20-
if ($invert) {
21-
return $title . " " . trim(e($separator)) . " " . config('app.name');
22-
} else {
23-
return config('app.name') . " " . trim(e($separator)) . " " . $title;
24-
}
25-
} else {
26-
return config('app.name');
27-
}
28-
}
19+
if (!empty($title) && $withAppName) {
20+
if ($invert) {
21+
return $title . " " . trim(e($separator)) . " " . config('app.name');
22+
} else {
23+
return config('app.name') . " " . trim(e($separator)) . " " . $title;
24+
}
25+
} else {
26+
return config('app.name');
27+
}
28+
}
2929
}
3030

3131
if (!function_exists('theme')) {
32-
/**
33-
* Set theme.
34-
*
35-
* @param string $themeName
36-
* @return \Hexadog\ThemesManager\Theme
37-
*/
38-
function theme($themeName = null)
39-
{
40-
if ($themeName) {
41-
\Theme::set($themeName);
42-
}
43-
44-
return \Theme::current();
45-
}
32+
/**
33+
* Set theme.
34+
*
35+
* @param string $themeName
36+
* @return \Hexadog\ThemesManager\Theme
37+
*/
38+
function theme($themeName = null)
39+
{
40+
if ($themeName) {
41+
\Theme::set($themeName);
42+
}
43+
44+
return \Theme::current();
45+
}
4646
}
4747

4848
if (!function_exists('theme_asset')) {
@@ -53,9 +53,9 @@ function theme($themeName = null)
5353
* @param bool $absolutePath
5454
* @return string
5555
*/
56-
function theme_asset(string $asset, $absolutePath = true)
56+
function theme_asset(string $asset, $absolutePath = true, bool $version = true)
5757
{
58-
return \Theme::url($asset, $absolutePath);
58+
return \Theme::url($asset, $absolutePath, $version);
5959
}
6060
}
6161

@@ -67,9 +67,9 @@ function theme_asset(string $asset, $absolutePath = true)
6767
* @param bool $absolutePath
6868
* @return string
6969
*/
70-
function theme_style(string $asset, $absolutePath = true)
70+
function theme_style(string $asset, $absolutePath = true, bool $version = true)
7171
{
72-
return \Theme::style($asset, $absolutePath);
72+
return \Theme::style($asset, $absolutePath, $version);
7373
}
7474
}
7575

@@ -84,9 +84,9 @@ function theme_style(string $asset, $absolutePath = true)
8484
* @param string $level
8585
* @return string
8686
*/
87-
function theme_script(string $asset, string $mode = '', $absolutePath = true, string $type = 'text/javascript', string $level = 'functionality')
87+
function theme_script(string $asset, string $mode = '', $absolutePath = true, string $type = 'text/javascript', string $level = 'functionality', bool $version = true)
8888
{
89-
return \Theme::script($asset, $mode, $absolutePath, $type, $level);
89+
return \Theme::script($asset, $mode, $absolutePath, $type, $level, $version);
9090
}
9191
}
9292

@@ -98,8 +98,8 @@ function theme_script(string $asset, string $mode = '', $absolutePath = true, st
9898
* @param string $asset
9999
* @return string
100100
*/
101-
function theme_image(string $asset, string $alt = '', string $class = '', array $attributes = [], $absolutePath = true)
101+
function theme_image(string $asset, string $alt = '', string $class = '', array $attributes = [], $absolutePath = true, bool $version = true)
102102
{
103-
return \Theme::image($asset, $alt, $class, $attributes, $absolutePath);
103+
return \Theme::image($asset, $alt, $class, $attributes, $absolutePath, $version);
104104
}
105105
}

src/Components/Image.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ class Image extends Component
1717
/**
1818
* Create the component instance.
1919
*
20-
* @param string $type
21-
* @param string $message
22-
* @return void
20+
* @param string $type
21+
* @param string $message
22+
* @param mixed $src
23+
* @param mixed $absolutePath
2324
*/
2425
public function __construct($src, $absolutePath = true)
2526
{

src/Components/PageTitle.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,24 @@ class PageTitle extends Component
1717
/**
1818
* Create the component instance.
1919
*
20-
* @param string $type
21-
* @param string $message
22-
* @return void
20+
* @param string $type
21+
* @param string $message
22+
* @param null|mixed $title
23+
* @param mixed $withAppName
24+
* @param mixed $separator
25+
* @param mixed $invert
2326
*/
2427
public function __construct($title = null, $withAppName = true, $separator = '-', $invert = false)
2528
{
2629
if (View::hasSection('title')) {
2730
$title = View::getSection('title');
2831
}
2932

30-
if (! empty($title) && $withAppName) {
33+
if (!empty($title) && $withAppName) {
3134
if ($invert) {
32-
$this->title = $title . " " . trim(e($separator)) . " " . config('app.name');
35+
$this->title = $title.' '.trim(e($separator)).' '.config('app.name');
3336
} else {
34-
$this->title = config('app.name') . " " . trim(e($separator)) . " " . $title;
37+
$this->title = config('app.name').' '.trim(e($separator)).' '.$title;
3538
}
3639
} else {
3740
$this->title = config('app.name');

src/Components/Script.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,14 @@ class Script extends Component
1717
/**
1818
* Create the component instance.
1919
*
20-
* @param string $type
21-
* @param string $message
22-
* @return void
20+
* @param string $type
21+
* @param string $message
22+
* @param null|mixed $src
23+
* @param mixed $absolutePath
2324
*/
2425
public function __construct($src = null, $absolutePath = true)
2526
{
26-
if (! is_null($src)) {
27+
if (!is_null($src)) {
2728
$this->source = ThemesManager::asset($src, $absolutePath);
2829
} else {
2930
$this->source = null;

src/Components/Style.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,14 @@ class Style extends Component
1717
/**
1818
* Create the component instance.
1919
*
20-
* @param string $type
21-
* @param string $message
22-
* @return void
20+
* @param string $type
21+
* @param string $message
22+
* @param mixed $src
23+
* @param mixed $absolutePath
2324
*/
2425
public function __construct($src, $absolutePath = true)
2526
{
26-
if (! is_null($src)) {
27+
if (!is_null($src)) {
2728
$this->source = ThemesManager::asset($src, $absolutePath);
2829
} else {
2930
$this->source = null;

src/Console/Commands/AbstractCommand.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ protected function validateName()
2121
$name = $this->argument('name');
2222

2323
$this->theme = \Theme::get($name);
24-
if (! $this->theme) {
25-
$this->error("Theme with name ${name} does not exists!");
24+
if (!$this->theme) {
25+
$this->error("Theme with name {$name} does not exists!");
26+
2627
exit();
2728
}
2829
}

src/Console/Commands/ActivateTheme.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,14 @@ class ActivateTheme extends AbstractCommand
2020

2121
/**
2222
* Create a new command instance.
23-
*
24-
* @return void
2523
*/
2624
public function __construct()
2725
{
2826
parent::__construct();
2927
}
3028

3129
/**
32-
* Prompt for module's alias name
33-
*
30+
* Prompt for module's alias name.
3431
*/
3532
public function handle()
3633
{

src/Console/Commands/Cache.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,21 @@ class Cache extends AbstractCommand
2222

2323
/**
2424
* Create a new command instance.
25-
*
26-
* @return void
2725
*/
2826
public function __construct()
2927
{
3028
parent::__construct();
3129
}
3230

3331
/**
34-
* Prompt for module's alias name
35-
*
32+
* Prompt for module's alias name.
3633
*/
3734
public function handle()
3835
{
3936
if (ThemesManager::buildCache()) {
4037
$this->sectionMessage('Themes Manager', 'Themes cache created succefully');
4138
} else {
42-
$this->error("An error occured while creating themes cache");
39+
$this->error('An error occured while creating themes cache');
4340
}
4441
}
4542
}

src/Console/Commands/ClearCache.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,21 @@ class ClearCache extends AbstractCommand
2222

2323
/**
2424
* Create a new command instance.
25-
*
26-
* @return void
2725
*/
2826
public function __construct()
2927
{
3028
parent::__construct();
3129
}
3230

3331
/**
34-
* Prompt for module's alias name
35-
*
32+
* Prompt for module's alias name.
3633
*/
3734
public function handle()
3835
{
3936
if (ThemesManager::clearCache()) {
4037
$this->sectionMessage('Themes Manager', 'Themes cache cleared succefully');
4138
} else {
42-
$this->error("An error occured while clearing themes cache");
39+
$this->error('An error occured while clearing themes cache');
4340
}
4441
}
4542
}

0 commit comments

Comments
 (0)