public function minify() { if (FIRST_RELOAD || RX_MODE_DEBUG || self::$cache->isEmpty()) { foreach ($this->scripts as $key => $value) { $newName = self::$BUILD_PATH . $value["file"]; $this->scripts[$key]["exists"] = file_exists(PROJECT_ROOT_DIR . $value["file"]); $this->scripts[$key]["build_path"] = $newName; if ($this->const['RX_JS_MIN'] && !$this->scripts[$key]["remote"]) { $this->scripts[$key]["minified"] = $this->minified->minify(PROJECT_ROOT_DIR . $value["file"], $newName); $this->scripts[$key]["link"] = CONTEXT_PATH . str_replace(self::$BUILD_PATH, "", $this->scripts[$key]["minified"]); } else { if (!$this->scripts[$key]["remote"]) { \RudraX\Utils\FileUtil::build_copy($value["file"], ResourceUtil::$RESOURCE_DIST_DIR . "/" . $value["file"]); } } } foreach ($this->css as $key => $value) { if ($this->const['RX_JS_MIN'] && !$this->css[$key]["remote"]) { Browser::warn("minifying...", $this->css[$key]["minified"], file_exists(PROJECT_ROOT_DIR . $value["file"]), $value["file"]); $newName = self::$BUILD_PATH . $value["file"]; $this->css[$key]["exists"] = file_exists($value["file"]); $this->css[$key]["build_path"] = $newName; $inputFile = PROJECT_ROOT_DIR . $value["file"]; $inputFileExists = file_exists($inputFile); if ($inputFileExists) { $this->css[$key]["minified"] = $this->minified->minify($inputFile, $newName); } else { $this->css[$key]["minified"] = $newName; } $this->css[$key]["link"] = CONTEXT_PATH . str_replace(self::$BUILD_PATH, "", $this->css[$key]["minified"]); } } } }
function rx_scan_dir($annotations, $dir) { $allController = ClassUtil::getControllerArray(); $dir_iterator = new RecursiveDirectoryIterator($dir); $iterator = new RecursiveIteratorIterator($dir_iterator, RecursiveIteratorIterator::SELF_FIRST); // could use CHILD_FIRST if you so wish foreach ($iterator as $filename => $file) { if ($file->isFile()) { if (fnmatch("*/handler/*.php", $file->getPathname()) || fnmatch("*\\\\handler\\\\*.php", $file->getPathname())) { require_once $file->getPathname(); $className = str_replace(".php", "", $file->getFilename()); $scan = true; if (ClassUtil::getMTime($className) >= $file->getMTime()) { $scan = false; } if ($scan && class_exists($className)) { $result = $annotations->getClassAnnotations($className); if (isset($result["Handler"]) && isset($result["Handler"][0]) && !empty($result["Handler"][0])) { ClassUtil::setHandler($result["Handler"][0], array("className" => $className, "filePath" => $file->getPathname(), "mtime" => $file->getMTime(), "requestParams" => isset($result["RequestParams"]))); Browser::warn("HandleScanned::", ClassUtil::getHandler($result["Handler"][0])); ClassUtil::setMTime($className, $file->getMTime()); } } } else { if (fnmatch("*/controller/*.php", $file->getPathname()) || fnmatch("*\\\\controller\\\\*.php", $file->getPathname())) { require_once $file->getPathname(); $className = str_replace(".php", "", $file->getFilename()); $scan = true; if (ClassUtil::getMTime($className) >= $file->getMTime()) { $scan = false; } if ($scan && class_exists($className)) { $methods = get_class_methods($className); foreach ($methods as $method) { $result = $annotations->getMethodAnnotations($className, $method); Browser::error("ControllerScanned::", $result); if (isset($result["RequestMapping"]) && isset($result["RequestMapping"][0]) && isset($result["RequestMapping"][0]["url"])) { $allController[] = array("className" => $className, "method" => $method, "filePath" => $file->getPathname(), "mtime" => $file->getMTime(), "mappingUrl" => $result["RequestMapping"][0]["url"], "requestParams" => isset($result["RequestParams"]), "cache" => isset($result["RequestMapping"][0]["cache"]) ? $result["RequestMapping"][0]["cache"] : FALSE, "type" => isset($result["RequestMapping"][0]["type"]) ? $result["RequestMapping"][0]["type"] : NULL, "requestMethod" => isset($result["RequestMapping"][0]["method"]) ? strtoupper($result["RequestMapping"][0]["method"]) : NULL); } } Browser::warn("ControllerScanned::", $allController[$result["RequestMapping"][0]["url"]]); ClassUtil::setMTime($className, $file->getMTime()); } } else { if (fnmatch("*/model/*.php", $file->getPathname()) || fnmatch("*\\\\model\\\\*.php", $file->getPathname())) { require_once $file->getPathname(); $className = str_replace(".php", "", $file->getFilename()); $scan = true; if (ClassUtil::getMTime($className) >= $file->getMTime()) { $scan = false; } if ($scan && class_exists($className)) { $result = $annotations->getClassAnnotations($className); if (isset($result["Model"]) && isset($result["Model"][0]) && !empty($result["Model"][0])) { ClassUtil::setModel($result["Model"][0], array("className" => $className, "filePath" => $file->getPathname(), "mtime" => $file->getMTime(), "type" => $result["Model"][0])); Browser::warn("ModelScanned::", ClassUtil::getModel($result["Model"][0])); ClassUtil::setMTime($className, $file->getMTime()); } } } } } } } ClassUtil::setControllerArray($allController); }