Esempio n. 1
0
 /**
  * Update an existing step from JSON structure
  * @param  \Innova\PathBundle\Entity\Path\Path $path          Parent path of the step
  * @param  integer                             $level         Depth of the step in the path
  * @param  \Innova\PathBundle\Entity\Step      $parent        Parent step of the step
  * @param  integer                             $order         Order of the step relative to its siblings
  * @param  \stdClass                           $stepStructure Data about the step
  * @param  \Innova\PathBundle\Entity\Step      $step          Current step to edit
  * @return \Innova\PathBundle\Entity\Step      Edited step
  */
 public function edit(Path $path, $level = 0, Step $parent = null, $order = 0, \stdClass $stepStructure, Step $step)
 {
     // Update step properties
     $step->setPath($path);
     $step->setParent($parent);
     $step->setLvl($level);
     $step->setOrder($order);
     $this->updateParameters($step, $stepStructure);
     $this->updateActivity($step, $stepStructure);
     // Save modifications
     $this->om->persist($step);
     return $step;
 }
Esempio n. 2
0
 public function import(Path $path, array $data, array $createdResources = array(), array $createdSteps = array())
 {
     $step = new Step();
     $step->setPath($path);
     if (!empty($data['parent'])) {
         $step->setParent($createdSteps[$data['parent']]);
     }
     $step->setLvl($data['lvl']);
     $step->setOrder($data['order']);
     // Link Step to its Activity
     if (!empty($data['activityNodeId']) && !empty($createdResources[$data['activityNodeId']])) {
         // Step has an Activity
         $step->setActivity($createdResources[$data['activityNodeId']]);
     }
     if (!empty($data['inheritedResources'])) {
         foreach ($data['inheritedResources'] as $inherited) {
             if (!empty($createdResources[$inherited['resource']])) {
                 // Check if the resource has been created (in case of the Resource has no Importer, it may not exist)
                 $inheritedResource = new InheritedResource();
                 $inheritedResource->setLvl($inherited['lvl']);
                 $inheritedResource->setStep($step);
                 $inheritedResource->setResource($createdResources[$inherited['resource']]->getResourceNode());
                 $this->om->persist($inheritedResource);
             }
         }
     }
     $createdSteps[$data['uid']] = $step;
     $this->om->persist($step);
     return $createdSteps;
 }