Skip to content

Commit

Permalink
added docblock to filesystem setting methods
Browse files Browse the repository at this point in the history
  • Loading branch information
roncodes committed Mar 12, 2024
1 parent c089a3b commit 0213b7d
Showing 1 changed file with 26 additions and 5 deletions.
31 changes: 26 additions & 5 deletions src/Http/Controllers/Internal/v1/SettingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,12 @@ public function adminOverview(AdminRequest $request)
}

/**
* Loads and sends the filesystem configuration.
* Retrieves the current filesystem configuration including details about configured storage drivers.
* It specifically fetches configurations for AWS S3 and Google Cloud Storage (GCS).
*
* @return \Illuminate\Http\JsonResponse
* @param AdminRequest $request the incoming request
*
* @return \Illuminate\Http\JsonResponse JSON response containing the filesystem configuration details
*/
public function getFilesystemConfig(AdminRequest $request)
{
Expand Down Expand Up @@ -73,9 +76,12 @@ public function getFilesystemConfig(AdminRequest $request)
}

/**
* Saves filesystem configuration.
* Saves the updated filesystem configuration based on the incoming request.
* It handles the settings for various filesystem drivers like local, AWS S3, and GCS.
*
* @return \Illuminate\Http\JsonResponse
* @param AdminRequest $request the incoming request containing filesystem configuration data
*
* @return \Illuminate\Http\JsonResponse JSON response indicating the success status of the operation
*/
public function saveFilesystemConfig(AdminRequest $request)
{
Expand All @@ -90,13 +96,20 @@ public function saveFilesystemConfig(AdminRequest $request)
return response()->json(['status' => 'OK']);
}

/**
* Extracts the Google Cloud Storage (GCS) configuration from the incoming request.
* Updates the GCS configuration based on the provided bucket information and credentials file ID.
*
* @param Request $request the incoming request with GCS configuration details
*
* @return array the updated GCS configuration array
*/
private static function _getGcsConfigWithIcomingRequest(Request $request): array
{
$gcsBucket = $request->input('gcsBucket');
$gcsCredentialsFileId = $request->input('gcsCredentialsFileId');
$gcsConfig = config('filesystems.disks.gcs');
$gcsConfig['bucket'] = $gcsBucket;
$gcsConfig['key_file_path'] = env('GOOGLE_APPLICATION_CREDENTIALS', env('GOOGLE_CLOUD_KEY_FILE'));
if ($gcsCredentialsFileId) {
$gcsCredentialsContent = static::_setupGcsConfigUsingFileId($gcsCredentialsFileId);
if (is_array($gcsCredentialsContent)) {
Expand All @@ -114,6 +127,14 @@ private static function _getGcsConfigWithIcomingRequest(Request $request): array
return $gcsConfig;
}

/**
* Sets up the Google Cloud Storage (GCS) configuration using a given file ID.
* Retrieves the credentials file for GCS and decodes its contents to use in the GCS configuration.
*
* @param string $fileId the UUID of the file containing GCS credentials
*
* @return array an array containing the parsed content of the GCS credentials file
*/
private static function _setupGcsConfigUsingFileId(string $fileId): array
{
if (!Str::isUuid($fileId)) {
Expand Down

0 comments on commit 0213b7d

Please sign in to comment.