private function updateDatabase() { $tablesClasses = $this->getIdentityClasses(); $this->processTableClasses($tablesClasses); Helpers::writeInFile("Config/migrations.txt", strval(time())); }
private function scanControllersRoutes(array $controllersNames) { foreach ($controllersNames as $controllersName) { $fullPath = "Framework\\" . "Controllers" . "\\" . $controllersName; $rc = new \ReflectionClass($fullPath); $methods = $rc->getMethods(); foreach ($methods as $method) { $methodDoc = $method->getDocComment(); if ($methodDoc && preg_match('/@NoAction/', $methodDoc, $dummy)) { continue; } $requestMethods = array("GET"); $action = $controllersName . "/" . $method->getName(); if ($methodDoc && preg_match_all('/@(POST|PUT|DELETE|GET)/', $methodDoc, $requestMethodsAnnotations)) { $requestMethods = $requestMethodsAnnotations[1]; } $this->actions[$action] = array("methods" => $requestMethods, "annotations" => [], "params" => [], "arguments" => []); if ($methodDoc && preg_match('/@Route\\(([^\\)]+)\\)/', $methodDoc, $routeAnnotation)) { $params = explode("/", $routeAnnotation[1]); array_shift($params); array_shift($params); $this->customRoutes[$routeAnnotation[1]] = array("controller" => $controllersName, "action" => $method->getName(), "parameters" => $params, "methods" => $requestMethods); } if ($methodDoc && preg_match_all('/@@(\\w+)(?:\\(([^)\\s\\n*]+)\\))*/', $methodDoc, $fieldMatch)) { for ($i = 0; $i < count($fieldMatch[0]); $i++) { $annotationName = AppConfig::ANNOTATIONS_NAMESPACE . ucfirst($fieldMatch[1][$i]) . AppConfig::ANNOTATIONS_SUFFIX; $this->actions[$action]["annotations"][$annotationName] = $fieldMatch[2][$i]; } } if ($methodDoc && preg_match_all('/@param\\s+([^\\s]+)\\s+\\$([^\\s]+)/', $method->getDocComment(), $parameterType)) { for ($i = 0; $i < count($parameterType[0]); $i++) { $this->actions[$action]["params"][$parameterType[2][$i]] = $parameterType[1][$i]; } } } } Helpers::writeInFile("Config/routes.json", json_encode($this->customRoutes)); Helpers::writeInFile("Config/actions.json", json_encode($this->actions)); }