PluginProbe
Solid Performance – Your No-Code Caching, Performance, & Page Speed Solution / trunk
Solid Performance – Your No-Code Caching, Performance, & Page Speed Solution vtrunk
2.0.1 trunk 1.0.0 1.1.0 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 1.4.2 1.5.0 1.6.0 1.6.1 1.7.0 1.7.1 1.8.0 1.9.0 2.0.0
solid-performance / src / Performance / Page_Cache / Provider.php

Provider.php in Solid Performance – Your No-Code Caching, Performance, & Page Speed Solution trunk, at src/Performance/Page_Cache/Provider.php

62 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * The provider for all core Page caching related functionality.
4 *
5 * @since 0.1.0
6 *
7 * @package SolidWP\Performance
8 */
9
10 namespace SolidWP\Performance\Page_Cache;
11
12 use SolidWP\Performance\Config\Config;
13 use SolidWP\Performance\Contracts\Service_Provider;
14 use SolidWP\Performance\Page_Cache\Compression\Collection;
15 use SolidWP\Performance\Page_Cache\Compression\Strategies\Brotli;
16 use SolidWP\Performance\Page_Cache\Compression\Strategies\Deflate;
17 use SolidWP\Performance\Page_Cache\Compression\Strategies\Gzip;
18 use SolidWP\Performance\Page_Cache\Compression\Strategies\Html;
19 use SolidWP\Performance\Page_Cache\Compression\Strategies\Zstd;
20
21 if ( ! defined( 'ABSPATH' ) ) {
22 exit;
23 }
24
25 /**
26 * The provider for all core Page caching related functionality.
27 *
28 * @since 0.1.0
29 *
30 * @package SolidWP\Performance
31 */
32 class Provider extends Service_Provider {
33
34 /**
35 * {@inheritdoc}
36 */
37 public function register(): void {
38 $this->container->when( Expiration::class )
39 ->needs( '$seconds' )
40 ->give( static fn( $c ): int => $c->get( Config::class )->get( 'page_cache.expiration' ) );
41
42 $this->container->when( WP_Context::class )
43 ->needs( '$post_id' )
44 ->give( static fn(): int => (int) get_the_ID() );
45
46 $this->container->when( Collection::class )
47 ->needs( '$compressors' )
48 ->give(
49 static fn( $c ): array => [
50 // Different browser compression algorithms for saving and serving cached files.
51 $c->get( Brotli::class ),
52 $c->get( Zstd::class ),
53 $c->get( Gzip::class ),
54 $c->get( Deflate::class ),
55 $c->get( Html::class ),
56 ]
57 );
58
59 $this->container->singleton( Collection::class, Collection::class );
60 }
61 }
62