/** * * @param Proyecto $elem * @return boolean */ function save($elem) { if (!file_exists($elem->getRuta())) { mkdir($elem->getRuta()); } //TODO: actualizar config.xml $jsonProy = new stdClass(); $jsonProy->nombre = $elem->getNombre(); $jsonProy->ruta = $elem->getRuta(); $jsonProy->id = $elem->getId(); $jsonProy->dbConfig = $elem->getDbConfig(); if (empty($jsonProy->id)) { $maxId = 0; $existentes = $this->findBy(); foreach ($existentes as $proy) { $maxId = max($proy->getId(), $maxId); } $jsonProy->id = $maxId + 1; } $fp = fopen(DIR_PROYECTOS . $elem->getNombre() . ".json", 'w'); fwrite($fp, json_encode($jsonProy)); fclose($fp); return true; }