ltsecurityinc安防产品在线商城代码
This commit is contained in:
+34
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* @author Amasty Team
|
||||
* @copyright Copyright (c) Amasty (https://www.amasty.com)
|
||||
* @package Admin Actions Log for Magento 2
|
||||
*/
|
||||
|
||||
namespace Amasty\AdminActionsLog\Restoring\RestoreValidator;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\Data\LogEntryInterface;
|
||||
use Amasty\AdminActionsLog\Model\OptionSource\LogEntryTypes;
|
||||
|
||||
class LogEntryTypeValidator implements RestoreValidatorInterface
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $notRestorableCategories;
|
||||
|
||||
public function __construct(
|
||||
array $notRestorableCategories
|
||||
) {
|
||||
$this->notRestorableCategories = $notRestorableCategories;
|
||||
}
|
||||
|
||||
public function isValid(LogEntryInterface $logEntry): bool
|
||||
{
|
||||
return $logEntry->getType() == LogEntryTypes::TYPE_EDIT
|
||||
&& !in_array($logEntry->getCategory(), $this->notRestorableCategories);
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* @author Amasty Team
|
||||
* @copyright Copyright (c) Amasty (https://www.amasty.com)
|
||||
* @package Admin Actions Log for Magento 2
|
||||
*/
|
||||
|
||||
namespace Amasty\AdminActionsLog\Restoring\RestoreValidator;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\Data\LogEntryInterface;
|
||||
|
||||
interface RestoreValidatorInterface
|
||||
{
|
||||
public function isValid(LogEntryInterface $logEntry): bool;
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* @author Amasty Team
|
||||
* @copyright Copyright (c) Amasty (https://www.amasty.com)
|
||||
* @package Admin Actions Log for Magento 2
|
||||
*/
|
||||
|
||||
namespace Amasty\AdminActionsLog\Restoring\RestoreValidator;
|
||||
|
||||
use Amasty\AdminActionsLog\Api\Data\LogEntryInterface;
|
||||
use Magento\Framework\Exception\NoSuchEntityException;
|
||||
use Magento\Store\Model\StoreManagerInterface;
|
||||
|
||||
class ScopeValidator implements RestoreValidatorInterface
|
||||
{
|
||||
/**
|
||||
* @var StoreManagerInterface
|
||||
*/
|
||||
private $storeManager;
|
||||
|
||||
public function __construct(
|
||||
StoreManagerInterface $storeManager
|
||||
) {
|
||||
$this->storeManager = $storeManager;
|
||||
}
|
||||
|
||||
public function isValid(LogEntryInterface $logEntry): bool
|
||||
{
|
||||
try {
|
||||
$this->storeManager->getStore((int)$logEntry->getStoreId());
|
||||
return true;
|
||||
} catch (NoSuchEntityException $exception) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user