diff --git a/lib/Bundler.php b/lib/Bundler.php index ad331dd..aa5581c 100644 --- a/lib/Bundler.php +++ b/lib/Bundler.php @@ -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(); @@ -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() { diff --git a/lib/Bundler_Loader.php b/lib/Bundler_Loader.php index a4cd5b4..98f1f8b 100644 --- a/lib/Bundler_Loader.php +++ b/lib/Bundler_Loader.php @@ -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') );