HEX
Server: LiteSpeed
System: Linux premium260.web-hosting.com 4.18.0-553.45.1.lve.el8.x86_64 #1 SMP Wed Mar 26 12:08:09 UTC 2025 x86_64
User: aliazzsr (627)
PHP: 7.4.33
Disabled: NONE
Upload Files
File: /home/aliazzsr/api.crm.vqode.com/controllers/SettingController.php
<?php
namespace app\controllers;

use app\components\BaseActiveController;
use app\models\enums\SettingEnum;
use app\models\enums\PermissionEnum;

class SettingController extends BaseActiveController
{
    public $modelClass = 'app\models\core\Setting';

    protected static $permissionRequired = PermissionEnum::EULA;

    public function behaviors()
    {
        $behaviors = parent::behaviors();

        /** @todo find better way */
        if ($this->isEulaViewRequest()) {
            unset($behaviors['auth']);
        }

        return $behaviors;
    }

    /**
     * Returns true if EULA requested for reading
     * @return bool
     */
    protected function isEulaViewRequest()
    {
        $isEula = SettingEnum::EULA === \Yii::$app->request->get('id');
        $isView = 'view' === $this->action->id;

        return $isEula && $isView;
    }
}
/**
 * @SWG\Get(
 *   path="/settings/{id}",
 *   tags={"Settings"},
 *   security={{"bearer":{}}},
 *   summary="Returns a single Setting record. Doesn't require authorization to get EULA.",
 *     consumes={"application/json"},
 *     produces={"application/json"},
 *   @SWG\Parameter(description="Unique identifier", in="path", name="id", required=true, type="string"),
 *   @SWG\Response(response=200, description="Successful operation.", @SWG\Schema(ref="#/definitions/Setting")),
 *   @SWG\Response(response=401, description="Unauthorized."),
 *   @SWG\Response(response=404, description="Not found."),
 *   @SWG\Response(response=500, description="Internal server error.")
 * )
 * @SWG\Put(
 *   path="/settings/{id}",
 *   tags={"Settings"},
 *   security={{"bearer":{}}},
 *   summary="Updates an existed Setting record.",
 *     consumes={"application/json"},
 *     produces={"application/json"},
 *   @SWG\Parameter(description="Unique identifier", in="path", name="id", required=true, type="string"),
 *   @SWG\Parameter(name="body", required=true, in="body", @SWG\Schema(
 *     ref="#/definitions/Setting")),
 *   @SWG\Response(response=401, description="Unauthorized."),
 *   @SWG\Response(response=422, description="Data validation error."),
 *   @SWG\Response(response=500, description="Internal server error.")
 * )
 */