diff --git a/src/Assets/Asset.php b/src/Assets/Asset.php index 97a7d2b..3c7149e 100644 --- a/src/Assets/Asset.php +++ b/src/Assets/Asset.php @@ -491,14 +491,19 @@ public function get_condition() { * @return array */ public function get_dependencies(): array { - if ( - $this->is_compiled() - && ! empty( $this->compiled['dependencies'] ) - ) { - return $this->compiled['dependencies']; - } + if ( + $this->is_compiled() + && ! empty( $this->compiled['dependencies'] ) + ) { + return array_unique( + array_merge( + $this->compiled['dependencies'], + $this->dependencies + ) + ); + } - return $this->dependencies; + return $this->dependencies; } /** @@ -1296,6 +1301,25 @@ public function is_compiled(): bool { return ! empty( $this->compiled ); } + /** + * Set the asset as compiled. + * + * @since TBD + * + * @return static + */ + public function set_as_compiled() { + $file = $this->get_root_path() . $this->get_path() . $this->get_file() . '.asset.php'; + + if ( ! file_exists( $file ) ) { + return $this; + } + + $this->compiled = require $file; + + return $this; + } + /** * Set the compiled data for the asset. * @@ -1305,7 +1329,7 @@ public function is_compiled(): bool { * * @return static */ - public function set_compiled_data( string $src ) { + public function set_compiled_path( string $src ) { $file = $this->get_root_path() . $this->get_path() . $src . '.asset.php'; if ( ! file_exists( $file ) ) {