コード例 #1
0
 public function bind(array $taintedValues = null, array $taintedFiles = null)
 {
     $new_occurrences = new BaseForm();
     if (isset($taintedValues["EiBlockParams"])) {
         try {
             $formParams = $this->getEmbeddedForm("EiBlockParams");
         } catch (InvalidArgumentException $exc) {
             $formParams = null;
         }
     }
     if (isset($taintedValues['EiBlockParams'])) {
         foreach ($taintedValues['EiBlockParams'] as $key => $new_occurrence) {
             try {
                 if (isset($new_occurrence["id"]) && $new_occurrence["id"] == "") {
                     $blockParam = new EiBlockParam();
                     $blockParam->setEiVersionStructureParent($this->getObject());
                     $blockParam->setId($new_occurrence["id"]);
                     $blockParam->setEiVersionId($this->getObject()->getEiVersionId());
                     $occurrence_form = new EiBlockParamForm($blockParam);
                     $new_occurrences->embedForm($key, $occurrence_form);
                 } elseif ($formParams != null && ($subForm = $formParams->getEmbeddedForm($key))) {
                     $occurrence_form = new EiBlockParamForm($subForm->getObject());
                     $new_occurrences->embedForm($key, $occurrence_form);
                 }
             } catch (InvalidArgumentException $exc) {
                 // TODO: Traiter l'exception.
             }
         }
         $this->embedForm('EiBlockParams', $new_occurrences);
     } else {
         $this->embedForm("EiBlockParams", new BaseForm());
     }
     parent::bind($taintedValues, $taintedFiles);
 }
コード例 #2
0
 /**
  * @see EiScenarioStructureForm
  */
 public function configure()
 {
     if (!($block = $this->getOption('block'))) {
         throw new InvalidArgumentException('You must provide a block object.');
     }
     $parentFormName = $this->getOption('parentName');
     $elements = $this->getOption("elements");
     if (!$elements) {
         $elements = array();
     }
     for ($i = 0; $i < $this->getOption('size'); $i++) {
         if (isset($elements[$i])) {
             $blockParam = $elements[$i];
         } else {
             $blockParam = new EiBlockParam();
             $blockParam->setEiVersionStructureParent($block);
             $blockParam->setEiVersionId($block->getEiVersionId());
         }
         $form = new EiBlockParamForm($blockParam);
         if ($parentFormName) {
         }
         $this->embedForm($i, $form);
     }
 }
コード例 #3
0
 /**
  * @param Doctrine_Connection $conn
  */
 public function createAutoMapping(Doctrine_Connection $conn = null)
 {
     /** @var EiBlockForeach $block */
     $block = $this;
     /** @var EiDataSetStructure $node */
     $node = $this->getIteratorMapping()->getEiDataSetStructureMapping();
     // Si le block est nouveau, on crée automatiquement les paramètres et le mapping avec le jeu de données.
     if ($block->isEiBlock() && count($block->getParams()) == 0) {
         // Récupération des paramètres de la structure mappée.
         $nodeParams = $node->getEiDataSetStructures();
         /** @var EiDataSetStructure $param => Pour chaque noeud, on crée le paramètre pour le block. */
         foreach ($nodeParams as $param) {
             if ($param->isLeaf() && $node->getNode()->getLevel() == $param->getNode()->getLevel() - 1) {
                 // Création du paramètre pour le block.
                 $paramBlock = new EiBlockParam();
                 $paramBlock->setName($param->getName());
                 $paramBlock->setEiVersionId($block->getEiVersionId());
                 $paramBlock->setEiVersionStructureParent($block);
                 // Création du mapping IN.
                 $paramBlockSyncIn = new EiMappingStructureSyncIn();
                 $paramBlockSyncIn->setEiDataSetStructureMapping($param);
                 $paramBlockSyncIn->setEiVersionStructureMapping($paramBlock);
                 // Création du mapping OUT.
                 $paramBlockSyncOut = new EiMappingStructureSyncOut();
                 $paramBlockSyncOut->setEiDataSetStructureMapping($param);
                 $paramBlockSyncOut->setEiVersionStructureMapping($paramBlock);
                 // Persistence.
                 $block->getNode()->addChild($paramBlock);
                 $paramBlockSyncIn->save($conn);
                 $paramBlockSyncOut->save($conn);
             }
         }
     }
 }