How to change YAML value from Controller in Symfony

240 views Asked by At

I want to change a value of my config.yml I need to change it from my DefaultController.php but I don't know if this is possible (and if it's possible how to do it).

The YAML file

 google:
    enabled: true          # If Google Authenticator should be enabled, default false
    server_name: Zioo      # Server name used in QR code
    issuer: Zioo           # Issuer name used in QR code
    template: ZPAdminBundle:Authentication:form.html.twig   # Template used to render the authentication form

I need to change "enabled" to false from the defaultcontroller when A user doesn't want to use this option.

1

There are 1 answers

0
Marco Koopman On

Got a fix!

In user I made an IsActivated value for the GoogleAuth

 /**
 * @return mixed
 */
public function getGoogleAuthenticatorIsActivated()
{
    return $this->googleAuthenticatorIsActivated;
}

/**
 * @param mixed $googleAuthenticatorIsActivated
 */
public function setGoogleAuthenticatorIsActivated($googleAuthenticatorIsActivated)
{
    $this->googleAuthenticatorIsActivated = $googleAuthenticatorIsActivated;
}

And then I checked if it is activated. If not it returns NULL. The bundle automaticly disables google auth if "getGoogleAuthenticatorSecret" returns NULL

    public function getGoogleAuthenticatorSecret()
    {

    if($this->getGoogleAuthenticatorIsActivated() == true){
        return $this->googleAuthenticatorSecret;
    }

    return NULL;
    }