encryptor = $encryptor; $this->change = $change; $this->cache = $cache; parent::__construct($context); } /** * Process saving new encryption key * * @return void */ public function execute() { try { $key = null; if (0 == $this->getRequest()->getPost('generate_random')) { $key = $this->getRequest()->getPost('crypt_key'); if (empty($key)) { throw new \Exception(__('Please enter an encryption key.')); } $this->encryptor->validateKey($key); } $newKey = $this->change->changeEncryptionKey($key); $this->messageManager->addSuccessMessage(__('The encryption key has been changed.')); if (!$key) { $this->messageManager->addNoticeMessage( __( 'This is your new encryption key: %1. ' . 'Be sure to write it down and take good care of it!', $newKey ) ); } $this->cache->clean(); } catch (\Exception $e) { $this->messageManager->addErrorMessage($e->getMessage()); $this->_session->setFormData(['crypt_key' => $key]); } $this->_redirect('adminhtml/*/'); } }