Skip to content

Conversation

@erikn69
Copy link
Contributor

@erikn69 erikn69 commented Mar 9, 2022

Fix dependsOn bug when string is not an asset or when dependency is empty

  • Code fixes
  • Better validation on isJs, isCss, isBonsai
  • Avoid adding same namespace to all files by mistake

    bonsai/src/Assets.php

    Lines 43 to 45 in 466603f

    foreach ($assets as $asset) {
    $this->add($asset, $namespace);
    }
  • Avoid code duplicity on foreachs
    foreach ($assets as $asset) {

    foreach ($assets as $asset => $meta) {

    foreach ($assets as $path => $meta) {
  • Added missing return type on parseBonsai
    * @return Assets

    return;
  • Fix bug in dependsOn when by mistake you Bonsai::add a non asset file like favico.ico and it has dependency with dependsOn, it adds the dependency to the las asset added before favico.ico,
    so if it is not asset clean lastAddedAsset property with $this->lastAddedAsset = '';

    bonsai/src/Assets.php

    Lines 48 to 52 in 466603f

    } elseif ($this->isAsset($assets)) {
    $this->addAsset($assets, $namespace);
    }
    return $this;
  • Support arrays on parseBonsai, now is posible to do this
Bonsai::add(['file1.css', 'file2.css'])
Bonsai::add(['file1.css', 'file2.css' => ['namespace' => 'test']])
Bonsai::add(['file1.css' => null, 'file2.css' => ['namespace' => 'test']])
Bonsai::add(['file1.css' => ['namespace' => 'test'], 'file2.css' => ['dependency' => 'test']])

@kaidesu it works the same, just validations added and it's better now

@erikn69 erikn69 force-pushed the patch-2 branch 5 times, most recently from affd3ef to 5f1e99c Compare March 9, 2022 22:48
@erikn69 erikn69 force-pushed the patch-2 branch 5 times, most recently from ad8ac10 to aba8e79 Compare April 7, 2022 20:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant