/** * Get all language files in the language directory. * * @return array Language files. * * @throws Exception Throws if an error occurred. */ private static function getLanguageFiles() { // Get the language directory and make sure it exists $langDir = static::getLanguageDirectory(); if (!$langDir->isDirectory()) { throw new Exception('Language file directory doesn\'t exist, or isn\'t accessible!'); } // Create a directory scanner to list all language files $scanner = new DirectoryScanner($langDir); // Define an array for the language files $langFiles = array(); // Process each file in this directory while (($file = $scanner->read()) !== null) { // Make sure this file is a file if (!$file->isFile()) { continue; } // Make sure the extension is valid if (!StringUtils::equals($file->getExtension(false), 'ini', false, true)) { continue; } // Add the file to the language files list $langFiles[] = $file; } // Return the list of files return $langFiles; }
public static function getContents($dir, $recursive = false, $types = self::FLAG_TYPE_ALL, $default = null) { // Convert the directory into a path string, return the $default value if failed if (($dir = self::asPath($dir, false)) === null) { return $default; } // Make sure the filesystem object is a directory, and exists if (!self::isDirectory($dir)) { return null; } // Create a directory scanner $scanner = new DirectoryScanner($dir, true); // Scan the directory and return the result if it's valid if (($out = $scanner->readAll($recursive, $types)) === null) { return $default; } return $out; }