init
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
namespace WeltPixel\Backend\Controller\Adminhtml;
|
||||
|
||||
abstract class Debugger extends \Magento\Backend\App\Action
|
||||
{
|
||||
/**
|
||||
* Authorization level of a basic admin session
|
||||
*
|
||||
* @see _isAllowed()
|
||||
*/
|
||||
const ADMIN_RESOURCE = 'WeltPixel_Backend::WeltPixel_Debugger';
|
||||
|
||||
/**
|
||||
* Core registry
|
||||
*
|
||||
* @var \Magento\Framework\Registry
|
||||
*/
|
||||
protected $_coreRegistry;
|
||||
|
||||
/**
|
||||
* @param \Magento\Backend\App\Action\Context $context
|
||||
* @param \Magento\Framework\Registry $coreRegistry
|
||||
*/
|
||||
public function __construct(\Magento\Backend\App\Action\Context $context, \Magento\Framework\Registry $coreRegistry)
|
||||
{
|
||||
$this->_coreRegistry = $coreRegistry;
|
||||
parent::__construct($context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Init page
|
||||
*
|
||||
* @param \Magento\Backend\Model\View\Result\Page $resultPage
|
||||
* @return \Magento\Backend\Model\View\Result\Page
|
||||
*/
|
||||
protected function initPage($resultPage)
|
||||
{
|
||||
$resultPage->setActiveMenu('WeltPixel_Backend::WeltPixel_Debugger');
|
||||
return $resultPage;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
namespace WeltPixel\Backend\Controller\Adminhtml\Debugger;
|
||||
|
||||
class Modules extends \WeltPixel\Backend\Controller\Adminhtml\Debugger
|
||||
{
|
||||
const ADMIN_RESOURCE = 'WeltPixel_Backend::WeltPixel_Debugger_Modules';
|
||||
|
||||
/**
|
||||
* @var \Magento\Framework\View\Result\PageFactory
|
||||
*/
|
||||
protected $resultPageFactory;
|
||||
|
||||
/**
|
||||
* @param \Magento\Backend\App\Action\Context $context
|
||||
* @param \Magento\Framework\Registry $coreRegistry
|
||||
* @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
|
||||
*/
|
||||
public function __construct(
|
||||
\Magento\Backend\App\Action\Context $context,
|
||||
\Magento\Framework\Registry $coreRegistry,
|
||||
\Magento\Framework\View\Result\PageFactory $resultPageFactory
|
||||
) {
|
||||
$this->resultPageFactory = $resultPageFactory;
|
||||
parent::__construct($context, $coreRegistry);
|
||||
}
|
||||
|
||||
/**
|
||||
* Index action
|
||||
*
|
||||
* @return \Magento\Framework\Controller\ResultInterface
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
/** @var \Magento\Backend\Model\View\Result\Page $resultPage */
|
||||
$resultPage = $this->resultPageFactory->create();
|
||||
$this->initPage($resultPage)->getConfig()->getTitle()->prepend(__('Modules'));
|
||||
return $resultPage;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
namespace WeltPixel\Backend\Controller\Adminhtml\Debugger;
|
||||
|
||||
class Rewrites extends \WeltPixel\Backend\Controller\Adminhtml\Debugger
|
||||
{
|
||||
const ADMIN_RESOURCE = 'WeltPixel_Backend::WeltPixel_Debugger';
|
||||
|
||||
/**
|
||||
* @var \Magento\Framework\View\Result\PageFactory
|
||||
*/
|
||||
protected $resultPageFactory;
|
||||
|
||||
/**
|
||||
* @param \Magento\Backend\App\Action\Context $context
|
||||
* @param \Magento\Framework\Registry $coreRegistry
|
||||
* @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
|
||||
*/
|
||||
public function __construct(
|
||||
\Magento\Backend\App\Action\Context $context,
|
||||
\Magento\Framework\Registry $coreRegistry,
|
||||
\Magento\Framework\View\Result\PageFactory $resultPageFactory
|
||||
) {
|
||||
$this->resultPageFactory = $resultPageFactory;
|
||||
parent::__construct($context, $coreRegistry);
|
||||
}
|
||||
|
||||
/**
|
||||
* Index action
|
||||
*
|
||||
* @return \Magento\Framework\Controller\ResultInterface
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
/** @var \Magento\Backend\Model\View\Result\Page $resultPage */
|
||||
$resultPage = $this->resultPageFactory->create();
|
||||
$this->initPage($resultPage)->getConfig()->getTitle()->prepend(__('Check Rewrites / Preferences'));
|
||||
return $resultPage;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
namespace WeltPixel\Backend\Controller\Adminhtml\Debugger;
|
||||
|
||||
class Rewritesall extends \WeltPixel\Backend\Controller\Adminhtml\Debugger\Rewrites
|
||||
{
|
||||
/**
|
||||
* @var \Magento\Framework\View\Result\PageFactory
|
||||
*/
|
||||
protected $resultPageFactory;
|
||||
|
||||
/**
|
||||
* @param \Magento\Backend\App\Action\Context $context
|
||||
* @param \Magento\Framework\Registry $coreRegistry
|
||||
* @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
|
||||
*/
|
||||
public function __construct(
|
||||
\Magento\Backend\App\Action\Context $context,
|
||||
\Magento\Framework\Registry $coreRegistry,
|
||||
\Magento\Framework\View\Result\PageFactory $resultPageFactory
|
||||
)
|
||||
{
|
||||
$this->resultPageFactory = $resultPageFactory;
|
||||
parent::__construct($context, $coreRegistry, $resultPageFactory);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Magento\Framework\Controller\ResultInterface
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
|
||||
$this->_session->setDebuggerRewite(true);
|
||||
$resultRedirect = $this->resultRedirectFactory->create();
|
||||
return $resultRedirect->setPath('*/*/rewrites');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
namespace WeltPixel\Backend\Controller\Adminhtml\Debugger;
|
||||
|
||||
class Rewritescustom extends \WeltPixel\Backend\Controller\Adminhtml\Debugger\Rewrites
|
||||
{
|
||||
/**
|
||||
* @var \Magento\Framework\View\Result\PageFactory
|
||||
*/
|
||||
protected $resultPageFactory;
|
||||
|
||||
/**
|
||||
* @param \Magento\Backend\App\Action\Context $context
|
||||
* @param \Magento\Framework\Registry $coreRegistry
|
||||
* @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
|
||||
*/
|
||||
public function __construct(
|
||||
\Magento\Backend\App\Action\Context $context,
|
||||
\Magento\Framework\Registry $coreRegistry,
|
||||
\Magento\Framework\View\Result\PageFactory $resultPageFactory
|
||||
)
|
||||
{
|
||||
$this->resultPageFactory = $resultPageFactory;
|
||||
parent::__construct($context, $coreRegistry, $resultPageFactory);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Magento\Framework\Controller\ResultInterface
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
|
||||
$this->_session->setDebuggerRewite(false);
|
||||
$resultRedirect = $this->resultRedirectFactory->create();
|
||||
return $resultRedirect->setPath('*/*/rewrites');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
namespace WeltPixel\Backend\Controller\Adminhtml;
|
||||
|
||||
abstract class Licenses extends \Magento\Backend\App\Action
|
||||
{
|
||||
/**
|
||||
* Authorization level of a basic admin session
|
||||
*
|
||||
* @see _isAllowed()
|
||||
*/
|
||||
const ADMIN_RESOURCE = 'WeltPixel_Backend::WeltPixel_Licenses';
|
||||
|
||||
/**
|
||||
* @var \Magento\Framework\View\Result\PageFactory
|
||||
*/
|
||||
protected $resultPageFactory;
|
||||
|
||||
/**
|
||||
* @var \Magento\Framework\Controller\Result\JsonFactory
|
||||
*/
|
||||
protected $resultJsonFactory;
|
||||
|
||||
/**
|
||||
* @var \WeltPixel\Backend\Helper\License
|
||||
*/
|
||||
protected $wpHelper;
|
||||
|
||||
/**
|
||||
* @var \WeltPixel\Backend\Model\LicenseFactory
|
||||
*/
|
||||
protected $licenseFactory;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param \Magento\Backend\App\Action\Context $context
|
||||
* @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
|
||||
* @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
|
||||
* @param \WeltPixel\Backend\Helper\License $wpHelper
|
||||
* @param \WeltPixel\Backend\Model\LicenseFactory $licenseFactory
|
||||
*/
|
||||
public function __construct(
|
||||
\Magento\Backend\App\Action\Context $context,
|
||||
\Magento\Framework\View\Result\PageFactory $resultPageFactory,
|
||||
\Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory,
|
||||
\WeltPixel\Backend\Helper\License $wpHelper,
|
||||
\WeltPixel\Backend\Model\LicenseFactory $licenseFactory
|
||||
) {
|
||||
parent::__construct($context);
|
||||
$this->resultPageFactory = $resultPageFactory;
|
||||
$this->resultJsonFactory = $resultJsonFactory;
|
||||
$this->wpHelper = $wpHelper;
|
||||
$this->licenseFactory = $licenseFactory;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
namespace WeltPixel\Backend\Controller\Adminhtml\Licenses;
|
||||
|
||||
class Index extends \WeltPixel\Backend\Controller\Adminhtml\Licenses
|
||||
{
|
||||
const ADMIN_RESOURCE = 'WeltPixel_Backend::Modules_License';
|
||||
|
||||
/**
|
||||
* @return \Magento\Framework\View\Result\Page
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
$this->wpHelper->checkAndUpdate();
|
||||
return $resultPage = $this->resultPageFactory->create();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
namespace WeltPixel\Backend\Controller\Adminhtml\Licenses;
|
||||
|
||||
class Post extends \WeltPixel\Backend\Controller\Adminhtml\Licenses
|
||||
{
|
||||
const ADMIN_RESOURCE = 'WeltPixel_Backend::Modules_License';
|
||||
|
||||
/**
|
||||
* @return \Magento\Framework\View\Result\Page
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
$result = [];
|
||||
|
||||
$lcK = trim($this->getRequest()->getParam('license'));
|
||||
$moduleName = $this->getRequest()->getParam('module_name');
|
||||
|
||||
try {
|
||||
$license = $this->licenseFactory->create();
|
||||
$license->load($moduleName, 'module_name');
|
||||
|
||||
$license->setModuleName($moduleName);
|
||||
$license->setLicenseKey($lcK);
|
||||
$license->save();
|
||||
$license->updMdsInf();
|
||||
|
||||
$result['error'] = false;
|
||||
$result['license'] = $lcK;
|
||||
$result['module_name'] = $moduleName;
|
||||
$licenseValidity = $license->isLcVd($lcK, $moduleName);
|
||||
$result['is_valid'] = ($licenseValidity) ? 'license-status-ok' : 'license-status-nok';
|
||||
$result['is_valid_msg'] = ($licenseValidity) ? __('Valid') : __('Invalid');
|
||||
$result['message'] = __('The license key was successfully updated.');
|
||||
$result['message'] .= "<br/><br/>";
|
||||
if ($licenseValidity) {
|
||||
$result['message'] .= '<div class="license-pmsg valid-license-pmsg">' . __('The license key introduced is valid') . '</div>';
|
||||
} else {
|
||||
$userFriendlyNames = $license->getUserFriendlyModuleNames();
|
||||
$options = [];
|
||||
$options['module_name'] = $moduleName;
|
||||
$options['license'] = $lcK;
|
||||
$licenseErrorMessage = $this->wpHelper->getLicenseErrorMessage($options, $userFriendlyNames, false);
|
||||
$result['message'] .= '<div class="license-pmsg invalid-license-pmsg">' . __('The license key you entered is invalid.')
|
||||
. '<br/>' . $licenseErrorMessage . '</div><br/>'
|
||||
. '<b>' . __('Common reasons:') . '</b><br>'
|
||||
. __('- Wrong domain name - check active license domain under My Downloadable Products section of your weltpixel.com account. License allows using the product on one Magento installation with any number of store views / URLs. Product can be installed on up to 5 sub-domains of the licensed domain for testing purpose, including domains .local | .localhost | .localdev | .dev | .development | .staging | .stage Ex: staging.domain.com, development.domain.com, domain.local, domain.dev etc..') . '<br/><br/>'
|
||||
. __('- Wrong Magento edition - using a Magento Open Source license key for a Magento Commerce installation.') . '<br/><br/>'
|
||||
. __('- Wrong module - using a license key from a different product or product pack.');
|
||||
}
|
||||
} catch (\Exception $ex) {
|
||||
$result['error'] = true;
|
||||
$result['message'] = __('There was a problem with the license key saving.') . ' ' . $ex->getMessage();
|
||||
}
|
||||
|
||||
$resultJson = $this->resultJsonFactory->create();
|
||||
$resultJson->setData($result);
|
||||
return $resultJson;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user