无法获得静态参数值

时间:2015-11-19 06:33:43

标签: yii2 params

我有错误未知方法

  

调用未知方法:yii \ web \ Application :: params()

型号:

public static function isSecretKeyExpire($key)
{
    if (empty($key))
        return false;
    $expire = Yii::$app->params('secretKeyExpire');
    $parts = explode('_', $key);
    $timestamp = (int) end($parts);
    return $timestamp + $expire >= time();
}

2 个答案:

答案 0 :(得分:2)

尝试这种方式:

 Yii::$app->params['versionDate'];

答案 1 :(得分:0)

尝试:

public class MyAlert extends DialogFragment {
  Bitmap b;
  public MyAlert newInstance(Bitmap b) {
    this.b=b;
    MyAlert frag=new MyAlert();
    Bundle args=new Bundle();
    args.put("bitByte",b);
    frag.setArguments(args);
    return frag;
  }

  @Override
  public Dialog onCreateDialog(Bundle savedInstanceState) {
    Bitmap bitmap=getArguments().getByteArray("bitByte");
    return new AlertDialog().Builder(getActivity());

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()).setView(R.id.fragid).create();