123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- <?php
- /**
- * Copyright © Magento, Inc. All rights reserved.
- * See COPYING.txt for license details.
- */
- namespace Magento\Customer\Block\Adminhtml\Group;
- use Magento\Customer\Api\GroupManagementInterface;
- use Magento\Customer\Api\GroupRepositoryInterface;
- use Magento\Customer\Controller\RegistryConstants;
- /**
- * Customer group edit block
- */
- class Edit extends \Magento\Backend\Block\Widget\Form\Container
- {
- /**
- * Core registry
- *
- * @var \Magento\Framework\Registry
- */
- protected $coreRegistry;
- /**
- * @var GroupRepositoryInterface
- */
- protected $groupRepository;
- /**
- * @var GroupManagementInterface
- */
- protected $groupManagement;
- /**
- * Constructor
- *
- * @param \Magento\Backend\Block\Widget\Context $context
- * @param \Magento\Framework\Registry $registry
- * @param GroupRepositoryInterface $groupRepository
- * @param GroupManagementInterface $groupManagement
- * @param array $data
- */
- public function __construct(
- \Magento\Backend\Block\Widget\Context $context,
- \Magento\Framework\Registry $registry,
- GroupRepositoryInterface $groupRepository,
- GroupManagementInterface $groupManagement,
- array $data = []
- ) {
- $this->coreRegistry = $registry;
- $this->groupRepository = $groupRepository;
- $this->groupManagement = $groupManagement;
- parent::__construct($context, $data);
- }
- /**
- * Update Save and Delete buttons. Remove Delete button if group can't be deleted.
- *
- * @return void
- */
- protected function _construct()
- {
- parent::_construct();
- $this->_objectId = 'id';
- $this->_controller = 'adminhtml_group';
- $this->_blockGroup = 'Magento_Customer';
- $this->buttonList->update('save', 'label', __('Save Customer Group'));
- $this->buttonList->update('delete', 'label', __('Delete Customer Group'));
- $groupId = $this->coreRegistry->registry(RegistryConstants::CURRENT_GROUP_ID);
- if (!$groupId || $this->groupManagement->isReadonly($groupId)) {
- $this->buttonList->remove('delete');
- }
- }
- /**
- * Retrieve the header text, either editing an existing group or creating a new one.
- *
- * @return \Magento\Framework\Phrase
- */
- public function getHeaderText()
- {
- $groupId = $this->coreRegistry->registry(RegistryConstants::CURRENT_GROUP_ID);
- if ($groupId === null) {
- return __('New Customer Group');
- } else {
- $group = $this->groupRepository->getById($groupId);
- return __('Edit Customer Group "%1"', $this->escapeHtml($group->getCode()));
- }
- }
- /**
- * Retrieve CSS classes added to the header.
- *
- * @return string
- */
- public function getHeaderCssClass()
- {
- return 'icon-head head-customer-groups';
- }
- }
|