<commit_before><?php
/**
 * Domain plugin for HiPanel
 *
 * @link      https://github.com/hiqdev/hipanel-module-domain
 * @package   hipanel-module-domain
 * @license   BSD-3-Clause
 * @copyright Copyright (c) 2015-2017, HiQDev (http://hiqdev.com/)
 */

namespace hipanel\modules\domain\controllers;

use hipanel\helpers\ArrayHelper;
use hipanel\modules\domain\forms\BulkCheckForm;
use hipanel\modules\domain\forms\CheckForm;
use hipanel\modules\domain\repositories\DomainTariffRepository;
use Yii;
use yii\base\Module;
use yii\web\NotFoundHttpException;

class CheckController extends \hipanel\base\CrudController
{
    /**
     * @var DomainTariffRepository
     */
    protected $domainTariffRepository;

    public $defaultAction = 'check-domain';

    public function __construct($id, Module $module, DomainTariffRepository $domainTariffRepository, array $config = [])
    {
        parent::__construct($id, $module, $config);

        $this->domainTariffRepository = $domainTariffRepository;
    }

    private function getAvailableZones()
    {
        $zones = $this->domainTariffRepository->getAvailableZones();

        if ($zones === []) {
            throw new NotFoundHttpException('No available domain zones found.');
        }

        return $zones;
    }

    private function getAvailableZonesList()
    {
        return ArrayHelper::map($this->getAvailableZones(), 'zone', function ($resource) {
            return '.' . $resource->zone;
        });
    }

    public function actionCheck()
    {
        session_write_close();
        Yii::$app->get('hiart')->disableAuth();

        $zones = $this->getAvailableZonesList();
        $model = new CheckForm($zones);

        if ($model->load(Yii::$app->request->post()) && $model->validate()) {
            if ($model->checkIsAvailable()) {
                foreach ($this->getAvailableZones() as $resource) {
                    if ($resource->zone === $model->zone) {
                        $model->resource = $resource;
                        break;
                    }
                }
            }

            return $this->renderAjax('_checkDomainItem', [
                'model' => $model,
            ]);
        }

        return Yii::$app->end();
    }

    public function actionCheckDomain()
    {
        $results = [];
        $availableZones = $this->getAvailableZonesList();
        $bulkForm = new BulkCheckForm($availableZones);

        if ($bulkForm->load(Yii::$app->request->get(), '') && $bulkForm->validate()) {
            $results = $bulkForm->variateAll();
        }

        return $this->render('checkDomain', [
            'model' => $bulkForm,
            'dropDownZonesOptions' => $availableZones,
            'results' => $results,
        ]);
    }
}
<commit_msg>Removed not found exception from CheckController::getAvailableZonesList<commit_after><?php
/**
 * Domain plugin for HiPanel
 *
 * @link      https://github.com/hiqdev/hipanel-module-domain
 * @package   hipanel-module-domain
 * @license   BSD-3-Clause
 * @copyright Copyright (c) 2015-2017, HiQDev (http://hiqdev.com/)
 */

namespace hipanel\modules\domain\controllers;

use hipanel\helpers\ArrayHelper;
use hipanel\modules\domain\forms\BulkCheckForm;
use hipanel\modules\domain\forms\CheckForm;
use hipanel\modules\domain\repositories\DomainTariffRepository;
use Yii;
use yii\base\Module;
use yii\web\NotFoundHttpException;

class CheckController extends \hipanel\base\CrudController
{
    /**
     * @var DomainTariffRepository
     */
    protected $domainTariffRepository;

    public $defaultAction = 'check-domain';

    public function __construct($id, Module $module, DomainTariffRepository $domainTariffRepository, array $config = [])
    {
        parent::__construct($id, $module, $config);

        $this->domainTariffRepository = $domainTariffRepository;
    }

    private function getAvailableZones()
    {
        $zones = $this->domainTariffRepository->getAvailableZones();

        return $zones;
    }

    private function getAvailableZonesList()
    {
        return ArrayHelper::map($this->getAvailableZones(), 'zone', function ($resource) {
            return '.' . $resource->zone;
        });
    }

    public function actionCheck()
    {
        session_write_close();
        Yii::$app->get('hiart')->disableAuth();

        $zones = $this->getAvailableZonesList();
        $model = new CheckForm($zones);

        if ($model->load(Yii::$app->request->post()) && $model->validate()) {
            if ($model->checkIsAvailable()) {
                foreach ($this->getAvailableZones() as $resource) {
                    if ($resource->zone === $model->zone) {
                        $model->resource = $resource;
                        break;
                    }
                }
            }

            return $this->renderAjax('_checkDomainItem', [
                'model' => $model,
            ]);
        }

        return Yii::$app->end();
    }

    public function actionCheckDomain()
    {
        $results = [];
        $availableZones = $this->getAvailableZonesList();
        $bulkForm = new BulkCheckForm($availableZones);

        if ($bulkForm->load(Yii::$app->request->get(), '') && $bulkForm->validate()) {
            $results = $bulkForm->variateAll();
        }

        return $this->render('checkDomain', [
            'model' => $bulkForm,
            'dropDownZonesOptions' => $availableZones,
            'results' => $results,
        ]);
    }
}

{'fraction_non_alphanumeric': 0.14236174484394962, 'fraction_numerical': 0.003285271034860376, 'mean_word_length': 2.3973961562306263, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 63, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2997608', 'n_tokens_mistral': 1605, 'n_tokens_neox': 1572, 'n_words': 270}