-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add update notice to module config page. * Create admin notification once for each update. * Change module version 3.1.11.
- Loading branch information
1 parent
1d12b38
commit 996a48c
Showing
22 changed files
with
595 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
namespace Flekto\Postcode\Api\Data; | ||
|
||
/** | ||
* @api | ||
*/ | ||
interface UpdateNotificationInterface | ||
{ | ||
public const VERSION = 'version'; | ||
public const NOTIFIED = 'notified'; | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getVersion(); | ||
|
||
/** | ||
* @param string $version | ||
* @return $this | ||
*/ | ||
public function setVersion(string $version); | ||
|
||
/** | ||
* @return bool | ||
*/ | ||
public function getNotified(); | ||
|
||
/** | ||
* @param bool $notified | ||
* @return $this | ||
*/ | ||
public function setNotified(bool $notified); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
namespace Flekto\Postcode\Api; | ||
|
||
use Flekto\Postcode\Api\Data\UpdateNotificationInterface; | ||
use Magento\Framework\Exception\LocalizedException; | ||
use Magento\Framework\Exception\NoSuchEntityException; | ||
|
||
/** | ||
* Update notification CRUD interface. | ||
* @api | ||
*/ | ||
interface UpdateNotificationRepositoryInterface | ||
{ | ||
/** | ||
* @param UpdateNotificationInterface $notification | ||
* @return UpdateNotificationInterface | ||
* @throws LocalizedException | ||
*/ | ||
public function save(UpdateNotificationInterface $notification): UpdateNotificationInterface; | ||
|
||
/** | ||
* @param string $version | ||
* @return UpdateNotificationInterface | ||
* @throws LocalizedException | ||
* @throws NoSuchEntityException | ||
*/ | ||
public function getByVersion(string $version): UpdateNotificationInterface; | ||
|
||
/** | ||
* @param string $version | ||
* @throws LocalizedException | ||
*/ | ||
public function setVersionNotified(string $version): void; | ||
|
||
/** | ||
* @param string $version | ||
* @return bool | ||
* @throws LocalizedException | ||
*/ | ||
public function isVersionNotified(string $version): bool; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
namespace Flekto\Postcode\Cron; | ||
|
||
use Psr\Log\LoggerInterface; | ||
use Flekto\Postcode\Helper\Data as DataHelper; | ||
use Flekto\Postcode\Model\UpdateNotification\UpdateNotifier; | ||
|
||
class NotifyModuleUpdate | ||
{ | ||
protected $_logger; | ||
protected $_dataHelper; | ||
protected $_updateNotifier; | ||
|
||
/** | ||
* Constructor | ||
* | ||
* @access public | ||
* @param LoggerInterface $logger | ||
* @param DataHelper $dataHelper | ||
* @param UpdateNotifier $updateNotifier | ||
* @return void | ||
*/ | ||
public function __construct( | ||
LoggerInterface $logger, | ||
DataHelper $dataHelper, | ||
UpdateNotifier $updateNotifier, | ||
) { | ||
$this->_logger = $logger; | ||
$this->_dataHelper = $dataHelper; | ||
$this->_updateNotifier = $updateNotifier; | ||
} | ||
|
||
/** | ||
* Run cron job. | ||
* | ||
* @access public | ||
* @return void | ||
*/ | ||
public function execute(): void | ||
{ | ||
$moduleInfo = $this->_dataHelper->getModuleInfo(); | ||
if (($moduleInfo['has_update'] ?? false) | ||
&& $this->_updateNotifier->notifyVersion($moduleInfo['latest_version']) | ||
) { | ||
$this->_logger->info(__('Added notification for Postcode.eu Address API %1 update.', $moduleInfo['latest_version'])); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.