[ 'class' => AccessControl::class, 'rules' => [ [ 'allow' => true, 'actions' => ['profile'], 'roles' => [Permissions::OBTAIN_ACCOUNT_INFO], 'roleParams' => function(): array { $account = Yii::$app->user->identity->getAccount(); return [ 'accountId' => $account ? $account->id : -1, ]; }, ], ], ], 'verbs' => [ 'class' => VerbFilter::class, 'actions' => [ 'profile' => ['GET'], ], ], ]); } public function actionProfile(SkinsSystemApi $skinsSystemApi): array { /** @var \common\models\Account $account at this point null value isn't possible */ $account = Yii::$app->user->identity->getAccount(); try { $textures = $skinsSystemApi->textures($account->username); } catch (Exception $e) { Yii::warning('Cannot get textures from skinsystem.ely.by. Exception message is ' . $e->getMessage()); $textures = []; } $response = [ 'id' => str_replace('-', '', $account->uuid), 'name' => $account->username, 'skins' => [], 'capes' => [], ]; if (isset($textures['SKIN'])) { $response['skins'][] = [ 'id' => v3(Uuid::NAMESPACE_URL, $textures['SKIN']['url']), 'state' => 'ACTIVE', 'url' => $textures['SKIN']['url'], 'variant' => isset($textures['SKIN']['metadata']['model']) ? 'SLIM' : 'CLASSIC', 'alias' => '', ]; } if (isset($textures['CAPE'])) { $response['capes'][] = [ 'id' => v3(Uuid::NAMESPACE_URL, $textures['CAPE']['url']), 'state' => 'ACTIVE', 'url' => $textures['CAPE']['url'], 'alias' => '', ]; } return $response; } }