Move WooCommerceHelper instantiation to constructor [MAILPOET-1723]

This commit is contained in:
wxa
2019-02-04 15:49:01 +03:00
committed by M. Shull
parent 6e8cad2307
commit 95f162592b

View File

@@ -15,8 +15,12 @@ class Reporter {
/** @var SettingsController */ /** @var SettingsController */
private $settings; private $settings;
/** @var WooCommerceHelper */
private $woocommerce_helper;
public function __construct(SettingsController $settings) { public function __construct(SettingsController $settings) {
$this->settings = $settings; $this->settings = $settings;
$this->woocommerce_helper = new WooCommerceHelper;
} }
function getData() { function getData() {
@@ -27,8 +31,7 @@ class Reporter {
$checker = new ServicesChecker(); $checker = new ServicesChecker();
$bounceAddress = $this->settings->get('bounce.address'); $bounceAddress = $this->settings->get('bounce.address');
$segments = Segment::getAnalytics(); $segments = Segment::getAnalytics();
$woocommerce_helper = new WooCommerceHelper; $has_wc = $this->woocommerce_helper->isWooCommerceActive();
$has_wc = $woocommerce_helper->isWooCommerceActive();
$wc_customers_count = 0; $wc_customers_count = 0;
if($has_wc) { if($has_wc) {
$wc_customers_count = (int)Newsletter::rawQuery( $wc_customers_count = (int)Newsletter::rawQuery(