Skip to content

Commit

Permalink
Laravel 8.x and Php 8.0 Support, fixes (#8)
Browse files Browse the repository at this point in the history
* Laravel 8 Support, fixes

* Revert slash in link

* Php 8.0 support

* Reverse Blade Directive 'add'

* Fix PHP8 Required parameter $type follows optional parameter $assets

Co-authored-by: Erik Niebla <[email protected]>
  • Loading branch information
erikn69 and Erik Niebla committed Mar 24, 2021
1 parent 423cc86 commit 466603f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 18 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
}
],
"require": {
"php": "^7.2",
"illuminate/support": "^6.0|^7.0"
"php": "^7.2.5|^8.0",
"illuminate/support": "^6.0|^7.0|^8.0|^9.0"
},
"autoload": {
"psr-4": {
Expand Down
15 changes: 4 additions & 11 deletions src/Assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,6 @@
class Assets
{

/**
* Regex pattern to match Bonsai json files.
*
* @var string
*/
protected $bonsaiRegex = '/bonsai\.json$/i';

/**
* @var Illuminate\Support\Collection
*/
Expand Down Expand Up @@ -50,10 +43,10 @@ public function add($assets, $namespace = null)
foreach ($assets as $asset) {
$this->add($asset, $namespace);
}
} elseif ($this->isAsset($assets)) {
$this->addAsset($assets, $namespace);
} elseif ($this->isBonsai($assets)) {
$this->parseBonsai($assets);
} elseif ($this->isAsset($assets)) {
$this->addAsset($assets, $namespace);
}

return $this;
Expand Down Expand Up @@ -157,7 +150,7 @@ protected function isCss($asset)
*/
protected function isBonsai($asset)
{
return preg_match($this->bonsaiRegex, $asset);
return preg_match('/bonsai\.json$/i', $asset);
}

/**
Expand Down Expand Up @@ -225,7 +218,7 @@ protected function parseBonsai($path)
* @param array $assets
* @return array
*/
protected function sortDependencies($assets = array(), $type)
protected function sortDependencies($assets = array(), $type = null)
{
$dependencyList = array();

Expand Down
6 changes: 1 addition & 5 deletions src/BonsaiServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,8 @@ public function boot()
switch($assetType) {
case "'css'":
return "<?php echo Bonsai::get()->css(); ?>";
break;

case "'js'":
return "<?php echo Bonsai::get()->js(); ?>";
break;

return "<?php echo Bonsai::get()->js(); ?>";
default:
throw new Exception('Invalid asset type declared. Must be either "css" or "js".');
}
Expand Down

0 comments on commit 466603f

Please sign in to comment.