_coreRegistry = $coreRegistry; $this->_fileFactory = $fileFactory; $this->_customerFactory = $customerFactory; $this->_addressFactory = $addressFactory; $this->_formFactory = $formFactory; $this->_subscriberFactory = $subscriberFactory; $this->_viewHelper = $viewHelper; $this->_random = $random; $this->_customerRepository = $customerRepository; $this->_extensibleDataObjectConverter = $extensibleDataObjectConverter; $this->addressMapper = $addressMapper; $this->customerAccountManagement = $customerAccountManagement; $this->addressRepository = $addressRepository; $this->customerDataFactory = $customerDataFactory; $this->addressDataFactory = $addressDataFactory; $this->customerMapper = $customerMapper; $this->dataObjectProcessor = $dataObjectProcessor; $this->_objectFactory = $objectFactory; $this->dataObjectHelper = $dataObjectHelper; $this->layoutFactory = $layoutFactory; $this->resultLayoutFactory = $resultLayoutFactory; $this->resultPageFactory = $resultPageFactory; $this->resultForwardFactory = $resultForwardFactory; $this->resultJsonFactory = $resultJsonFactory; parent::__construct($context); } /** * Customer initialization * * @return string customer id */ protected function initCurrentCustomer() { $customerId = (int)$this->getRequest()->getParam('id'); if ($customerId) { $this->_coreRegistry->register(RegistryConstants::CURRENT_CUSTOMER_ID, $customerId); } return $customerId; } /** * Prepare customer default title * * @param \Magento\Backend\Model\View\Result\Page $resultPage * @return void */ protected function prepareDefaultCustomerTitle(\Magento\Backend\Model\View\Result\Page $resultPage) { $resultPage->getConfig()->getTitle()->prepend(__('Customers')); } /** * Add errors messages to session. * * @param array|string $messages * @return void * * @SuppressWarnings(PHPMD.UnusedLocalVariable) */ protected function _addSessionErrorMessages($messages) { $messages = (array)$messages; $session = $this->_getSession(); $callback = function ($error) use ($session) { if (!$error instanceof Error) { $error = new Error($error); } $this->messageManager->addMessage($error); }; array_walk_recursive($messages, $callback); } /** * Helper function that handles mass actions by taking in a callable for handling a single customer action. * * @param callable $singleAction A single action callable that takes a customer ID as input * @param int[] $customerIds Array of customer Ids to perform the action upon * @return int Number of customers successfully acted upon * @deprecated 101.0.0 */ protected function actUponMultipleCustomers(callable $singleAction, $customerIds) { if (!is_array($customerIds)) { $this->messageManager->addError(__('Please select customer(s).')); return 0; } $customersUpdated = 0; foreach ($customerIds as $customerId) { try { $singleAction($customerId); $customersUpdated++; } catch (\Exception $exception) { $this->messageManager->addError($exception->getMessage()); } } return $customersUpdated; } }