Exemplo n.º 1
0
 public function chargerFonctions($KalFunctions, Doctrine_Connection $conn = null)
 {
     if ($conn == null) {
         $conn = Doctrine_Manager::connection();
     }
     if ($KalFunctions != null) {
         foreach ($KalFunctions as $KalFunction) {
             $function_id = null;
             $function_ref = null;
             $project_ref = null;
             $project_id = null;
             $name = null;
             $description = null;
             $created_at = null;
             $updated_at = null;
             if ($KalFunction->getElementsByTagName("function_id")) {
                 $function_id = $KalFunction->getElementsByTagName("function_id")->item(0)->nodeValue;
             }
             if ($KalFunction->getElementsByTagName("function_ref")) {
                 $function_ref = $KalFunction->getElementsByTagName("function_ref")->item(0)->nodeValue;
             }
             if ($KalFunction->getElementsByTagName("project_ref")) {
                 $project_ref = $KalFunction->getElementsByTagName("project_ref")->item(0)->nodeValue;
             }
             if ($KalFunction->getElementsByTagName("project_id")) {
                 $project_id = $KalFunction->getElementsByTagName("project_id")->item(0)->nodeValue;
             }
             if ($KalFunction->getElementsByTagName("name")) {
                 $name = $KalFunction->getElementsByTagName("name")->item(0)->nodeValue;
             }
             if ($KalFunction->getElementsByTagName("description")) {
                 $description = $KalFunction->getElementsByTagName("description")->item(0)->nodeValue;
             }
             if ($KalFunction->getElementsByTagName("created_at")) {
                 $created_at = $KalFunction->getElementsByTagName("created_at")->item(0)->nodeValue;
             }
             if ($KalFunction->getElementsByTagName("updated_at")) {
                 $updated_at = $KalFunction->getElementsByTagName("updated_at")->item(0)->nodeValue;
             }
             if ($KalFunction->getElementsByTagName("delta")) {
                 $delta = $KalFunction->getElementsByTagName("delta")->item(0)->nodeValue;
             }
             //recherche de la fonction en base
             if ($function_id != null && $function_ref != null) {
                 $q = Doctrine_Core::getTable('KalFunction')->findOneByFunctionIdAndFunctionRef($function_id, $function_ref);
             }
             if ($q && $q != null) {
                 //si l'element existe , on fait une mise à jour
                 $q->name = $name;
                 $q->description = $description;
                 $q->function_ref = $function_ref;
                 $q->function_id = $function_id;
                 $q->project_id = $project_id;
                 $q->project_ref = $project_ref;
                 //$q->setDelta($delta);
                 $q->save();
             } else {
                 //le projet n'existe pas encore et dans ce cas on le crée
                 $ei_KalFunction = new KalFunction();
                 $ei_KalFunction->name = $name;
                 $ei_KalFunction->description = $description;
                 $ei_KalFunction->function_ref = $function_ref;
                 $ei_KalFunction->function_id = $function_id;
                 $ei_KalFunction->project_id = $project_id;
                 $ei_KalFunction->project_ref = $project_ref;
                 //$ei_KalFunction->setDelta($delta);
                 $ei_KalFunction->save();
             }
         }
     }
     return null;
 }