2021-06-09 18:06:13 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace frontend\modules\api\controllers;
|
|
|
|
|
2021-06-14 17:26:05 +03:00
|
|
|
use common\behaviors\GsCors;
|
2021-06-09 18:06:13 +03:00
|
|
|
use common\models\Options;
|
2023-04-13 01:09:35 +03:00
|
|
|
use common\models\Skill;
|
2021-06-09 18:06:13 +03:00
|
|
|
use yii\filters\AccessControl;
|
2021-08-05 18:52:07 +03:00
|
|
|
use yii\filters\auth\CompositeAuth;
|
|
|
|
use yii\filters\auth\HttpBearerAuth;
|
2021-08-05 14:08:00 +03:00
|
|
|
use yii\filters\auth\QueryParamAuth;
|
2021-11-29 18:21:50 +03:00
|
|
|
use yii\filters\ContentNegotiator;
|
|
|
|
use yii\web\Response;
|
2021-06-09 18:06:13 +03:00
|
|
|
|
2021-11-29 18:21:50 +03:00
|
|
|
class SkillsController extends ApiController
|
2021-06-09 18:06:13 +03:00
|
|
|
{
|
|
|
|
public function behaviors()
|
|
|
|
{
|
2021-11-29 18:21:50 +03:00
|
|
|
$parent = parent::behaviors();
|
|
|
|
$b = [
|
2021-06-09 18:06:13 +03:00
|
|
|
[
|
2021-11-29 18:21:50 +03:00
|
|
|
'class' => ContentNegotiator::className(),
|
2021-06-09 18:06:13 +03:00
|
|
|
'formats' => [
|
2021-11-29 18:21:50 +03:00
|
|
|
'application/json' => Response::FORMAT_JSON,
|
2021-06-09 18:06:13 +03:00
|
|
|
],
|
|
|
|
],
|
2021-08-05 18:52:07 +03:00
|
|
|
'authenticator' => [
|
|
|
|
'class' => CompositeAuth::class,
|
|
|
|
'authMethods' => [
|
|
|
|
HttpBearerAuth::class,
|
|
|
|
],
|
|
|
|
]
|
2021-06-09 18:06:13 +03:00
|
|
|
];
|
2021-11-29 18:21:50 +03:00
|
|
|
|
|
|
|
return array_merge($parent, $b);
|
2021-06-09 18:06:13 +03:00
|
|
|
}
|
|
|
|
|
2023-04-13 01:09:35 +03:00
|
|
|
public function verbs(): array
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'skills-on-main-page' => ['get'],
|
|
|
|
'get-skills-list' => ['get'],
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2021-06-09 18:06:13 +03:00
|
|
|
public function actionIndex()
|
|
|
|
{
|
|
|
|
return ['some' => 'rrr'];
|
|
|
|
}
|
|
|
|
|
2023-04-13 01:09:35 +03:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @OA\Get(path="/skills/skills-on-main-page",
|
|
|
|
* summary="Получить список навыков для отображения на главной",
|
|
|
|
* description="Получить список навыков на главной странице",
|
|
|
|
* tags={"Skills"},
|
|
|
|
* security={
|
|
|
|
* {"bearerAuth": {}}
|
|
|
|
* },
|
|
|
|
* @OA\Response(
|
|
|
|
* response=200,
|
|
|
|
* description="Возвращает массив навыков",
|
|
|
|
* @OA\MediaType(
|
|
|
|
* mediaType="application/json",
|
|
|
|
* ),
|
|
|
|
*
|
|
|
|
* ),
|
|
|
|
* )
|
|
|
|
*
|
|
|
|
* @return array|mixed
|
|
|
|
*/
|
2021-06-09 18:06:13 +03:00
|
|
|
public function actionSkillsOnMainPage()
|
|
|
|
{
|
|
|
|
$data = \common\models\Options::getValue('skills_on_main_page_to_front');
|
|
|
|
if ($data) $data = json_decode($data, true);
|
|
|
|
else return [];
|
|
|
|
|
|
|
|
return $data;
|
|
|
|
}
|
|
|
|
|
2023-04-13 01:09:35 +03:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @OA\Get(path="/skills/get-skills-list",
|
|
|
|
* summary="Получить список навыков",
|
|
|
|
* description="Получить список навыков",
|
|
|
|
* tags={"Skills"},
|
|
|
|
* security={
|
|
|
|
* {"bearerAuth": {}}
|
|
|
|
* },
|
|
|
|
* @OA\Response(
|
|
|
|
* response=200,
|
|
|
|
* description="Возвращает массив навыков",
|
|
|
|
* @OA\MediaType(
|
|
|
|
* mediaType="application/json",
|
|
|
|
* @OA\Schema(ref="#/components/schemas/SkillsExample"),
|
|
|
|
* ),
|
|
|
|
*
|
|
|
|
* ),
|
|
|
|
* )
|
|
|
|
*
|
|
|
|
* @return array|\yii\db\ActiveRecord[]
|
|
|
|
*/
|
|
|
|
public function actionGetSkillsList(): array
|
|
|
|
{
|
|
|
|
return Skill::find()->all();
|
|
|
|
}
|
|
|
|
|
2021-06-09 18:06:13 +03:00
|
|
|
}
|