# solid-performance/1.3.0/src/Performance/Shutdown/Provider.php

Solid Performance – Your No-Code Caching, Performance, &amp; Page Speed Solution, version 1.3.0. 65 lines.

- Page: https://pluginprobe.com/plugins/solid-performance/1.3.0/code/src/Performance/Shutdown/Provider.php
- Raw: https://pluginprobe.com/plugins/solid-performance/1.3.0/raw/src/Performance/Shutdown/Provider.php
- Modified: 2024-10-09T17:31:38+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/solid-performance/1.3.0/code/src/Performance/Shutdown/Provider.php#L10-L20`.

```php
<?php
/**
 * The Service Provider for Terminal Shutdown tasks.
 *
 * @package SolidWP\Performance
 */

declare( strict_types=1 );

namespace SolidWP\Performance\Shutdown;

use SolidWP\Performance\Config\Config;
use SolidWP\Performance\Contracts\Service_Provider;
use SolidWP\Performance\Page_Cache\Purge\Batch\Batch_Purger;
use SolidWP\Performance\Update\Updater;

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * The Service Provider for Terminal Shutdown tasks.
 *
 * @package SolidWP\Performance
 */
final class Provider extends Service_Provider {

	/**
	 * @inheritDoc
	 */
	public function register(): void {
		$this->container->singleton(
			Shutdown_Handler::class,
			fn() => new Shutdown_Handler(
				// Add any terminable tasks to the collection to run on shutdown.
				// Important: these will run in the order provided.
				$this->container->get( Config::class ),
				$this->container->get( Updater::class ),
				$this->container->get( Batch_Purger::class ),
			)
		);

		// Create an action that can be called manually.
		add_action( 'solidwp/performance/terminate', $this->container->callback( Shutdown_Handler::class, 'handle' ) );

		// Run early to get ahead of any potentially bad code that could kill execution.
		add_action(
			'shutdown',
			static function (): void {
				do_action( 'solidwp/performance/terminate' );
			},
			1
		);

		// Run this again in case any other code was updated in the shutdown action that could trigger our Terminable tasks.
		add_action(
			'shutdown',
			static function (): void {
				do_action( 'solidwp/performance/terminate' );
			},
			9999
		);
	}
}

```
