PluginProbe
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF / trunk
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF vtrunk
2.3.4 2.3.3 2.3.2 2.3.1 2.3.0 2.2.9 2.2.8 trunk 1.10 1.3.3 1.3.4 1.3.5 1.3.5.1 1.3.5.2 1.3.6 1.3.6.1 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.5 All 103 releases
← All changes | classes/MCP/ServiceProvider.php +22 -1 2.3.0 → trunk View file →
@@ -2,8 +2,10 @@
2 2 declare(strict_types=1);
3 3
4 4 namespace Imagify\MCP;
5 5
6 +use Imagify\Abilities\BulkOptimize;
7 +use Imagify\Abilities\GenerateMissingNextgen;
6 8 use Imagify\Abilities\GetAccount;
7 9 use Imagify\Abilities\GetMediaStatus;
8 10 use Imagify\Abilities\GetNextgenCoverage;
9 11 use Imagify\Abilities\GetSettings;
@@ -8,9 +10,11 @@
8 10 use Imagify\Abilities\GetNextgenCoverage;
9 11 use Imagify\Abilities\GetSettings;
10 12 use Imagify\Abilities\GetStats;
11 13 use Imagify\Abilities\OptimizeMedia;
14 +use Imagify\Abilities\RestoreMedia;
12 15 use Imagify\Abilities\UpdateSettings;
16 +use Imagify\Bulk\Bulk;
13 17 use Imagify\Dependencies\League\Container\ServiceProvider\AbstractServiceProvider;
14 18 use Imagify\Stats\OptimizedMediaWithoutNextGen;
15 19
16 20 /**
@@ -33,8 +37,11 @@
33 37 */
34 38 protected $provides = [
35 39 ConfigSubscriber::class,
36 40 AbilitiesSubscriber::class,
41 + Bulk::class,
42 + BulkOptimize::class,
43 + GenerateMissingNextgen::class,
37 44 GetAccount::class,
38 45 GetMediaStatus::class,
39 46 GetNextgenCoverage::class,
40 47 GetSettings::class,
@@ -39,8 +46,9 @@
39 46 GetNextgenCoverage::class,
40 47 GetSettings::class,
41 48 GetStats::class,
42 49 OptimizeMedia::class,
50 + RestoreMedia::class,
43 51 UpdateSettings::class,
44 52 ];
45 53
46 54 /**
@@ -65,11 +73,23 @@
65 73
66 74 /**
67 75 * Registers the provided services into the container.
68 76 *
77 + * Bulk is registered by passing the already-initialised singleton directly
78 + * (Plugin::init() calls Bulk::get_instance()->init() before any provider
79 + * runs), so no factory closure is needed. This avoids the ~12 KB opcode
80 + * allocation that a closure would incur in CLI environments with a tight
81 + * memory limit (e.g. wp-env at 128 MB).
82 + *
69 83 * @return void
70 84 */
71 85 public function register(): void {
86 + $this->getContainer()->addShared( Bulk::class, Bulk::get_instance() );
87 + $this->getContainer()->addShared( BulkOptimize::class )
88 + ->addArgument( Bulk::get_instance() );
89 + $this->getContainer()->addShared( GenerateMissingNextgen::class )
90 + ->addArgument( Bulk::class )
91 + ->addArgument( OptimizedMediaWithoutNextGen::class );
72 92 $this->getContainer()->addShared( ConfigSubscriber::class );
73 93 $this->getContainer()->addShared( GetAccount::class );
74 94 $this->getContainer()->addShared( GetMediaStatus::class );
75 95 $this->getContainer()->addShared( GetNextgenCoverage::class )
@@ -76,11 +96,12 @@
76 96 ->addArgument( OptimizedMediaWithoutNextGen::class );
77 97 $this->getContainer()->addShared( GetSettings::class );
78 98 $this->getContainer()->addShared( GetStats::class );
79 99 $this->getContainer()->addShared( OptimizeMedia::class );
100 + $this->getContainer()->addShared( RestoreMedia::class );
80 101 $this->getContainer()->addShared( UpdateSettings::class );
81 102 $this->getContainer()->addShared( AbilitiesSubscriber::class )
82 - ->addArguments( [ GetAccount::class, GetMediaStatus::class, GetNextgenCoverage::class, GetSettings::class, GetStats::class, OptimizeMedia::class, UpdateSettings::class ] );
103 + ->addArguments( [ BulkOptimize::class, GenerateMissingNextgen::class, GetAccount::class, GetMediaStatus::class, GetNextgenCoverage::class, GetSettings::class, GetStats::class, OptimizeMedia::class, RestoreMedia::class, UpdateSettings::class ] );
83 104 }
84 105
85 106 /**
86 107 * Returns the list of subscriber class names.