PluginProbe
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF / 2.3.3
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF v2.3.3
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
imagify / classes / Tracking / ServiceProvider.php

ServiceProvider.php in Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF 2.3.3, at classes/Tracking/ServiceProvider.php

97 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 declare(strict_types=1);
3
4 namespace Imagify\Tracking;
5
6 use Imagify\Dependencies\League\Container\ServiceProvider\AbstractServiceProvider;
7 use Imagify\Dependencies\WPMedia\Mixpanel\Optin;
8 use Imagify\Dependencies\WPMedia\Mixpanel\TrackingPlugin;
9
10 /**
11 * Service provider for the Tracking module.
12 *
13 * Wires Optin, TrackingPlugin, Tracking, and Subscriber into the DI container.
14 *
15 * @since 2.3.0
16 */
17 class ServiceProvider extends AbstractServiceProvider {
18
19 const MIXPANEL_TOKEN = '517e881edc2636e99a2ecf013d8134d3';
20 const APPLICATION = 'imagify';
21 const BRAND = 'wp media';
22
23 /**
24 * Services provided by this provider.
25 *
26 * @var array<int, string>
27 */
28 protected $provides = [
29 Optin::class,
30 TrackingPlugin::class,
31 Tracking::class,
32 Subscriber::class,
33 McpTracking::class,
34 McpTrackingSubscriber::class,
35 Notices::class,
36 ];
37
38 /**
39 * Subscribers provided by this provider.
40 *
41 * @var array<int, string>
42 */
43 public $subscribers = [
44 Subscriber::class,
45 McpTrackingSubscriber::class,
46 Notices::class,
47 ];
48
49 /**
50 * Checks whether this provider provides a given service.
51 *
52 * @param string $id Service identifier.
53 *
54 * @return bool
55 */
56 public function provides( string $id ): bool {
57 return in_array( $id, $this->provides, true );
58 }
59
60 /**
61 * Registers the provided services into the container.
62 *
63 * @return void
64 */
65 public function register(): void {
66 $this->getContainer()->addShared( Optin::class )
67 ->addArguments( [ self::APPLICATION, 'manage_options' ] );
68
69 $this->getContainer()->addShared( TrackingPlugin::class )
70 ->addArguments( [ self::MIXPANEL_TOKEN, self::APPLICATION . ' ' . IMAGIFY_VERSION, self::BRAND, self::APPLICATION ] );
71
72 $this->getContainer()->addShared( Tracking::class )
73 ->addArguments( [ Optin::class, TrackingPlugin::class ] );
74
75 $this->getContainer()->addShared( Subscriber::class )
76 ->addArgument( Tracking::class );
77
78 $this->getContainer()->addShared( McpTracking::class )
79 ->addArguments( [ Optin::class, TrackingPlugin::class ] );
80
81 $this->getContainer()->addShared( McpTrackingSubscriber::class )
82 ->addArgument( McpTracking::class );
83
84 $this->getContainer()->addShared( Notices::class )
85 ->addArgument( Optin::class );
86 }
87
88 /**
89 * Returns the list of subscriber class names.
90 *
91 * @return array<int, string>
92 */
93 public function get_subscribers(): array {
94 return $this->subscribers;
95 }
96 }
97