/**
  * Méthode permettant de savoir si la sous-partie du block commence par un block ou non.
  *
  * @param EiTestSetBlockStack $stack
  * @param null $pIndex
  * @return bool
  */
 public function firstFragmentElementIsFunction(EiTestSetBlockStack $stack = null, $pIndex = null)
 {
     $last = "";
     $index = 1;
     $pIndex = $pIndex == null ? $stack->getPartIndex() : $pIndex;
     $res = $this->getNextVersionStructureFragmentsObjects($stack);
     //        var_dump("Is Function ? ");
     //        var_dump($pIndex . "/" . $stack->getPartsCount());
     if (!is_bool($res)) {
         foreach ($res as $elt) {
             //                var_dump("Index : " . $index);
             //                var_dump($elt["type"] . " / " . $last);
             if ($pIndex == $index && !($elt["type"] == EiVersionStructure::$TYPE_FONCTION && $last == EiVersionStructure::$TYPE_FONCTION)) {
                 //                    var_dump("CAS 1 : " . ($elt["type"] == EiVersionStructure::$TYPE_FONCTION ? 1:0));
                 return $elt["type"] == EiVersionStructure::$TYPE_FONCTION;
             }
             if (in_array($elt["type"], EiVersionStructure::getBlockTypes())) {
                 //                    var_dump("CAS 2");
                 $index++;
             } elseif ($elt["type"] == EiVersionStructure::$TYPE_FONCTION && $last != EiVersionStructure::$TYPE_FONCTION) {
                 //                    var_dump("CAS 3");
                 $index++;
             }
             $last = $elt["type"];
         }
     }
     //        exit;
     return false;
 }
 /**
  * Génération des paramètres des blocks à partir du jeu de test et de son jeu de données.
  *
  * @param EiTestSet $testSet
  * @param EiTestSetBlockStack $stack
  * @return EiTestSetBlockParam|void
  */
 public function generate(EiTestSet $testSet, EiTestSetBlockStack $stack, Doctrine_Connection $conn = null)
 {
     $conn = $conn == null ? Doctrine_Manager::connection() : $conn;
     $chronometre = new Chronometre();
     // Début mesure.
     $gen = $chronometre->lancerChrono("GENERATION PARAMETRES DE BLOCK", true);
     // On récupère le block à partir de la pile.
     $block = $stack->getEiVersionStructure();
     // Récupération du parent.
     $parent = $block->getNode()->getParent();
     $index = null;
     $path = "";
     if ($parent != null && ($parent instanceof EiTestSetBlockParam || $parent instanceof EiVersionStructure)) {
         /** @var EiTestSetBlockParam $parent */
         $parent = $this->getParentBlock($testSet, $parent);
         $path = $parent->getPath();
         // TODO: Calcul index.
         $index = $stack->getRepetitionIndex();
     } else {
         $index = 1;
     }
     // Si le fragment de l'élément de la pile est supérieur à 1 alors le père a déjà été généré et on le récupère.
     if ($stack->getPartIndex() > 1) {
         $blockParam = Doctrine_Core::getTable("EiTestSetBlockParam")->findOneByEiTestSetIdAndIndexRepetitionAndEiVersionStructureId($testSet->getId(), $index, $block->getId());
         //            var_dump($blockParam->toArray(false));
         //            var_dump($stack->toArray(false));
     } else {
         // Génération des paramètres du Block.
         $blockParam = $block->generateTestSetParameters($testSet, $parent, $index, $path, false, $conn);
     }
     if ($blockParam != null) {
         // Ajout du block param dans la stack.
         $stack->setEiTestSetBlockParam($blockParam);
         $stack->setPath($blockParam->getPath());
         $stack->save($conn);
     }
     // Fin de la mesure.
     $chronometre->arreterEtAfficherChrono("GENERATION PARAMETRES DE BLOCK", $gen);
     return $blockParam;
 }