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

61 lines 1.3 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\Lazy_Load_Modifier;
14 use SolidWP\Performance\StellarWP\Pipeline\Pipeline;
15
16 /**
17 * Registers DOM related functionality in the container.
18 *
19 * @package SolidWP\Performance
20 */
21 final class Provider extends Service_Provider {
22
23 public const PIPELINE = 'solid_performance.dom.modifier_pipeline';
24
25 /**
26 * @inheritDoc
27 */
28 public function register(): void {
29 $this->register_dom_modifier_pipeline();
30
31 // Run the HTML through the pipeline before being rendered.
32 add_filter(
33 'solidwp/performance/cache/html',
34 $this->container->callback( Modifier::class, 'modify' ),
35 10,
36 1
37 );
38 }
39
40 /**
41 * Register the dom modifier pipeline steps.
42 *
43 * @return void
44 */
45 private function register_dom_modifier_pipeline(): void {
46 $this->container->singleton(
47 self::PIPELINE,
48 fn(): Pipeline => ( new Pipeline( $this->container ) )->through(
49 // Register any dom modifier pipeline stages here.
50 [
51 Lazy_Load_Modifier::class,
52 ]
53 )
54 );
55
56 $this->container->when( Modifier::class )
57 ->needs( Pipeline::class )
58 ->give( static fn( $c ) => $c->get( self::PIPELINE ) );
59 }
60 }
61