container = $container; } /** * Activation hook. * * @since 0.1.0 * * @return void */ public function __invoke(): void { $this->advanced_cache_dropin_init(); $this->cache_directory_init(); $this->wp_cache_init(); $this->initialize_settings(); } /** * Ensure that the advanced-cache.php drop-in is copied into place. * * @since 0.1.0 * * @return void */ private function advanced_cache_dropin_init(): void { $this->container->get( Advanced_Cache::class )->generate(); } /** * Ensure that the cache directory exists. * * @since 0.1.0 * * @return void */ private function cache_directory_init(): void { if ( ! is_dir( swpsp_config_get( 'page_cache.cache_dir' ) ) ) { wp_mkdir_p( swpsp_config_get( 'page_cache.cache_dir' ) ); } } /** * Set the WP_CACHE constant. * * @since 0.1.0 * * @return void */ private function wp_cache_init(): void { $this->container->get( WP_Config::class )->set_wp_cache( 'true' ); } /** * Saves a set of default values in the config. * * @since 0.1.0 * * @return void */ private function initialize_settings(): void { $pipeline = new Pipeline( $this->container ); $pipeline->pipes( [ Site::class, Site_File::class, ] ); if ( is_multisite() ) { $pipeline->pipe( [ Network::class, Network_File::class, ] ); } $config = new Config( $pipeline ); $config->save(); } }