Use DI to initialize PermanentNotices

[MAILPOET-2088]
This commit is contained in:
Jan Jakeš
2019-05-31 15:39:41 +02:00
committed by M. Shull
parent 0e99d7982c
commit 74a4ff5a2f
3 changed files with 17 additions and 11 deletions

View File

@ -52,6 +52,9 @@ class Initializer {
/** @var CronTrigger */ /** @var CronTrigger */
private $cron_trigger; private $cron_trigger;
/** @var PermanentNotices */
private $permanent_notices;
const INITIALIZED = 'MAILPOET_INITIALIZED'; const INITIALIZED = 'MAILPOET_INITIALIZED';
function __construct( function __construct(
@ -64,7 +67,8 @@ class Initializer {
Hooks $hooks, Hooks $hooks,
Changelog $changelog, Changelog $changelog,
Menu $menu, Menu $menu,
CronTrigger $cron_trigger CronTrigger $cron_trigger,
PermanentNotices $permanent_notices
) { ) {
$this->renderer_factory = $renderer_factory; $this->renderer_factory = $renderer_factory;
$this->access_control = $access_control; $this->access_control = $access_control;
@ -76,6 +80,7 @@ class Initializer {
$this->changelog = $changelog; $this->changelog = $changelog;
$this->menu = $menu; $this->menu = $menu;
$this->cron_trigger = $cron_trigger; $this->cron_trigger = $cron_trigger;
$this->permanent_notices = $permanent_notices;
} }
function init() { function init() {
@ -302,8 +307,7 @@ class Initializer {
} }
function setupPermanentNotices() { function setupPermanentNotices() {
$notices = new PermanentNotices(); $this->permanent_notices->init();
$notices->init();
} }
function handleFailedInitialization($exception) { function handleFailedInitialization($exception) {

View File

@ -83,6 +83,8 @@ class ContainerConfigurator implements IContainerConfigurator {
$container->autowire(\MailPoet\Listing\BulkActionController::class)->setPublic(true); $container->autowire(\MailPoet\Listing\BulkActionController::class)->setPublic(true);
$container->autowire(\MailPoet\Listing\BulkActionFactory::class)->setPublic(true); $container->autowire(\MailPoet\Listing\BulkActionFactory::class)->setPublic(true);
$container->autowire(\MailPoet\Listing\Handler::class)->setPublic(true); $container->autowire(\MailPoet\Listing\Handler::class)->setPublic(true);
// Notices
$container->autowire(\MailPoet\Util\Notices\PermanentNotices::class);
// Router // Router
$container->autowire(\MailPoet\Router\Endpoints\CronDaemon::class)->setPublic(true); $container->autowire(\MailPoet\Router\Endpoints\CronDaemon::class)->setPublic(true);
$container->autowire(\MailPoet\Router\Endpoints\Subscription::class)->setPublic(true); $container->autowire(\MailPoet\Router\Endpoints\Subscription::class)->setPublic(true);

View File

@ -8,6 +8,9 @@ use MailPoet\WP\Functions as WPFunctions;
class PermanentNotices { class PermanentNotices {
/** @var WPFunctions */
private $wp;
/** @var PHPVersionWarnings */ /** @var PHPVersionWarnings */
private $php_version_warnings; private $php_version_warnings;
@ -26,17 +29,14 @@ class PermanentNotices {
/** @var InactiveSubscribersNotice */ /** @var InactiveSubscribersNotice */
private $inactive_subscribers_notice; private $inactive_subscribers_notice;
/** @var WPFunctions */ public function __construct(WPFunctions $wp) {
private $wp; $this->wp = $wp;
public function __construct() {
$this->wp = WPFunctions::get();
$this->php_version_warnings = new PHPVersionWarnings(); $this->php_version_warnings = new PHPVersionWarnings();
$this->after_migration_notice = new AfterMigrationNotice(); $this->after_migration_notice = new AfterMigrationNotice();
$this->discounts_announcement = new DiscountsAnnouncement(); $this->discounts_announcement = new DiscountsAnnouncement();
$this->unauthorized_emails_notice = new UnauthorizedEmailNotice(new SettingsController, $this->wp); $this->unauthorized_emails_notice = new UnauthorizedEmailNotice(new SettingsController, $wp);
$this->unauthorized_emails_in_newsletters_notice = new UnauthorizedEmailInNewslettersNotice(new SettingsController, $this->wp); $this->unauthorized_emails_in_newsletters_notice = new UnauthorizedEmailInNewslettersNotice(new SettingsController, $wp);
$this->inactive_subscribers_notice = new InactiveSubscribersNotice(new SettingsController, $this->wp); $this->inactive_subscribers_notice = new InactiveSubscribersNotice(new SettingsController, $wp);
} }
public function init() { public function init() {