Skip to content
Snippets Groups Projects
Verified Commit 46c06d49 authored by Bartek Jaskulski's avatar Bartek Jaskulski
Browse files

refactor: use cache, only if previously built

parent 0dbe359a
No related branches found
No related tags found
2 merge requests!3improve into wp-hook and some additional unfinished things,!21.x
...@@ -86,12 +86,14 @@ final class Kernel { ...@@ -86,12 +86,14 @@ final class Kernel {
private function initialize_container( Plugin $plugin ): Container { private function initialize_container( Plugin $plugin ): Container {
$original_builder = new DiBuilder(); $original_builder = new DiBuilder();
// If there's a cache file, use it as we are in production environment.
// Otherwise, build the container from scratch and use live version, without compilation.
if ( file_exists( $this->get_cache_path( $this->get_container_name( $plugin ) . '.php' ) ) ) {
$original_builder->enableCompilation( $original_builder->enableCompilation(
$this->get_cache_path(), $this->get_cache_path(),
$this->get_container_name( $plugin ) $this->get_container_name( $plugin )
); );
if ( file_exists( $this->get_cache_path( $this->get_container_name( $plugin ) . '.php' ) ) ) {
return $original_builder->build(); return $original_builder->build();
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment