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;
 }
 /**
  * Manage resource inheritance
  * @param  \Innova\PathBundle\Entity\Step               $step
  * @param  array                                        $propagatedResources
  * @param  array                                        $excludedResources
  * @return \Innova\PathBundle\Manager\PublishingManager
  */
 protected function publishPropagatedResources(Step $step, array $propagatedResources = array(), array $excludedResources = array())
 {
     $inheritedResources = array();
     $currentInherited = $step->getInheritedResources();
     if (!empty($propagatedResources)) {
         foreach ($propagatedResources as $resource) {
             if (!in_array($resource['id'], $excludedResources)) {
                 // Resource is not excluded => link it to step
                 // Retrieve resource node
                 $resourceNode = $this->om->getRepository('ClarolineCoreBundle:Resource\\ResourceNode')->findOneById($resource['resourceId']);
                 if (!($inherited = $step->hasInheritedResource($resourceNode->getId()))) {
                     // Inherited resource doesn't exist => Create inherited resource
                     $inherited = new InheritedResource();
                 }
                 // Update inherited resource properties
                 $inherited->setResource($resourceNode);
                 $inherited->setLvl($resource['lvl']);
                 // Add inherited resource to Step
                 $step->addInheritedResource($inherited);
                 $this->om->persist($inherited);
                 // Store resource ID to clean step
                 $inheritedResources[] = $resourceNode->getId();
             }
         }
     }
     // Clean inherited resources which no long exists
     foreach ($currentInherited as $inherited) {
         $resourceId = $inherited->getResource()->getId();
         if (!in_array($resourceId, $inheritedResources)) {
             $step->removeInheritedResource($inherited);
             $this->om->remove($inherited);
         }
     }
     return $this;
 }