コード例 #1
0
ファイル: Step.php プロジェクト: stmolivier/PathBundle
 /**
  * Wrapper to access workspace of the Step
  * @return \Claroline\CoreBundle\Entity\Workspace\Workspace
  */
 public function getWorkspace()
 {
     $workspace = null;
     if (!empty($this->path)) {
         $workspace = $this->path->getWorkspace();
     }
     return $workspace;
 }
コード例 #2
0
 /**
  * Check that all Activities and Resources as at least same rights than the Path
  * @return \Innova\PathBundle\Manager\PublishingManager
  */
 protected function manageRights()
 {
     // Grab Resources and Activities
     $nodes = $this->retrieveAllNodes($this->path->getSteps()->toArray());
     if (!empty($nodes)) {
         $pathRights = $this->path->getResourceNode()->getRights();
         foreach ($nodes as $node) {
             foreach ($pathRights as $right) {
                 if ($right->getMask() & 1) {
                     $this->rightsManager->editPerms($right->getMask(), $right->getRole(), $node, true);
                 }
             }
         }
     }
     return $this;
 }
コード例 #3
0
 /**
  * Fired when a ResourceNode of type Path is duplicated
  * @param \Claroline\CoreBundle\Event\CopyResourceEvent $event
  * @throws \Exception
  */
 public function onCopy(CopyResourceEvent $event)
 {
     $om = $this->container->get('claroline.persistence.object_manager');
     // Start the transaction. We'll copy every resource in one go that way.
     $om->startFlushSuite();
     // Get Path to duplicate
     $pathToCopy = $event->getResource();
     // Create new Path
     $path = new Path();
     // Set up new Path properties
     $path->setName($pathToCopy->getName());
     $path->setDescription($pathToCopy->getDescription());
     $parent = $event->getParent();
     $structure = json_decode($pathToCopy->getStructure());
     // Process steps
     $processedNodes = array();
     foreach ($structure->steps as $step) {
         $processedNodes = $this->copyStepContent($step, $parent, $processedNodes);
     }
     // End the transaction
     $om->endFlushSuite();
     // We need the resources ids
     $om->forceFlush();
     //update the structure tree
     foreach ($structure->steps as $step) {
         $this->updateStep($step, $processedNodes);
     }
     $path->setStructure(json_encode($structure));
     $event->setCopy($path);
     // Force the unpublished state (the publication will recreate the correct links, and create new Activities)
     // If we directly copy all the published Entities we can't remap some relations
     $event->setPublish(false);
     $event->stopPropagation();
 }
コード例 #4
0
 /**
  * Import a Path into the Platform.
  *
  * @param string $structure
  * @param array  $data
  * @param array  $resourcesCreated
  *
  * @return Path
  */
 public function import($structure, array $data, array $resourcesCreated = [])
 {
     // Create a new Path object which will be populated with exported data
     $path = new Path();
     $pathData = $data['data']['path'];
     // Populate Path properties
     $path->setBreadcrumbs(!empty($pathData['breadcrumbs']) ? $pathData['breadcrumbs'] : false);
     $path->setDescription($pathData['description']);
     $path->setModified($pathData['modified']);
     $path->setSummaryDisplayed($pathData['summaryDisplayed']);
     $path->setCompleteBlockingCondition($pathData['completeBlockingCondition']);
     $path->setManualProgressionAllowed($pathData['manualProgressionAllowed']);
     // Create steps
     $stepData = $data['data']['steps'];
     if (!empty($stepData)) {
         $createdSteps = [];
         foreach ($stepData as $step) {
             $createdSteps = $this->stepManager->import($path, $step, $resourcesCreated, $createdSteps);
         }
     }
     // Inject empty structure into path (will be replaced by a version with updated IDs later in the import process)
     $path->setStructure($structure);
     return $path;
 }
コード例 #5
0
ファイル: PathManager.php プロジェクト: stmolivier/PathBundle
 /**
  * Delete path
  * @param  \Innova\PathBundle\Entity\Path\Path $path
  * @return boolean
  * @throws \Exception
  */
 public function delete(Path $path)
 {
     // User can delete current path
     $this->om->remove($path->getResourceNode());
     $this->om->flush();
     return $this;
 }
コード例 #6
0
 /**
  * Fired when a ResourceNode of type Path is duplicated
  * @param \Claroline\CoreBundle\Event\CopyResourceEvent $event
  * @throws \Exception
  */
 public function onCopy(CopyResourceEvent $event)
 {
     // Get Path to duplicate
     $pathToCopy = $event->getResource();
     // Create new Path
     $path = new Path();
     // Set up new Path properties
     $path->setName($pathToCopy->getName());
     $path->setDescription($pathToCopy->getDescription());
     $parent = $event->getParent();
     $structure = json_decode($pathToCopy->getStructure());
     // Process steps
     $processedNodes = array();
     foreach ($structure->steps as $step) {
         $processedNodes = $this->copyStepContent($step, $parent, $processedNodes);
     }
     // Store the new structure of the Path
     $path->setStructure(json_encode($structure));
     $event->setCopy($path);
     // Force the unpublished state (the publication will recreate the correct links, and create new Activities)
     // If we directly copy all the published Entities we can't remap some relations
     $event->setPublish(false);
     $event->stopPropagation();
 }
コード例 #7
0
 /**
  * Get list of teams available in the Workspace of the current Path.
  *
  * @param Path $path
  *
  * @return \Symfony\Component\HttpFoundation\JsonResponse
  *
  * @Route(
  *     "/team/{id}",
  *     name = "innova_path_criteria_teams"
  * )
  * @Method("GET")
  */
 public function listTeamsAction(Path $path)
 {
     $data = [];
     // retrieve list of groups object for this user
     $teams = $this->teamManager->getTeamsByWorkspace($path->getWorkspace());
     if ($teams) {
         // data needs to be explicitly set because Team does not extends Serializable
         /** @var \Claroline\TeamBundle\Entity\Team $team */
         foreach ($teams as $team) {
             $data[$team->getId()] = $team->getName();
         }
     }
     return new JsonResponse($data);
 }
コード例 #8
0
ファイル: Step.php プロジェクト: claroline/distribution
 /**
  * Set path.
  *
  * @param \Innova\PathBundle\Entity\Path\Path $path
  *
  * @return \Innova\PathBundle\Entity\
  */
 public function setPath(Path\Path $path = null)
 {
     $this->path = $path;
     if (!empty($path)) {
         $path->addStep($this);
     }
     return $this;
 }