PluginProbe
Solid Performance – Your No-Code Caching, Performance, & Page Speed Solution / 1.8.0
Solid Performance – Your No-Code Caching, Performance, & Page Speed Solution v1.8.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 / Dom / Provider.php

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

63 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Registers DOM related functionality in the container.
4 *
5 * @package SolidWP\Performance
6 */
7
8 declare( strict_types=1 );
9
10 namespace SolidWP\Performance\Dom;
11
12 use SolidWP\Performance\Contracts\Service_Provider;
13 use SolidWP\Performance\Dom\Modifiers\Image_Transformation_Modifier;
14 use SolidWP\Performance\Dom\Modifiers\Lazy_Load_Modifier;
15 use SolidWP\Performance\StellarWP\Pipeline\Pipeline;
16
17 /**
18 * Registers DOM related functionality in the container.
19 *
20 * @package SolidWP\Performance
21 */
22 final class Provider extends Service_Provider {
23
24 public const PIPELINE = 'solid_performance.dom.modifier_pipeline';
25
26 /**
27 * @inheritDoc
28 */
29 public function register(): void {
30 $this->register_dom_modifier_pipeline();
31
32 // Run the HTML through the pipeline before being rendered.
33 add_filter(
34 'solidwp/performance/cache/html',
35 $this->container->callback( Modifier::class, 'modify' ),
36 10,
37 1
38 );
39 }
40
41 /**
42 * Register the dom modifier pipeline steps.
43 *
44 * @return void
45 */
46 private function register_dom_modifier_pipeline(): void {
47 $this->container->singleton(
48 self::PIPELINE,
49 fn(): Pipeline => ( new Pipeline( $this->container ) )->through(
50 // Register any dom modifier pipeline stages here.
51 [
52 Image_Transformation_Modifier::class,
53 Lazy_Load_Modifier::class,
54 ]
55 )
56 );
57
58 $this->container->when( Modifier::class )
59 ->needs( Pipeline::class )
60 ->give( static fn( $c ) => $c->get( self::PIPELINE ) );
61 }
62 }
63