Skip to content

Commit

Permalink
Fixed bug in Loader that was causing bundled items to be enqueued whe…
Browse files Browse the repository at this point in the history
…n calling enqueue_original_files. Also allowing explicit setting of bundle key for handling dependencies on bundle.

git-svn-id: https://git.crowdfave.org/svn/crowdfavorite/code/wp-plugins/asset-build-script/trunk@38490 546ca710-db30-0410-8887-d9dd8e66aff0
  • Loading branch information
gbrander committed Aug 2, 2011
1 parent a537287 commit 946b888
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
20 changes: 18 additions & 2 deletions lib/Bundler.php
Expand Up @@ -77,6 +77,7 @@ public function get_full_path($my_path_suffix) {
}

class Bundle {
protected $bundle_key = null;
protected $output_path;
protected $bundle_items = array();
protected $meta = array();
Expand All @@ -90,12 +91,27 @@ public function add($bundle_item_key, $my_path) {
return $this;
}

public function get_bundle_key() {
/**
* Best to use this after configuring the bundle
*/
protected function manufacture_bundle_key() {
$keys = array();
foreach($this->bundle_items as $bundle_item) {
$key[]=$bundle_item->get_key();
}
return implode('-', $key);
return 'bundle-'.implode('-', $key);
}

public function set_bundle_key($key) {
$this->bundle_key = (string) $key;
return $this;
}

public function get_bundle_key() {
if (!$this->bundle_key) {
$this->bundle_key = $this->manufacture_bundle_key();
}
return $this->bundle_key;
}

public function get_bundle_items() {
Expand Down
4 changes: 2 additions & 2 deletions lib/Bundler_Loader.php
Expand Up @@ -68,8 +68,8 @@ public function enqueue_original_files() {
foreach($bundle->get_bundle_items() as $bundle_item) {
$this->enqueue(
$bundle->get_language(),
$bundle->get_bundle_key(),
$this->asset_url_prefix . $bundle->get_bundled_path(),
$bundle_item->get_key(),
$this->asset_url_prefix . $bundle_item->get_path(),
$bundle->get_meta('dependencies'),
$bundle->get_meta('ver')
);
Expand Down

0 comments on commit 946b888

Please sign in to comment.