Skip to content

Commit

Permalink
Update notifications via cron
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacker committed Dec 15, 2022
1 parent 6199a9a commit f105e4b
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 100 deletions.
129 changes: 57 additions & 72 deletions ...dispatchAdminActionControllerObserver.php → Cron/ProcessFeed.php
Original file line number Diff line number Diff line change
@@ -1,72 +1,57 @@
<?php
/**
* Mageplaza
*
* NOTICE OF LICENSE
*
* This source file is subject to the mageplaza.com license that is
* available through the world-wide-web at this URL:
* https://www.mageplaza.com/LICENSE.txt
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this extension to newer
* version in the future.
*
* @category Mageplaza
* @package Mageplaza_Core
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/)
* @license https://www.mageplaza.com/LICENSE.txt
*/

namespace Mageplaza\Core\Observer;

use Magento\Backend\Model\Auth\Session;
use Magento\Framework\Event\Observer;
use Magento\Framework\Event\ObserverInterface;
use Mageplaza\Core\Helper\AbstractData;
use Mageplaza\Core\Model\Feed;

/**
* Class PredispatchAdminActionControllerObserver
* @package Mageplaza\Core\Observer
*/
class PredispatchAdminActionControllerObserver implements ObserverInterface
{
/**
* @type Session
*/
protected $_backendAuthSession;

/**
* @var AbstractData
*/
protected $helper;

/**
* PredispatchAdminActionControllerObserver constructor.
*
* @param Session $backendAuthSession
* @param AbstractData $helper
*/
public function __construct(
Session $backendAuthSession,
AbstractData $helper
) {
$this->_backendAuthSession = $backendAuthSession;
$this->helper = $helper;
}

/**
* @param Observer $observer
*/
public function execute(Observer $observer)
{
if ($this->_backendAuthSession->isLoggedIn()
&& $this->helper->isModuleOutputEnabled('Magento_AdminNotification')) {
/* @var $feedModel Feed */
$feedModel = $this->helper->createObject(Feed::class);
$feedModel->checkUpdate();
}
}
}
<?php
/**
* Mageplaza
*
* NOTICE OF LICENSE
*
* This source file is subject to the mageplaza.com license that is
* available through the world-wide-web at this URL:
* https://www.mageplaza.com/LICENSE.txt
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this extension to newer
* version in the future.
*
* @category Mageplaza
* @package Mageplaza_Core
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/)
* @license https://www.mageplaza.com/LICENSE.txt
*/

namespace Mageplaza\Core\Cron;

use Mageplaza\Core\Helper\AbstractData;
use Mageplaza\Core\Model\Feed;

/**
* Class ProcessFeed
* @package Mageplaza\Core\Cron
*/
class ProcessFeed
{
/**
* @var AbstractData
*/
protected $helper;

/**
* ProcessFeed constructor.
*
* @param AbstractData $helper
*/
public function __construct(
AbstractData $helper
) {
$this->helper = $helper;
}

public function execute()
{
if ($this->helper->isModuleOutputEnabled('Magento_AdminNotification')) {
/* @var $feedModel Feed */
$feedModel = $this->helper->createObject(Feed::class);
$feedModel->checkUpdate();
}
}
}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "mageplaza/module-core",
"description": "Mageplaza Core for Magento 2",
"type": "magento2-module",
"version": "1.5.0",
"version": "1.5.1",
"license": "proprietary",
"authors": [
{
Expand Down
27 changes: 0 additions & 27 deletions etc/adminhtml/events.xml

This file was deleted.

3 changes: 3 additions & 0 deletions etc/crontab.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,8 @@
<job name="core_get_update" instance="Mageplaza\Core\Cron\GetUpdate" method="execute">
<schedule>0 2 * * 0</schedule>
</job>
<job name="core_process_feed" instance="Mageplaza\Core\Cron\ProcessFeed" method="execute">
<schedule>0 * * * *</schedule>
</job>
</group>
</config>

0 comments on commit f105e4b

Please sign in to comment.