/**
  * @param Doctrine_Connection $conn
  */
 public function save(Doctrine_Connection $conn = null)
 {
     $isNew = $this->isNew();
     parent::save($conn);
     if ($isNew && $this->getParamType() == 'OUT') {
         /** @var EiFonction[] $fonctions */
         $fonctions = Doctrine_Core::getTable("EiFonction")->findByFunctionIdAndFunctionRef($this->getFunctionId(), $this->getFunctionRef());
         foreach ($fonctions as $fonction) {
             $mapping = new EiParamBlockFunctionMapping();
             $mapping->setEiFunction($fonction);
             $mapping->setEiFunctionParamMapping($this);
             $mapping->save();
         }
     }
 }
 public function save(\Doctrine_Connection $conn = null, $withparams = true)
 {
     $new = $this->isNew();
     if ($conn == null) {
         $conn = Doctrine_Manager::connection();
     }
     $conn->beginTransaction();
     try {
         if ($new && $withparams) {
             $params = Doctrine_Core::getTable('EiFunctionHasParam')->findByFunctionRefAndFunctionIdAndParamType($this->function_ref, $this->function_id, "IN");
             //pour chaque paramètres associé à la fonction en provenance de script
             $params_collection = new Doctrine_Collection('EiParam');
             foreach ($params as $p => $param) {
                 $eiParam = new EiParam();
                 $eiParam->setEiFonction($this);
                 $eiParam->setParamId($param->getParamId());
                 $eiParam->setValeur($param->getDefaultValue());
                 $eiParam->setName($param->getName());
                 $params_collection->add($eiParam);
             }
             $this->setEiParams($params_collection);
             $params = Doctrine_Core::getTable('EiFunctionHasParam')->findByFunctionRefAndFunctionIdAndParamType($this->function_ref, $this->function_id, "OUT");
             $mappingCollection = new Doctrine_Collection("EiParamBlockFunctionMapping");
             /** @var EiFunctionHasParam $param */
             foreach ($params as $param) {
                 $mapping = new EiParamBlockFunctionMapping();
                 $mapping->setEiParamFunctionId($param->getParamId());
                 $mapping->setEiFunction($this);
                 $mappingCollection->add($mapping);
             }
             $this->setEiFunctionMapping($mappingCollection);
         }
         parent::save($conn);
         if ($new) {
             $this->getEiVersionStructure()->setEiFonctionId($this->getId());
         }
         $conn->commit();
     } catch (Exception $e) {
         //            $conn->rollback();
         throw $e;
     }
     return $this;
 }