PluginProbe
Solid Performance – Your No-Code Caching, Performance, & Page Speed Solution / 1.2.0
Solid Performance – Your No-Code Caching, Performance, & Page Speed Solution v1.2.0
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 1.2.0, at src/Performance/Page_Cache/Provider.php

66 lines 1.8 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( Cache_Path::class )
39 ->needs( '$cache_dir' )
40 ->give( static fn( $c ): string => $c->get( Config::class )->get( 'page_cache.cache_dir' ) );
41
42 $this->container->when( Expiration::class )
43 ->needs( '$seconds' )
44 ->give( static fn( $c ): int => $c->get( Config::class )->get( 'page_cache.expiration' ) );
45
46 $this->container->when( WP_Context::class )
47 ->needs( '$post_id' )
48 ->give( static fn(): int => (int) get_the_ID() );
49
50 $this->container->when( Collection::class )
51 ->needs( '$compressors' )
52 ->give(
53 static fn( $c ): array => [
54 // Different browser compression algorithms for saving and serving cached files.
55 $c->get( Brotli::class ),
56 $c->get( Zstd::class ),
57 $c->get( Gzip::class ),
58 $c->get( Deflate::class ),
59 $c->get( Html::class ),
60 ]
61 );
62
63 $this->container->singleton( Collection::class, Collection::class );
64 }
65 }
66