Skip to content

Commit

Permalink
Stellar - Add set_as_compiled() to automatically get the compiled assets
Browse files Browse the repository at this point in the history
  • Loading branch information
jesseeproductions committed Apr 16, 2024
1 parent 4839b59 commit a80e7bc
Showing 1 changed file with 32 additions and 8 deletions.
40 changes: 32 additions & 8 deletions src/Assets/Asset.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down Expand Up @@ -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.
*
Expand All @@ -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 ) ) {
Expand Down

0 comments on commit a80e7bc

Please sign in to comment.