예제 #1
0
 public static function createDistantFunction(EiProjet $ei_project, $data, EiUserDefaultPackage $defPack, EiTree $ei_parent_tree = null, Doctrine_Connection $conn = null)
 {
     if ($conn == null) {
         $conn = Doctrine_Manager::connection();
     }
     try {
         $conn->beginTransaction();
         //Début de la transaction
         //$result_file = new DOMDocument();
         $ei_subject = Doctrine_Core::getTable("EiSubject")->findOneByPackageIdAndPackageRef($defPack->getTicketId(), $defPack->getTicketRef());
         if ($ei_subject == null) {
             return false;
         }
         $result_update = MyFunction::loadResultOfWebServiceByPostJson(MyFunction::getPrefixPath(null) . "serviceweb/project/function/create.json", array('project_id' => $ei_project->getProjectId(), 'project_ref' => $ei_project->getRefId(), 'ticket_id' => $defPack->getTicketId(), 'ticket_ref' => $defPack->getTicketRef(), 'package_name' => "Package_S" . $ei_subject->getId(), 'parent_id' => $ei_parent_tree != null ? $ei_parent_tree->getId() : null, 'user_id' => $defPack->getUserId(), 'user_ref' => $defPack->getUserRef(), 'data' => $data));
         $array_result = json_decode(html_entity_decode($result_update), true);
         //Récupération du projet pour traitement
         if (count($array_result) == 0) {
             return false;
         }
         if (array_key_exists("error", $array_result)) {
             return false;
         }
         if (!$array_result[0]) {
             return false;
         }
         //Rechargement d'une fonction
         KalFunction::reload($array_result, $conn);
         $conn->commit();
         return true;
     } catch (Exception $e) {
         $conn->rollback();
         //return false;
         throw $e;
     }
 }