Skip to content

Auto-configure for Craft Cloud#14

Open
timkelty wants to merge 1 commit intodiginov:mainfrom
timkelty:feature/craft-cloud
Open

Auto-configure for Craft Cloud#14
timkelty wants to merge 1 commit intodiginov:mainfrom
timkelty:feature/craft-cloud

Conversation

@timkelty
Copy link
Copy Markdown

@timkelty timkelty commented Apr 25, 2024

Auto configures release and some extras if running on Craft Cloud.

'release' => $this->release ?: null,
'environment' => $this->environment ?: (App::env('CRAFT_ENVIRONMENT') ?: null),
'release' => $this->release ?? App::env('CRAFT_CLOUD_BUILD_ID'),
'environment' => $this->environment ?? App::env('CRAFT_ENVIRONMENT'),
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

App::env returns null if it can't find anything, so it seemed more straightforward to use null coalescing here.

'Yii Version' => Yii::getVersion(),
'Craft Cloud Project ID' => App::env('CRAFT_CLOUD_PROJECT_ID'),
'Craft Cloud Environment ID' => App::env('CRAFT_CLOUD_ENVIRONMENT_ID'),
'Craft Cloud Build ID' => App::env('CRAFT_CLOUD_BUILD_ID'),
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These will get filtered if empty (see below)

} catch (\Throwable $e) {}

return $extras;
return array_filter($extras);
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Filter any items with falsey values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant