ltsecurityinc安防产品在线商城代码
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
/**
|
||||
* @author Olegnax
|
||||
* @package Olegnax_GoogleMap
|
||||
* @copyright Copyright (c) 2020 Olegnax (http://olegnax.com/). All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
* @noinspection PhpDeprecationInspection
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Olegnax\GoogleMap\Controller\Adminhtml\Location;
|
||||
|
||||
use Magento\Backend\App\Action\Context;
|
||||
use Magento\Backend\Model\View\Result\Page;
|
||||
use Magento\Backend\Model\View\Result\Redirect;
|
||||
use Magento\Framework\Controller\ResultInterface;
|
||||
use Magento\Framework\Registry;
|
||||
use Magento\Framework\View\Result\PageFactory;
|
||||
use Olegnax\GoogleMap\Model\Location;
|
||||
|
||||
class Edit extends \Olegnax\GoogleMap\Controller\Adminhtml\Location
|
||||
{
|
||||
|
||||
/**
|
||||
* @var PageFactory
|
||||
*/
|
||||
protected $resultPageFactory;
|
||||
|
||||
/**
|
||||
* @param Context $context
|
||||
* @param Registry $coreRegistry
|
||||
* @param PageFactory $resultPageFactory
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context,
|
||||
Registry $coreRegistry,
|
||||
PageFactory $resultPageFactory
|
||||
) {
|
||||
$this->resultPageFactory = $resultPageFactory;
|
||||
parent::__construct($context, $coreRegistry);
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit action
|
||||
*
|
||||
* @return ResultInterface
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
// 1. Get ID and create model
|
||||
$id = $this->getRequest()->getParam('location_id');
|
||||
$model = $this->_objectManager->create(Location::class);
|
||||
|
||||
// 2. Initial checking
|
||||
if ($id) {
|
||||
$model->load($id);
|
||||
if (!$model->getId()) {
|
||||
$this->messageManager->addErrorMessage(__('This Location no longer exists.'));
|
||||
/** @var Redirect $resultRedirect */
|
||||
$resultRedirect = $this->resultRedirectFactory->create();
|
||||
return $resultRedirect->setPath('*/*/');
|
||||
}
|
||||
}
|
||||
$this->_coreRegistry->register('olegnax_googlemap_location', $model);
|
||||
|
||||
// 3. Build edit form
|
||||
/** @var Page $resultPage */
|
||||
$resultPage = $this->resultPageFactory->create();
|
||||
$this->initPage($resultPage)->addBreadcrumb(
|
||||
$id ? __('Edit Location') : __('New Location'),
|
||||
$id ? __('Edit Location') : __('New Location')
|
||||
);
|
||||
$resultPage->getConfig()->getTitle()->prepend(__('Locations'));
|
||||
$resultPage->getConfig()->getTitle()->prepend(
|
||||
$model->getId()
|
||||
? __(
|
||||
'Edit Location %1',
|
||||
$model->getId()
|
||||
)
|
||||
: __('New Location')
|
||||
);
|
||||
return $resultPage;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user