コード例 #1
0
ファイル: Config.php プロジェクト: kris-nova/API
 /**
  * Will build the config class if needed
  *
  * @return boolean
  */
 public static function init()
 {
     if (!static::$isInit) {
         $ini = static::getIniString();
         static::$config = parse_ini_string($ini);
     }
     return static::$isInit = true;
 }
コード例 #2
0
ファイル: QRcode.php プロジェクト: awebc/web_xbf
 /**
  * init qrcode
  * @param [] $options
  * @return bool
  */
 public static function init($options = [])
 {
     if (static::$isInit === true) {
         return static::$isInit;
     }
     $defaultOptions = ['QR_CACHEABLE' => true, 'QR_CACHE_DIR' => Yii::getAlias('@runtime/cache/qrcode') . DIRECTORY_SEPARATOR, 'QR_LOG_DIR' => Yii::getAlias('@runtime/logs/qrcode') . DIRECTORY_SEPARATOR, 'QR_FIND_BEST_MASK' => true, 'QR_FIND_FROM_RANDOM' => false, 'QR_DEFAULT_MASK' => 2, 'QR_PNG_MAXIMUM_SIZE' => 1024];
     $options = ArrayHelper::merge($defaultOptions, $options);
     foreach ($options as $key => $val) {
         define($key, $val);
     }
     //mkdir
     if (false === file_exists($defaultOptions['QR_CACHE_DIR'])) {
         @mkdir($defaultOptions['QR_CACHE_DIR'], 0775, true);
     }
     if (false === file_exists($defaultOptions['QR_LOG_DIR'])) {
         @mkdir($defaultOptions['QR_LOG_DIR'], 0775, true);
     }
     //reset status
     return static::$isInit = true;
 }