ltsecurityinc安防产品在线商城代码
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user