<commit_before><?php

namespace frontend\controllers;

use frontend\models\EmployeeSearchExt;
use frontend\models\SearchBySkillsForm;
use frontend\models\SkillSearchExt;
use jk\util\SkillsHelper;
use Yii;
use yii\filters\AccessControl;
use yii\web\Controller;

class SearchEmployeeController extends Controller {

    /**
     * @inheritdoc
     */
    public function behaviors() {
        return [
            'access' => [
                'class' => AccessControl::className(),
                'only' => ['by-skill','all-employees'],
                'rules' => [
                    [
                        'actions' => ['by-skill','all-employees'],
                        'allow' => true,
                        'roles' => ['@'],
                    ],
                ],
            ],
        ];
    }

    public function actionBySkill() {
        Yii::$app->session->set('profileBackUrl', Yii::$app->request->getAbsoluteUrl());
        
        $form = new SearchBySkillsForm();
        $skillSearch = new SkillSearchExt();
        $categories = $skillSearch->allWithCategories();
        
        if( $form->load(Yii::$app->request->getQueryParams()) && $form->validate()) {
            $employeeSearch = new EmployeeSearchExt();
            $dataProvider = $employeeSearch->searchBySkills(Yii::$app->request->getQueryParam($form->formName()));
        } else {
            $dataProvider = NULL;
        }
        
        return $this->render('by-skill', [
                                            'model' => $form, 
                                            'data' => $categories,
                                            'levels' => SkillsHelper::getLevels(),
                                            'dataProvider' => $dataProvider
                                          ]);
    }

    public function actionAllEmployees() {
        Yii::$app->session->set('profileBackUrl', Yii::$app->request->getAbsoluteUrl());

        $searchModel = new EmployeeSearchExt();
        $dataProvider = $searchModel->searchAll(Yii::$app->request->getQueryParams());

        return $this->render('all-employees', ['searchModel' => $searchModel,
                    'dataProvider' => $dataProvider]);
    }<commit_msg>Params array passed to search by skills method modified to allow using Pjax features.<commit_after><?php

namespace frontend\controllers;

use frontend\models\EmployeeSearchExt;
use frontend\models\SearchBySkillsForm;
use frontend\models\SkillSearchExt;
use jk\util\SkillsHelper;
use Yii;
use yii\filters\AccessControl;
use yii\helpers\ArrayHelper;
use yii\web\Controller;

class SearchEmployeeController extends Controller {

    /**
     * @inheritdoc
     */
    public function behaviors() {
        return [
            'access' => [
                'class' => AccessControl::className(),
                'only' => ['by-skill','all-employees'],
                'rules' => [
                    [
                        'actions' => ['by-skill','all-employees'],
                        'allow' => true,
                        'roles' => ['@'],
                    ],
                ],
            ],
        ];
    }

    public function actionBySkill() {
        Yii::$app->session->set('profileBackUrl', Yii::$app->request->getAbsoluteUrl());
        
        $form = new SearchBySkillsForm();
        $skillSearch = new SkillSearchExt();
        $categories = $skillSearch->allWithCategories();
        
        if( $form->load(Yii::$app->request->getQueryParams()) && $form->validate()) {
            $employeeSearch = new EmployeeSearchExt();
            // Preparing search params array. Some processing required to enable Pjax features.
            $params = Yii::$app->request->getQueryParams();
            $formParams = ArrayHelper::remove($params, $form->formName());
            $searchParams = ArrayHelper::merge($params, $formParams);
            
            $dataProvider = $employeeSearch->searchBySkills($searchParams);
        } else {
            $dataProvider = NULL;
        }
        
        return $this->render('by-skill', [
                                            'model' => $form, 
                                            'data' => $categories,
                                            'levels' => SkillsHelper::getLevels(),
                                            'dataProvider' => $dataProvider
                                          ]);
    }

    public function actionAllEmployees() {
        Yii::$app->session->set('profileBackUrl', Yii::$app->request->getAbsoluteUrl());

        $searchModel = new EmployeeSearchExt();
        $dataProvider = $searchModel->searchAll(Yii::$app->request->getQueryParams());

        return $this->render('all-employees', ['searchModel' => $searchModel,
                    'dataProvider' => $dataProvider]);
    }
{'fraction_non_alphanumeric': 0.13863636363636364, 'fraction_numerical': 0.0, 'mean_word_length': 1.7211916807195053, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 73, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 20, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1209579', 'n_tokens_mistral': 1229, 'n_tokens_neox': 1193, 'n_words': 208}