static function RedirectExtern($url) { if (StringHelper::Contains($url, 'http:') || StringHelper::Contains($url, 'https:')) { self::Redirect($url); } else { self::Redirect('http://' . $url); } }
public static function ModelTreatment($model) { $annotation = new Annotation($model); $get = $annotation->getAnnotations(); foreach ($get as $campo => $data) { if (array_key_exists("NotMapped", $data)) { unset($model->{$campo}); } else { if (array_key_exists("Type", $data) && StringHelper::Contains($data["Type"], "tinyint")) { $model->{$campo} = $model->{$campo} != "true" && $model->{$campo} != "1" ? "0" : "1"; } } } }
private function generateClass($table) { $vars = ""; foreach ($this->fields as $l) { $type = null; if (count($l) == 2) { //pegaTipo $consulta = "SHOW FIELDS FROM " . $l[1] . " where Field ='" . $l[0] . "'"; $busca = $this->db->Select($consulta); $type = $busca->Type; $vars .= "\n/**\n * @Name: " . $l[0] . "\n * @Type: " . $type . "\n */"; if ($type == 'timestamp') { $vars .= "\n public \$" . $l[0] . " = CURRENT_TIMESTAMP;\n"; } else { if ($type == 'tinyint(1)') { $vars .= "\n public \$" . $l[0] . " = false;\n"; } else { if (StringHelper::Contains($type, 'int')) { $vars .= "\n public \$" . $l[0] . " = 0;\n"; } else { $vars .= "\n public \$" . $l[0] . ";\n"; } } } } else { if ($l[2] == "PRIMARY") { $consulta = "SHOW FIELDS FROM " . $l[1] . " where Field ='" . $l[0] . "'"; $busca = $this->db->Select($consulta); $type = $busca->Type; $vars .= "/**\n * @PrimaryKey\n * @Name: " . $l[0] . "\n * @Type: " . $type . "\n */"; $vars .= "\n public \$" . $l[0] . " = 0;\n"; } else { if ($l[0] != '') { $vars .= "\n/**\n * @NotMapped\n * @Virtual\n * @Name: _" . ucfirst($l[0]) . "\n * @Fk: " . $l[1] . "\n * @Type: " . ucfirst($l[2]) . "\n */"; $vars .= "\n public \$_" . ucfirst($l[0]) . ";\n"; } } } } $template = new Template(VENDOR . "Helpers" . DS . "ClassGenerator" . DS . "Template" . DS . "ClasseTemplate.tpl"); $template->set('date', date("d/m/Y H:i:s")); $template->set('C', ucfirst($table)); $template->set('vars', $vars); $template->write(APP . 'Entities/Generator/' . ucfirst($table) . '.php'); }
private function BuildJoin($type, $join, $on, $on2) { if ($this->join == null && StringHelper::Contains($on, ".")) { $this->as = " AS " . ArrayHelper::getFirstElement(explode(".", $on)); } $as = ""; if (StringHelper::Contains($on2, ".")) { $as = " AS " . ArrayHelper::getFirstElement(explode(".", $on2)); } if ($join instanceof Select) { if ($join->join != null) { $this->join .= " " . $type . " JOIN ( "; $this->join .= " " . $join->getQuery(); $this->join .= ")" . $as . " ON " . $on . " = " . $on2; } else { $this->join .= " " . $type . " JOIN " . $join->type . $as . " ON " . $on . " = " . $on2; } $this->Where($join->where); } else { if (is_string($join)) { $this->join .= " " . $type . " JOIN " . $join . $as . " ON " . $on . " = " . $on2; } else { throw new UnitOfWorkException("Tipo não válido"); } } }