From ecc900a1d7a862ac99b26632daf91f0a8b02be97 Mon Sep 17 00:00:00 2001 From: tofid Date: Mon, 28 Nov 2016 18:35:52 +0200 Subject: [PATCH] Moved Transfer action to Transfer controller --- src/controllers/DomainController.php | 41 -------------------------- src/controllers/TransferController.php | 41 ++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 41 deletions(-) diff --git a/src/controllers/DomainController.php b/src/controllers/DomainController.php index 624e20e9..d03bcd29 100644 --- a/src/controllers/DomainController.php +++ b/src/controllers/DomainController.php @@ -525,47 +525,6 @@ public function actionRenew() return $this->redirect(Yii::$app->request->referrer); } - public function actionTransfer() - { - $model = new Domain(); - $model->scenario = 'transfer'; - $transferDataProvider = null; - if (Yii::$app->request->isPost) { - $post = Yii::$app->request->post($model->formName(), []); - if (!empty($post[0]['domains'])) { - $domains = []; - foreach (StringHelper::explode($post[0]['domains'], "\n") as $line) { - preg_match('/^([a-z0-9][0-9a-z.-]+)(?:[,;\s]+)(.*)/i', $line, $matches); - if ($matches) { - $domain = strtolower($matches[1]); - $password = $matches[2]; - $domains[] = compact('domain', 'password'); - } - } - $post = $domains; - } - - $collection = (new Collection(['model' => $model]))->load($post); - $models = $collection->getModels(); - - foreach ($models as $model) { - try { - Domain::perform('CheckTransfer', $model->getAttributes(['domain', 'password'])); - } catch (ErrorResponseException $e) { - $model->addError('password', $e->getMessage()); - } - } - - Yii::$app->session->setFlash('transferGrid', 1); - $transferDataProvider = new ArrayDataProvider(['models' => $models]); - } - - return $this->render('transfer', [ - 'model' => $model, - 'transferDataProvider' => $transferDataProvider, - ]); - } - public function actionGetPassword() { $return = ['status' => 'error']; diff --git a/src/controllers/TransferController.php b/src/controllers/TransferController.php index 4f9d8c17..f695278b 100644 --- a/src/controllers/TransferController.php +++ b/src/controllers/TransferController.php @@ -114,4 +114,45 @@ public function actionIndex() 'transferDataProvider' => $transferDataProvider, ]); } + + public function actionTransfer() + { + $model = new Domain(); + $model->scenario = 'transfer'; + $transferDataProvider = null; + if (Yii::$app->request->isPost) { + $post = Yii::$app->request->post($model->formName(), []); + if (!empty($post[0]['domains'])) { + $domains = []; + foreach (StringHelper::explode($post[0]['domains'], "\n") as $line) { + preg_match('/^([a-z0-9][0-9a-z.-]+)(?:[,;\s]+)(.*)/i', $line, $matches); + if ($matches) { + $domain = strtolower($matches[1]); + $password = $matches[2]; + $domains[] = compact('domain', 'password'); + } + } + $post = $domains; + } + + $collection = (new Collection(['model' => $model]))->load($post); + $models = $collection->getModels(); + + foreach ($models as $model) { + try { + Domain::perform('CheckTransfer', $model->getAttributes(['domain', 'password'])); + } catch (ErrorResponseException $e) { + $model->addError('password', $e->getMessage()); + } + } + + Yii::$app->session->setFlash('transferGrid', 1); + $transferDataProvider = new ArrayDataProvider(['models' => $models]); + } + + return $this->render('index', [ + 'model' => $model, + 'transferDataProvider' => $transferDataProvider, + ]); + } }