2017-03-22 10 views
0

私のconfig.ymlの値を変更したい DefaultController.phpから変更する必要がありますが、これが可能かどうかわかりませんそれをするために)。ユーザーがこのオプションを使用したくないときに、私は変更する必要がSymfonyのControllerからYAMLの値を変更するには

YAMLファイル

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 

がdefaultcontrollerからfalseに「有効」。

+0

設定が関連するバンドルについての情報も素晴らしいでしょう。実行時に実際にYAML設定を変更することはできませんが、ほとんどの場合バンドルはコンテナからアクセスできる値オブジェクトに値を設定します。このバンドルはコントローラの前で義務づけられているかもしれないので、これはまだ機能しません。だからバンドル情報を提供してください、そしてあなたはいくつかの答えを得るかもしれません。 –

+0

お返事ありがとうございます! 文書はここにあります:https://github.com/scheb/two-factor-bundle/blob/master/Resources/doc/configuration.md 私はしかし、 「有効」オプション –

答えて

1

修正があります!

は、ユーザーに私はGoogleAuth

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

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

ためIsActivated値を作り、それが有効になっている場合、私がチェック。そうでない場合、NULLを返します。 "getGoogleAuthenticatorSecret"がNULLを返す場合、バンドルは自動的にgoogle authを無効にします。

public function getGoogleAuthenticatorSecret() 
    { 

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

    return NULL; 
    } 
関連する問題