Add Populator to DI
This commit is contained in:
committed by
M. Shull
parent
fecfe32457
commit
5ae402bcab
@ -7,6 +7,7 @@ use MailPoet\WP\Functions as WPFunctions;
|
|||||||
use MailPoet\Config\AccessControl;
|
use MailPoet\Config\AccessControl;
|
||||||
use MailPoet\Config\Activator;
|
use MailPoet\Config\Activator;
|
||||||
use MailPoet\Settings\SettingsController;
|
use MailPoet\Settings\SettingsController;
|
||||||
|
use MailPoet\Config\Populator;
|
||||||
|
|
||||||
if (!defined('ABSPATH')) exit;
|
if (!defined('ABSPATH')) exit;
|
||||||
|
|
||||||
@ -22,7 +23,8 @@ class Setup extends APIEndpoint {
|
|||||||
|
|
||||||
function reset() {
|
function reset() {
|
||||||
try {
|
try {
|
||||||
$activator = new Activator(new SettingsController());
|
$settings = new SettingsController();
|
||||||
|
$activator = new Activator($settings, new Populator($settings, $this->wp));
|
||||||
$activator->deactivate();
|
$activator->deactivate();
|
||||||
$activator->activate();
|
$activator->activate();
|
||||||
$this->wp->doAction('mailpoet_setup_reset');
|
$this->wp->doAction('mailpoet_setup_reset');
|
||||||
|
@ -11,16 +11,19 @@ class Activator {
|
|||||||
/** @var SettingsController */
|
/** @var SettingsController */
|
||||||
private $settings;
|
private $settings;
|
||||||
|
|
||||||
function __construct(SettingsController $settings) {
|
/** @var Populator */
|
||||||
|
private $populator;
|
||||||
|
|
||||||
|
function __construct(SettingsController $settings, Populator $populator) {
|
||||||
$this->settings = $settings;
|
$this->settings = $settings;
|
||||||
|
$this->populator = $populator;
|
||||||
}
|
}
|
||||||
|
|
||||||
function activate() {
|
function activate() {
|
||||||
$migrator = new Migrator();
|
$migrator = new Migrator();
|
||||||
$migrator->up();
|
$migrator->up();
|
||||||
|
|
||||||
$populator = new Populator();
|
$this->populator->up();
|
||||||
$populator->up();
|
|
||||||
$this->updateDbVersion();
|
$this->updateDbVersion();
|
||||||
|
|
||||||
$caps = new Capabilities();
|
$caps = new Capabilities();
|
||||||
|
@ -41,9 +41,9 @@ class Populator {
|
|||||||
private $wp;
|
private $wp;
|
||||||
const TEMPLATES_NAMESPACE = '\MailPoet\Config\PopulatorData\Templates\\';
|
const TEMPLATES_NAMESPACE = '\MailPoet\Config\PopulatorData\Templates\\';
|
||||||
|
|
||||||
function __construct() {
|
function __construct(SettingsController $settings, WPFunctions $wp) {
|
||||||
$this->settings = new SettingsController();
|
$this->settings = $settings;
|
||||||
$this->wp = new WPFunctions();
|
$this->wp = $wp;
|
||||||
$this->prefix = Env::$db_prefix;
|
$this->prefix = Env::$db_prefix;
|
||||||
$this->models = [
|
$this->models = [
|
||||||
'newsletter_option_fields',
|
'newsletter_option_fields',
|
||||||
|
@ -57,6 +57,7 @@ class ContainerConfigurator implements IContainerConfigurator {
|
|||||||
// Config
|
// Config
|
||||||
$container->autowire(\MailPoet\Config\AccessControl::class)->setPublic(true);
|
$container->autowire(\MailPoet\Config\AccessControl::class)->setPublic(true);
|
||||||
$container->autowire(\MailPoet\Config\Activator::class)->setPublic(true);
|
$container->autowire(\MailPoet\Config\Activator::class)->setPublic(true);
|
||||||
|
$container->autowire(\MailPoet\Config\Populator::class)->setPublic(true);
|
||||||
$container->autowire(\MailPoet\Config\Changelog::class)->setPublic(true);
|
$container->autowire(\MailPoet\Config\Changelog::class)->setPublic(true);
|
||||||
$container->autowire(\MailPoet\Config\Hooks::class)->setPublic(true);
|
$container->autowire(\MailPoet\Config\Hooks::class)->setPublic(true);
|
||||||
$container->autowire(\MailPoet\Config\Initializer::class)->setPublic(true);
|
$container->autowire(\MailPoet\Config\Initializer::class)->setPublic(true);
|
||||||
|
@ -46,7 +46,8 @@ class SendingQueueTest extends \MailPoetTest {
|
|||||||
parent::_before();
|
parent::_before();
|
||||||
$wp_users = get_users();
|
$wp_users = get_users();
|
||||||
wp_set_current_user($wp_users[0]->ID);
|
wp_set_current_user($wp_users[0]->ID);
|
||||||
$populator = new Populator();
|
$this->settings = new SettingsController();
|
||||||
|
$populator = new Populator($this->settings, WPFunctions::get());
|
||||||
$populator->up();
|
$populator->up();
|
||||||
$this->subscriber = Subscriber::create();
|
$this->subscriber = Subscriber::create();
|
||||||
$this->subscriber->email = 'john@doe.com';
|
$this->subscriber->email = 'john@doe.com';
|
||||||
@ -83,7 +84,6 @@ class SendingQueueTest extends \MailPoetTest {
|
|||||||
$this->newsletter_link->hash = 'abcde';
|
$this->newsletter_link->hash = 'abcde';
|
||||||
$this->newsletter_link->save();
|
$this->newsletter_link->save();
|
||||||
$this->sending_error_handler = new SendingErrorHandler();
|
$this->sending_error_handler = new SendingErrorHandler();
|
||||||
$this->settings = new SettingsController();
|
|
||||||
$this->stats_notifications_worker = new StatsNotificationsScheduler($this->settings);
|
$this->stats_notifications_worker = new StatsNotificationsScheduler($this->settings);
|
||||||
$this->sending_queue_worker = new SendingQueueWorker($this->sending_error_handler, $this->stats_notifications_worker);
|
$this->sending_queue_worker = new SendingQueueWorker($this->sending_error_handler, $this->stats_notifications_worker);
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ use MailPoet\Mailer\Mailer;
|
|||||||
use MailPoet\Models\Setting;
|
use MailPoet\Models\Setting;
|
||||||
use MailPoet\Models\Subscriber;
|
use MailPoet\Models\Subscriber;
|
||||||
use MailPoet\Settings\SettingsController;
|
use MailPoet\Settings\SettingsController;
|
||||||
|
use MailPoet\WP\Functions as WPFunctions;
|
||||||
|
|
||||||
if (!defined('ABSPATH')) exit;
|
if (!defined('ABSPATH')) exit;
|
||||||
|
|
||||||
@ -23,10 +24,10 @@ class MailerTest extends \MailPoetTest {
|
|||||||
parent::_before();
|
parent::_before();
|
||||||
$wp_users = get_users();
|
$wp_users = get_users();
|
||||||
wp_set_current_user($wp_users[0]->ID);
|
wp_set_current_user($wp_users[0]->ID);
|
||||||
$populator = new Populator();
|
$this->settings = new SettingsController();
|
||||||
|
$populator = new Populator($this->settings, WPFunctions::get());
|
||||||
$populator->up();
|
$populator->up();
|
||||||
$this->mailer_task = new MailerTask();
|
$this->mailer_task = new MailerTask();
|
||||||
$this->settings = new SettingsController();
|
|
||||||
$this->sender = $this->settings->get('sender');
|
$this->sender = $this->settings->get('sender');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@ use MailPoet\Newsletter\Shortcodes\Categories\Date;
|
|||||||
use MailPoet\Newsletter\Url as NewsletterUrl;
|
use MailPoet\Newsletter\Url as NewsletterUrl;
|
||||||
use MailPoet\Settings\SettingsController;
|
use MailPoet\Settings\SettingsController;
|
||||||
use MailPoet\Subscription\Url as SubscriptionUrl;
|
use MailPoet\Subscription\Url as SubscriptionUrl;
|
||||||
|
use MailPoet\WP\Functions as WPFunctions;
|
||||||
|
|
||||||
require_once(ABSPATH . 'wp-admin/includes/user.php');
|
require_once(ABSPATH . 'wp-admin/includes/user.php');
|
||||||
|
|
||||||
@ -23,9 +24,9 @@ class ShortcodesTest extends \MailPoetTest {
|
|||||||
|
|
||||||
function _before() {
|
function _before() {
|
||||||
parent::_before();
|
parent::_before();
|
||||||
$populator = new Populator();
|
|
||||||
$populator->up();
|
|
||||||
$this->settings = new SettingsController();
|
$this->settings = new SettingsController();
|
||||||
|
$populator = new Populator($this->settings, WPFunctions::get());
|
||||||
|
$populator->up();
|
||||||
$this->WP_user = $this->_createWPUser();
|
$this->WP_user = $this->_createWPUser();
|
||||||
$this->WP_post = $this->_createWPPost();
|
$this->WP_post = $this->_createWPPost();
|
||||||
$this->subscriber = $this->_createSubscriber();
|
$this->subscriber = $this->_createSubscriber();
|
||||||
|
@ -6,11 +6,13 @@ use MailPoet\Subscription\Url;
|
|||||||
use MailPoet\Models\Subscriber;
|
use MailPoet\Models\Subscriber;
|
||||||
use MailPoet\Models\Setting;
|
use MailPoet\Models\Setting;
|
||||||
use MailPoet\Config\Populator;
|
use MailPoet\Config\Populator;
|
||||||
|
use MailPoet\Settings\SettingsController;
|
||||||
|
use MailPoet\WP\Functions as WPFunctions;
|
||||||
|
|
||||||
class UrlTest extends \MailPoetTest {
|
class UrlTest extends \MailPoetTest {
|
||||||
function _before() {
|
function _before() {
|
||||||
parent::_before();
|
parent::_before();
|
||||||
$populator = new Populator();
|
$populator = new Populator(new SettingsController, WPFunctions::get());
|
||||||
$populator->up();
|
$populator->up();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user