/** * Gets all the files needed for the provided CSS file. This will extract the imports from the CSS. * @param zibo\core\Zibo $zibo Instance of Zibo * @param zibo\library\filesystem\File $file CSS source file * @return array Array with the path of the file as key and the File object as value */ private function getFilesFromStyle(Zibo $zibo, File $file) { $source = $file->read(); $source = preg_replace(CSSMin::REGEX_COMMENT, '', $source); $files = array(); $parent = $file->getParent(); $lines = explode("\n", $source); foreach ($lines as $line) { $line = trim($line); if (empty($line)) { continue; } if (!preg_match(CSSMin::REGEX_IMPORT, $line)) { break; } $importFileName = $this->getFileNameFromImportLine($line); $importFile = $zibo->getRelativeFile(new File($parent, $importFileName)); $importFile = $zibo->getFile($importFile); if (!$importFile) { continue; } $styleFiles = $this->getFilesFromStyle($zibo, $importFile); $files = Structure::merge($files, $styleFiles); } $files[$file->getPath()] = $file; return $files; }