TinyAuth\Utility\Utility::parseFile PHP Метод

parseFile() публичный статический Метод

Returns the ini file as an array.
public static parseFile ( string $ini ) : array
$ini string Full path to the ini file
Результат array List
    public static function parseFile($ini)
    {
        if (!file_exists($ini)) {
            throw new Exception(sprintf('Missing TinyAuth config file (%s)', $ini));
        }
        if (function_exists('parse_ini_file')) {
            $iniArray = parse_ini_file($ini, true);
        } else {
            $iniArray = parse_ini_string(file_get_contents($ini), true);
        }
        if (!is_array($iniArray)) {
            throw new Exception(sprintf('Invalid TinyAuth config file (%s)', $ini));
        }
        return $iniArray;
    }

Usage Example

Пример #1
0
 /**
  * Returns the acl.ini file(s) as an array.
  *
  * @param array|string|null $paths Paths to look for INI file
  * @param string $file Full path to the INI file
  * @return array List with all available roles
  */
 protected function _parseFiles($paths, $file)
 {
     if ($paths === null) {
         $paths = ROOT . DS . 'config' . DS;
     }
     $list = [];
     foreach ((array) $paths as $path) {
         $list += Utility::parseFile($path . $file);
     }
     return $list;
 }