NewAction.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. /**
  3. *
  4. * Copyright © Magento, Inc. All rights reserved.
  5. * See COPYING.txt for license details.
  6. */
  7. namespace Magento\Customer\Controller\Adminhtml\Group;
  8. use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
  9. use Magento\Customer\Controller\RegistryConstants;
  10. class NewAction extends \Magento\Customer\Controller\Adminhtml\Group implements HttpGetActionInterface
  11. {
  12. /**
  13. * Initialize current group and set it in the registry.
  14. *
  15. * @return int
  16. */
  17. protected function _initGroup()
  18. {
  19. $groupId = $this->getRequest()->getParam('id');
  20. $this->_coreRegistry->register(RegistryConstants::CURRENT_GROUP_ID, $groupId);
  21. return $groupId;
  22. }
  23. /**
  24. * Edit or create customer group.
  25. *
  26. * @return \Magento\Backend\Model\View\Result\Page
  27. */
  28. public function execute()
  29. {
  30. $groupId = $this->_initGroup();
  31. /** @var \Magento\Backend\Model\View\Result\Page $resultPage */
  32. $resultPage = $this->resultPageFactory->create();
  33. $resultPage->setActiveMenu('Magento_Customer::customer_group');
  34. $resultPage->getConfig()->getTitle()->prepend(__('Customer Groups'));
  35. $resultPage->addBreadcrumb(__('Customers'), __('Customers'));
  36. $resultPage->addBreadcrumb(__('Customer Groups'), __('Customer Groups'), $this->getUrl('customer/group'));
  37. if ($groupId === null) {
  38. $resultPage->addBreadcrumb(__('New Group'), __('New Customer Groups'));
  39. $resultPage->getConfig()->getTitle()->prepend(__('New Customer Group'));
  40. } else {
  41. $resultPage->addBreadcrumb(__('Edit Group'), __('Edit Customer Groups'));
  42. $resultPage->getConfig()->getTitle()->prepend(
  43. $this->groupRepository->getById($groupId)->getCode()
  44. );
  45. }
  46. $resultPage->getLayout()->addBlock(\Magento\Customer\Block\Adminhtml\Group\Edit::class, 'group', 'content')
  47. ->setEditMode((bool)$groupId);
  48. return $resultPage;
  49. }
  50. }