config->getComponentPaths($i); // Then go over every individual paths $configFiles = []; foreach ($paths as $priority => $foldersArray) { foreach ($foldersArray as $folder) { // Get the contents from the folder $contents = array_diff(scandir($folder), array('..', '.')); // Then go over the folders, and see which ones are an admin view foreach ($contents as $file) { // If the file matches the expected filename, add it to the list if (str_starts_with($file, 'config.')) { if (!isset($configFiles[$file])) $configFiles[$file] = []; $configFiles[$file][] = ['folder' => $folder, 'priority' => substr(Priority::getPriority($priority), 10)]; } } } } // At the end, sort the files ksort($configFiles); // And return them return $configFiles; } /** * Fetch a file * * @param string $fileName * @return array * @throws NotFoundException */ public function fetchFile(string $fileName, int $selector): array { // Fetch files $files = $this->findSettingsFiles(); // Check if the file exists if (!isset($files[$fileName])) throw new NotFoundException("The requested settings file could not be found."); // Select correct data $meta = $files[$fileName][$selector]; // Find the file $file = $meta['folder'] . DS . $fileName; if (!file_exists($file)) throw new NotFoundException("The requested settings file could not be found."); // Load the raw data $raw = file_get_contents($file); // And try to load the editable data $data = include($file); // Prepare output variable return ['name' => $fileName, 'directory' => $meta['folder'], 'raw' => $raw, 'data' => $data]; } protected function verifyFileData(array $fileData): bool { foreach ($fileData as $key => $val) { switch (gettype($val)) { case 'array': case 'object': case 'resource': case 'unknown type': return false; break; } } return true; } }