Skip to content

Plugin settings using env variables not being parsed #13929

Closed Answered by brandonkelly
icreatestuff asked this question in Q&A
Discussion options

You must be logged in to vote

Right – Settings:$clientId is going to store the raw value.

The easy fix for this would be to add a new getParsedClientId() method:

use craft\helpers\App;

public function getParsedClientId(): string
{
    return App::parseEnv($this->clientId);
}

And start calling that instead of ->clientId directly.

Alternatively, you could make $clientId a private property and add a magic getter and setter for it, which handles the parsing internally by default, but also providing a way to access the raw value when needed (when rendering the plugin settings form).

private string $clientId;

public function getClientId(bool $parse = true): string
{
    if ($parse) {
        return App::parseEnv($this->cl…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@icreatestuff
Comment options

@brandonkelly
Comment options

Answer selected by brandonkelly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants