container->when( Advanced_Cache::class ) ->needs( '$template_file' ) ->give( '/src/views/cache/advanced-cache.php' ); swpsp_register_config(); $this->register_actions(); } /** * {@inheritdoc} */ public function register_actions(): void { $option_key = Config::OPTION_KEY; add_action( "update_option_{$option_key}", [ $this, 'save_via_config' ], 10, 2 ); add_action( "update_site_option_{$option_key}", [ $this, 'save_via_config' ], 10, 2 ); } /** * Saves the option updates using the Config architecture. * * @since 0.1.0 * * @param mixed $old_value The value being updated. * @param mixed $new_value The new values to update. * * @return void */ public function save_via_config( $old_value, $new_value ) { $changes = Arr::dot( $new_value ); foreach ( $changes as $key => $value ) { $this->container->get( Config::class )->set( $key, $value ); } $this->container->get( Config::class )->save(); } }