Commit 9855980857c for woocommerce
commit 9855980857c563961f1e6c0e2b7e266acaabaf74
Author: Hannah Tinkler <hannah.tinkler@gmail.com>
Date: Mon Mar 9 11:32:26 2026 +0000
Ensures container use is justified and consistent (#63557)
* Removes unnecessary items from the container.
diff --git a/plugins/woocommerce/src/Internal/PushNotifications/PushNotifications.php b/plugins/woocommerce/src/Internal/PushNotifications/PushNotifications.php
index ae82878c75d..a8795a182de 100644
--- a/plugins/woocommerce/src/Internal/PushNotifications/PushNotifications.php
+++ b/plugins/woocommerce/src/Internal/PushNotifications/PushNotifications.php
@@ -72,13 +72,11 @@ class PushNotifications {
$this->register_post_types();
- wc_get_container()->get( PushTokenRestController::class )->register();
+ wc_get_container()->get( PendingNotificationStore::class )->register();
- $store = wc_get_container()->get( PendingNotificationStore::class );
- $store->register();
-
- ( new NewOrderNotificationTrigger( $store ) )->register();
- ( new NewReviewNotificationTrigger( $store ) )->register();
+ ( new PushTokenRestController() )->register();
+ ( new NewOrderNotificationTrigger() )->register();
+ ( new NewReviewNotificationTrigger() )->register();
}
/**
diff --git a/plugins/woocommerce/src/Internal/PushNotifications/Triggers/NewOrderNotificationTrigger.php b/plugins/woocommerce/src/Internal/PushNotifications/Triggers/NewOrderNotificationTrigger.php
index d93bd7ab90c..402875edd32 100644
--- a/plugins/woocommerce/src/Internal/PushNotifications/Triggers/NewOrderNotificationTrigger.php
+++ b/plugins/woocommerce/src/Internal/PushNotifications/Triggers/NewOrderNotificationTrigger.php
@@ -41,24 +41,6 @@ class NewOrderNotificationTrigger {
'partial-payment',
);
- /**
- * The pending notification store.
- *
- * @var PendingNotificationStore
- */
- private PendingNotificationStore $pending_notification_store;
-
- /**
- * Constructs the trigger.
- *
- * @param PendingNotificationStore $pending_notification_store The notification store.
- *
- * @since 10.7.0
- */
- public function __construct( PendingNotificationStore $pending_notification_store ) {
- $this->pending_notification_store = $pending_notification_store;
- }
-
/**
* Registers WordPress hooks for order events.
*
@@ -85,7 +67,7 @@ class NewOrderNotificationTrigger {
return;
}
- $this->pending_notification_store->add(
+ wc_get_container()->get( PendingNotificationStore::class )->add(
new NewOrderNotification( $order_id )
);
}
@@ -116,7 +98,7 @@ class NewOrderNotificationTrigger {
return;
}
- $this->pending_notification_store->add(
+ wc_get_container()->get( PendingNotificationStore::class )->add(
new NewOrderNotification( $order_id )
);
}
diff --git a/plugins/woocommerce/src/Internal/PushNotifications/Triggers/NewReviewNotificationTrigger.php b/plugins/woocommerce/src/Internal/PushNotifications/Triggers/NewReviewNotificationTrigger.php
index 306d12b82e9..948976eb10f 100644
--- a/plugins/woocommerce/src/Internal/PushNotifications/Triggers/NewReviewNotificationTrigger.php
+++ b/plugins/woocommerce/src/Internal/PushNotifications/Triggers/NewReviewNotificationTrigger.php
@@ -16,24 +16,6 @@ defined( 'ABSPATH' ) || exit;
* @since 10.7.0
*/
class NewReviewNotificationTrigger {
- /**
- * The pending notification store.
- *
- * @var PendingNotificationStore
- */
- private PendingNotificationStore $store;
-
- /**
- * Constructs the trigger.
- *
- * @param PendingNotificationStore $store The notification store.
- *
- * @since 10.7.0
- */
- public function __construct( PendingNotificationStore $store ) {
- $this->store = $store;
- }
-
/**
* Registers WordPress hooks for review events.
*
@@ -71,7 +53,7 @@ class NewReviewNotificationTrigger {
return;
}
- $this->store->add(
+ wc_get_container()->get( PendingNotificationStore::class )->add(
new NewReviewNotification( $comment_id )
);
}
diff --git a/plugins/woocommerce/tests/php/src/Internal/PushNotifications/Triggers/NewOrderNotificationTriggerTest.php b/plugins/woocommerce/tests/php/src/Internal/PushNotifications/Triggers/NewOrderNotificationTriggerTest.php
index 500913ad099..a3bcf8dcbe8 100644
--- a/plugins/woocommerce/tests/php/src/Internal/PushNotifications/Triggers/NewOrderNotificationTriggerTest.php
+++ b/plugins/woocommerce/tests/php/src/Internal/PushNotifications/Triggers/NewOrderNotificationTriggerTest.php
@@ -39,7 +39,7 @@ class NewOrderNotificationTriggerTest extends WC_Unit_Test_Case {
wc_get_container()->replace( PendingNotificationStore::class, $this->store );
wc_get_container()->reset_all_resolved();
- $this->trigger = new NewOrderNotificationTrigger( $this->store );
+ $this->trigger = new NewOrderNotificationTrigger();
$this->trigger->register();
}
diff --git a/plugins/woocommerce/tests/php/src/Internal/PushNotifications/Triggers/NewReviewNotificationTriggerTest.php b/plugins/woocommerce/tests/php/src/Internal/PushNotifications/Triggers/NewReviewNotificationTriggerTest.php
index 0f28507f4f7..f1d1146231b 100644
--- a/plugins/woocommerce/tests/php/src/Internal/PushNotifications/Triggers/NewReviewNotificationTriggerTest.php
+++ b/plugins/woocommerce/tests/php/src/Internal/PushNotifications/Triggers/NewReviewNotificationTriggerTest.php
@@ -46,7 +46,7 @@ class NewReviewNotificationTriggerTest extends WC_Unit_Test_Case {
wc_get_container()->replace( PendingNotificationStore::class, $this->store );
wc_get_container()->reset_all_resolved();
- $this->trigger = new NewReviewNotificationTrigger( $this->store );
+ $this->trigger = new NewReviewNotificationTrigger();
$product = WC_Helper_Product::create_simple_product();
$this->product_id = $product->get_id();