ltsecurityinc安防产品在线商城代码
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Plumrocket_Base
|
||||
* @copyright Copyright (c) 2020 Plumrocket Inc. (https://plumrocket.com)
|
||||
* @license https://plumrocket.com/license/ End-user License Agreement
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Plumrocket\Base\Observer;
|
||||
|
||||
use Magento\Framework\Event\Observer;
|
||||
use Magento\Framework\Event\ObserverInterface;
|
||||
use Magento\Framework\View\Page\Config as PageConfig;
|
||||
use Plumrocket\Base\Model\Theme\GetInformation;
|
||||
|
||||
/**
|
||||
* @since 2.3.0
|
||||
*/
|
||||
class AddClassToBodyObserver implements ObserverInterface
|
||||
{
|
||||
public const CSS_CLASS_PREFIX = 'pl-thm-';
|
||||
|
||||
/** @var PageConfig */
|
||||
private $pageConfig;
|
||||
|
||||
/**
|
||||
* @var \Plumrocket\Base\Model\Theme\GetInformation
|
||||
*/
|
||||
private $getThemeInformation;
|
||||
|
||||
/**
|
||||
* @param \Magento\Framework\View\Page\Config $pageConfig
|
||||
* @param \Plumrocket\Base\Model\Theme\GetInformation $getThemeInformation
|
||||
*/
|
||||
public function __construct(
|
||||
PageConfig $pageConfig,
|
||||
GetInformation $getThemeInformation
|
||||
) {
|
||||
$this->pageConfig = $pageConfig;
|
||||
$this->getThemeInformation = $getThemeInformation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add theme vendor and theme name classes.
|
||||
*
|
||||
* @param \Magento\Framework\Event\Observer $observer
|
||||
*/
|
||||
public function execute(Observer $observer)
|
||||
{
|
||||
$this->pageConfig
|
||||
->addBodyClass(self::CSS_CLASS_PREFIX . $this->getThemeInformation->getVendor())
|
||||
->addBodyClass(self::CSS_CLASS_PREFIX . $this->getThemeInformation->getName());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Plumrocket_Base
|
||||
* @copyright Copyright (c) 2020 Plumrocket Inc. (https://plumrocket.com)
|
||||
* @license https://plumrocket.com/license/ End-user License Agreement
|
||||
*/
|
||||
|
||||
namespace Plumrocket\Base\Observer;
|
||||
|
||||
use Magento\Framework\Event\Observer;
|
||||
use Magento\Framework\Event\ObserverInterface;
|
||||
use Plumrocket\Base\Model\Theme\GetInformation;
|
||||
|
||||
/**
|
||||
* @since 2.3.5
|
||||
*/
|
||||
class AddThemeHandleObserver implements ObserverInterface
|
||||
{
|
||||
public const LAYOUT_PREFIX = 'pl_thm_';
|
||||
|
||||
/**
|
||||
* @var \Plumrocket\Base\Model\Theme\GetInformation
|
||||
*/
|
||||
private $getThemeInformation;
|
||||
|
||||
/**
|
||||
* @param \Plumrocket\Base\Model\Theme\GetInformation $getThemeInformation
|
||||
*/
|
||||
public function __construct(GetInformation $getThemeInformation)
|
||||
{
|
||||
$this->getThemeInformation = $getThemeInformation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add theme vendor and theme name handles.
|
||||
*
|
||||
* @param \Magento\Framework\Event\Observer $observer
|
||||
*/
|
||||
public function execute(Observer $observer)
|
||||
{
|
||||
/** @var \Magento\Framework\View\Layout\ProcessorInterface $update */
|
||||
$update = $observer->getEvent()->getLayout()->getUpdate();
|
||||
$update->addHandle($this->createLayoutName($this->getThemeInformation->getVendor()));
|
||||
$update->addHandle($this->createLayoutName($this->getThemeInformation->getName()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Build layout name.
|
||||
*
|
||||
* @param string $string
|
||||
* @return string
|
||||
*/
|
||||
private function createLayoutName(string $string): string
|
||||
{
|
||||
return self::LAYOUT_PREFIX . str_replace('-', '_', $string) . '_default';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Plumrocket_Base
|
||||
* @copyright Copyright (c) 2020 Plumrocket Inc. (https://plumrocket.com)
|
||||
* @license https://plumrocket.com/license/ End-user License Agreement
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Plumrocket\Base\Observer\Adminhtml;
|
||||
|
||||
use Magento\Framework\App\RequestInterface;
|
||||
use Magento\Framework\Event\Observer;
|
||||
use Magento\Framework\Event\ObserverInterface;
|
||||
use Plumrocket\Base\Model\System\Config\CurrentSection;
|
||||
|
||||
/**
|
||||
* Add handles for plumrocket sections
|
||||
*
|
||||
* @since 2.3.1
|
||||
*/
|
||||
class AddSystemConfigLayoutUpdateObserver implements ObserverInterface
|
||||
{
|
||||
/**
|
||||
* @var \Magento\Framework\App\RequestInterface
|
||||
*/
|
||||
private $request;
|
||||
|
||||
/**
|
||||
* @var \Plumrocket\Base\Model\System\Config\CurrentSection
|
||||
*/
|
||||
private $currentSection;
|
||||
|
||||
/**
|
||||
* AddSystemConfigLayoutUpdateObserver constructor.
|
||||
*
|
||||
* @param \Magento\Framework\App\RequestInterface $request
|
||||
* @param \Plumrocket\Base\Model\System\Config\CurrentSection $currentSection
|
||||
*/
|
||||
public function __construct(RequestInterface $request, CurrentSection $currentSection)
|
||||
{
|
||||
$this->request = $request;
|
||||
$this->currentSection = $currentSection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add layout handles.
|
||||
*
|
||||
* @param \Magento\Framework\Event\Observer $observer
|
||||
*/
|
||||
public function execute(Observer $observer)
|
||||
{
|
||||
if ('adminhtml_system_config_edit' === $this->request->getFullActionName() &&
|
||||
$this->currentSection->isPlumrocketExtension()
|
||||
) {
|
||||
/** @var \Magento\Framework\View\Layout\ProcessorInterface $update */
|
||||
$update = $observer->getEvent()->getLayout()->getUpdate();
|
||||
$update->addHandle('pr_system_config_edit');
|
||||
$update->addHandle('pr_system_config_edit_' . $this->currentSection->getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Plumrocket_Base
|
||||
* @copyright Copyright (c) 2020 Plumrocket Inc. (https://plumrocket.com)
|
||||
* @license https://plumrocket.com/license/ End-user License Agreement
|
||||
*/
|
||||
|
||||
namespace Plumrocket\Base\Observer\Adminhtml;
|
||||
|
||||
use Magento\Framework\App\RequestInterface;
|
||||
use Magento\Framework\Event\ObserverInterface;
|
||||
use Plumrocket\Base\Model\IsModuleInMarketplace;
|
||||
|
||||
/**
|
||||
* @since 2.1.6
|
||||
*/
|
||||
class LayoutLoadBeforeObserver implements ObserverInterface
|
||||
{
|
||||
/**
|
||||
* @var \Magento\Framework\App\RequestInterface
|
||||
*/
|
||||
private $request;
|
||||
|
||||
/**
|
||||
* @var \Plumrocket\Base\Model\IsModuleInMarketplace
|
||||
*/
|
||||
private $isModuleInMarketplace;
|
||||
|
||||
/**
|
||||
* LayoutLoadBeforeObserver constructor.
|
||||
*
|
||||
* @param \Magento\Framework\App\RequestInterface $request
|
||||
* @param \Plumrocket\Base\Model\IsModuleInMarketplace $isModuleInMarketplace
|
||||
*/
|
||||
public function __construct(
|
||||
RequestInterface $request,
|
||||
IsModuleInMarketplace $isModuleInMarketplace
|
||||
) {
|
||||
$this->request = $request;
|
||||
$this->isModuleInMarketplace = $isModuleInMarketplace;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add shared css to plumrocket extension configuration page.
|
||||
*
|
||||
* @param \Magento\Framework\Event\Observer $observer
|
||||
*/
|
||||
public function execute(\Magento\Framework\Event\Observer $observer)
|
||||
{
|
||||
if ('adminhtml_system_config_edit' === $this->request->getFullActionName()
|
||||
&& $this->isModuleInMarketplace->execute('Plumrocket_Base')
|
||||
) {
|
||||
/** @var \Magento\Framework\View\Layout\ProcessorInterface $update */
|
||||
$update = $observer->getEvent()->getLayout()->getUpdate();
|
||||
$update->addUpdate('<head><css src="Plumrocket_Base::css/system/config-marketplace.css"/></head>');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Plumrocket_Base
|
||||
* @copyright Copyright (c) 2020 Plumrocket Inc. (https://plumrocket.com)
|
||||
* @license https://plumrocket.com/license End-user License Agreement
|
||||
*/
|
||||
|
||||
namespace Plumrocket\Base\Observer\Adminhtml;
|
||||
|
||||
use Magento\Framework\Event\Observer;
|
||||
use Magento\Framework\Event\ObserverInterface;
|
||||
use Magento\Framework\Exception\NoSuchEntityException;
|
||||
use Magento\Framework\Exception\NotFoundException;
|
||||
use Magento\Framework\Message\Manager;
|
||||
use Plumrocket\Base\Api\ExtensionAuthorizationRepositoryInterface;
|
||||
use Plumrocket\Base\Model\Extension\Authorization\Factory;
|
||||
use Plumrocket\Base\Model\Extension\Authorization\Key;
|
||||
use Plumrocket\Base\Model\Extension\Authorization\Key\Update;
|
||||
use Plumrocket\Base\Model\Extension\Authorization\Message;
|
||||
use Plumrocket\Base\Model\Extension\Authorization\Status\Refresh;
|
||||
use Plumrocket\Base\Model\Extension\IsPaid;
|
||||
use Plumrocket\Base\Model\Extension\Status\Disable;
|
||||
use Plumrocket\Base\Model\System\Config\GetCurrentExtensionName;
|
||||
|
||||
/**
|
||||
* Base observer
|
||||
*/
|
||||
class SystemConfigEditBefore implements ObserverInterface
|
||||
{
|
||||
/**
|
||||
* @var \Plumrocket\Base\Model\System\Config\GetCurrentExtensionName
|
||||
*/
|
||||
private $getCurrentExtensionName;
|
||||
|
||||
/**
|
||||
* @var \Plumrocket\Base\Api\ExtensionAuthorizationRepositoryInterface
|
||||
*/
|
||||
private $extensionAuthorizationRepository;
|
||||
|
||||
/**
|
||||
* @var \Magento\Framework\Message\Manager
|
||||
*/
|
||||
private $messageManager;
|
||||
|
||||
/**
|
||||
* @var \Plumrocket\Base\Model\Extension\IsPaid
|
||||
*/
|
||||
private $isPaidExtension;
|
||||
|
||||
/**
|
||||
* @var \Plumrocket\Base\Model\Extension\Authorization\Key
|
||||
*/
|
||||
private $authorizationKey;
|
||||
|
||||
/**
|
||||
* @var \Plumrocket\Base\Model\Extension\Authorization\Key\Update
|
||||
*/
|
||||
private $updateAuthorizationKey;
|
||||
|
||||
/**
|
||||
* @var \Plumrocket\Base\Model\Extension\Authorization\Status\Refresh
|
||||
*/
|
||||
private $refreshAuthorizationStatus;
|
||||
|
||||
/**
|
||||
* @var \Plumrocket\Base\Model\Extension\Authorization\Message
|
||||
*/
|
||||
private $authorizationMessage;
|
||||
|
||||
/**
|
||||
* @var \Plumrocket\Base\Model\Extension\Authorization\Factory
|
||||
*/
|
||||
private $extensionAuthorizationFactory;
|
||||
|
||||
/**
|
||||
* @var \Plumrocket\Base\Model\Extension\Status\Disable
|
||||
*/
|
||||
private $disableExtension;
|
||||
|
||||
/**
|
||||
* @param \Plumrocket\Base\Model\System\Config\GetCurrentExtensionName $getCurrentExtensionName
|
||||
* @param \Plumrocket\Base\Api\ExtensionAuthorizationRepositoryInterface $extensionAuthorizationRepository
|
||||
* @param \Magento\Framework\Message\Manager $messageManager
|
||||
* @param \Plumrocket\Base\Model\Extension\IsPaid $isPaidExtension
|
||||
* @param \Plumrocket\Base\Model\Extension\Authorization\Key $authorizationKey
|
||||
* @param \Plumrocket\Base\Model\Extension\Authorization\Key\Update $updateAuthorizationKey
|
||||
* @param \Plumrocket\Base\Model\Extension\Authorization\Status\Refresh $refreshAuthorizationStatus
|
||||
* @param \Plumrocket\Base\Model\Extension\Authorization\Message $authorizationMessage
|
||||
* @param \Plumrocket\Base\Model\Extension\Authorization\Factory $extensionAuthorizationFactory
|
||||
* @param \Plumrocket\Base\Model\Extension\Status\Disable $disableExtension
|
||||
*/
|
||||
public function __construct(
|
||||
GetCurrentExtensionName $getCurrentExtensionName,
|
||||
ExtensionAuthorizationRepositoryInterface $extensionAuthorizationRepository,
|
||||
Manager $messageManager,
|
||||
IsPaid $isPaidExtension,
|
||||
Key $authorizationKey,
|
||||
Update $updateAuthorizationKey,
|
||||
Refresh $refreshAuthorizationStatus,
|
||||
Message $authorizationMessage,
|
||||
Factory $extensionAuthorizationFactory,
|
||||
Disable $disableExtension
|
||||
) {
|
||||
$this->getCurrentExtensionName = $getCurrentExtensionName;
|
||||
$this->extensionAuthorizationRepository = $extensionAuthorizationRepository;
|
||||
$this->messageManager = $messageManager;
|
||||
$this->isPaidExtension = $isPaidExtension;
|
||||
$this->authorizationKey = $authorizationKey;
|
||||
$this->updateAuthorizationKey = $updateAuthorizationKey;
|
||||
$this->refreshAuthorizationStatus = $refreshAuthorizationStatus;
|
||||
$this->authorizationMessage = $authorizationMessage;
|
||||
$this->extensionAuthorizationFactory = $extensionAuthorizationFactory;
|
||||
$this->disableExtension = $disableExtension;
|
||||
}
|
||||
|
||||
/**
|
||||
* Predispatch admin action controller
|
||||
*
|
||||
* @param \Magento\Framework\Event\Observer $observer
|
||||
* @return void
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*/
|
||||
public function execute(Observer $observer)
|
||||
{
|
||||
try {
|
||||
$extensionName = $this->getCurrentExtensionName->execute();
|
||||
if ($this->isPaidExtension->execute($extensionName)) {
|
||||
try {
|
||||
$authorization = $this->extensionAuthorizationRepository->get($extensionName);
|
||||
} catch (NoSuchEntityException $noSuchEntityException) {
|
||||
$authorization = $this->extensionAuthorizationFactory->create($extensionName);
|
||||
}
|
||||
|
||||
if (! $this->authorizationKey->get($extensionName)) {
|
||||
$this->updateAuthorizationKey->execute($authorization);
|
||||
} elseif (! $authorization->isAuthorized() || ! $authorization->isCached()) {
|
||||
$authorization = $this->refreshAuthorizationStatus->execute($authorization);
|
||||
}
|
||||
|
||||
if (! $authorization->isAuthorized()) {
|
||||
$this->disableExtension->execute($authorization->getModuleName());
|
||||
$this->messageManager->addError($this->authorizationMessage->get($authorization));
|
||||
}
|
||||
}
|
||||
} catch (NotFoundException|NoSuchEntityException $e) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Plumrocket_Base
|
||||
* @copyright Copyright (c) 2020 Plumrocket Inc. (https://plumrocket.com)
|
||||
* @license https://plumrocket.com/license/ End-user License Agreement
|
||||
*/
|
||||
|
||||
namespace Plumrocket\Base\Observer\Adminhtml;
|
||||
|
||||
use Magento\Framework\Event\Observer;
|
||||
use Magento\Framework\Event\ObserverInterface;
|
||||
use Magento\Framework\Exception\NoSuchEntityException;
|
||||
use Magento\Framework\Exception\NotFoundException;
|
||||
use Plumrocket\Base\Api\ExtensionAuthorizationRepositoryInterface;
|
||||
use Plumrocket\Base\Model\Extension\Authorization\Factory;
|
||||
use Plumrocket\Base\Model\Extension\Authorization\Status\Refresh;
|
||||
use Plumrocket\Base\Model\Extension\IsPaid;
|
||||
use Plumrocket\Base\Model\Extension\Status\Disable;
|
||||
use Plumrocket\Base\Model\System\Config\GetCurrentExtensionName;
|
||||
|
||||
/**
|
||||
* Base observer
|
||||
*/
|
||||
class SystemConfigSaveAfter implements ObserverInterface
|
||||
{
|
||||
/**
|
||||
* @var \Plumrocket\Base\Model\System\Config\GetCurrentExtensionName
|
||||
*/
|
||||
private $getCurrentExtensionName;
|
||||
|
||||
/**
|
||||
* @var \Plumrocket\Base\Api\ExtensionAuthorizationRepositoryInterface
|
||||
*/
|
||||
private $extensionAuthorizationRepository;
|
||||
|
||||
/**
|
||||
* @var \Plumrocket\Base\Model\Extension\IsPaid
|
||||
*/
|
||||
private $isPaidExtension;
|
||||
|
||||
/**
|
||||
* @var \Plumrocket\Base\Model\Extension\Authorization\Status\Refresh
|
||||
*/
|
||||
private $refreshAuthorizationStatus;
|
||||
|
||||
/**
|
||||
* @var \Plumrocket\Base\Model\Extension\Authorization\Factory
|
||||
*/
|
||||
private $extensionAuthorizationFactory;
|
||||
|
||||
/**
|
||||
* @var \Plumrocket\Base\Model\Extension\Status\Disable
|
||||
*/
|
||||
private $disableExtension;
|
||||
|
||||
/**
|
||||
* @param \Plumrocket\Base\Model\System\Config\GetCurrentExtensionName $getCurrentExtensionName
|
||||
* @param \Plumrocket\Base\Api\ExtensionAuthorizationRepositoryInterface $extensionAuthorizationRepository
|
||||
* @param \Plumrocket\Base\Model\Extension\IsPaid $isPaidExtension
|
||||
* @param \Plumrocket\Base\Model\Extension\Authorization\Status\Refresh $refreshAuthorizationStatus
|
||||
* @param \Plumrocket\Base\Model\Extension\Authorization\Factory $extensionAuthorizationFactory
|
||||
* @param \Plumrocket\Base\Model\Extension\Status\Disable $disableExtension
|
||||
*/
|
||||
public function __construct(
|
||||
GetCurrentExtensionName $getCurrentExtensionName,
|
||||
ExtensionAuthorizationRepositoryInterface $extensionAuthorizationRepository,
|
||||
IsPaid $isPaidExtension,
|
||||
Refresh $refreshAuthorizationStatus,
|
||||
Factory $extensionAuthorizationFactory,
|
||||
Disable $disableExtension
|
||||
) {
|
||||
$this->getCurrentExtensionName = $getCurrentExtensionName;
|
||||
$this->extensionAuthorizationRepository = $extensionAuthorizationRepository;
|
||||
$this->isPaidExtension = $isPaidExtension;
|
||||
$this->refreshAuthorizationStatus = $refreshAuthorizationStatus;
|
||||
$this->extensionAuthorizationFactory = $extensionAuthorizationFactory;
|
||||
$this->disableExtension = $disableExtension;
|
||||
}
|
||||
|
||||
/**
|
||||
* Predispatch admin action controller
|
||||
*
|
||||
* @param \Magento\Framework\Event\Observer $observer
|
||||
* @return void
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*/
|
||||
public function execute(Observer $observer)
|
||||
{
|
||||
try {
|
||||
$extensionName = $this->getCurrentExtensionName->execute();
|
||||
if ($this->isPaidExtension->execute($extensionName)) {
|
||||
try {
|
||||
$authorization = $this->extensionAuthorizationRepository->get($extensionName);
|
||||
} catch (NoSuchEntityException $noSuchEntityException) {
|
||||
$authorization = $this->extensionAuthorizationFactory->create($extensionName);
|
||||
}
|
||||
$authorization = $this->refreshAuthorizationStatus->execute($authorization);
|
||||
if (! $authorization->isAuthorized()) {
|
||||
$this->disableExtension->execute($authorization->getModuleName());
|
||||
}
|
||||
}
|
||||
} catch (NotFoundException|NoSuchEntityException $e) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Plumrocket_Base
|
||||
* @copyright Copyright (c) 2020 Plumrocket Inc. (https://plumrocket.com)
|
||||
* @license https://plumrocket.com/license/ End-user License Agreement
|
||||
*/
|
||||
|
||||
namespace Plumrocket\Base\Observer;
|
||||
|
||||
use Magento\Framework\Event\Observer;
|
||||
use Magento\Framework\Event\ObserverInterface;
|
||||
|
||||
/**
|
||||
* Change status of config statistic for specific module after save config
|
||||
*
|
||||
* @since 2.3.0
|
||||
*/
|
||||
class CheckNewConfigUsageStatistic implements ObserverInterface
|
||||
{
|
||||
/**
|
||||
* @var \Plumrocket\Base\Model\Statistic\Usage\StatusInterface[]
|
||||
*/
|
||||
private $statuses;
|
||||
|
||||
/**
|
||||
* CheckNewConfigStatistic constructor.
|
||||
*
|
||||
* @param \Plumrocket\Base\Model\Statistic\Usage\StatusInterface[] $statuses
|
||||
*/
|
||||
public function __construct(array $statuses = [])
|
||||
{
|
||||
$this->statuses = $statuses;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if module has statistic.
|
||||
*
|
||||
* @param \Magento\Framework\Event\Observer $observer
|
||||
*/
|
||||
public function execute(Observer $observer)
|
||||
{
|
||||
$section = $observer->getRequest()->getParam('section', '');
|
||||
|
||||
if (isset($this->statuses[$section])) {
|
||||
$this->statuses[$section]->switchToCollect();
|
||||
}
|
||||
}
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Plumrocket_Base
|
||||
* @copyright Copyright (c) 2020 Plumrocket Inc. (https://plumrocket.com)
|
||||
* @license https://plumrocket.com/license/ End-user License Agreement
|
||||
*/
|
||||
|
||||
namespace Plumrocket\Base\Observer;
|
||||
|
||||
use Magento\Framework\Event\ObserverInterface;
|
||||
|
||||
/**
|
||||
* Base observer
|
||||
*/
|
||||
class PredispathAdminActionControllerObserver implements ObserverInterface
|
||||
{
|
||||
/**
|
||||
* @var \Plumrocket\Base\Model\AdminNotificationFeedFactory
|
||||
*/
|
||||
protected $_feedFactory;
|
||||
|
||||
/**
|
||||
* @var \Magento\Backend\Model\Auth\Session
|
||||
*/
|
||||
protected $_backendAuthSession;
|
||||
|
||||
/**
|
||||
* @param \Plumrocket\Base\Model\AdminNotificationFeedFactory $feedFactory
|
||||
* @param \Magento\Backend\Model\Auth\Session $backendAuthSession
|
||||
*/
|
||||
|
||||
public function __construct(
|
||||
\Plumrocket\Base\Model\AdminNotificationFeedFactory $feedFactory,
|
||||
\Magento\Backend\Model\Auth\Session $backendAuthSession
|
||||
) {
|
||||
$this->_feedFactory = $feedFactory;
|
||||
$this->_backendAuthSession = $backendAuthSession;
|
||||
}
|
||||
|
||||
/**
|
||||
* Predispath admin action controller
|
||||
*
|
||||
* @param \Magento\Framework\Event\Observer $observer
|
||||
* @return void
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*/
|
||||
public function execute(\Magento\Framework\Event\Observer $observer)
|
||||
{
|
||||
if ($this->_backendAuthSession->isLoggedIn()) {
|
||||
$feedModel = $this->_feedFactory->create();
|
||||
/* @var \Plumrocket\Base\Model\AdminNotificationFeed $feedModel */
|
||||
$feedModel->checkUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Plumrocket_Base
|
||||
* @copyright Copyright (c) 2020 Plumrocket Inc. (https://plumrocket.com)
|
||||
* @license https://plumrocket.com/license/ End-user License Agreement
|
||||
*/
|
||||
|
||||
namespace Plumrocket\Base\Observer;
|
||||
|
||||
use Magento\Framework\Event\Observer;
|
||||
use Magento\Framework\Event\ObserverInterface;
|
||||
|
||||
/**
|
||||
* Base observer
|
||||
*/
|
||||
class Reindex implements ObserverInterface
|
||||
{
|
||||
/**
|
||||
* @var \Plumrocket\Base\Model\Extension\Authorization\Reindex
|
||||
*/
|
||||
private $reindex;
|
||||
|
||||
/**
|
||||
* @param \Plumrocket\Base\Model\Extension\Authorization\Reindex $reindex
|
||||
*/
|
||||
public function __construct(\Plumrocket\Base\Model\Extension\Authorization\Reindex $reindex)
|
||||
{
|
||||
$this->reindex = $reindex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Predispath admin action controller
|
||||
*
|
||||
* @param \Magento\Framework\Event\Observer $observer
|
||||
* @return void
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*/
|
||||
public function execute(Observer $observer)
|
||||
{
|
||||
$this->reindex->execute();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user