Example #1
0
 /**
  * @param Course $course
  * @return Course
  */
 public function addToolsInCourse(Course $course)
 {
     $tools = $this->getTools();
     /** @var BaseTool $tool */
     foreach ($tools as $tool) {
         $toolEntity = new CTool();
         $toolEntity->setCId($course->getId())->setImage($tool->getImage())->setName($tool->getName())->setVisibility(1)->setLink($tool->getLink())->setTarget($tool->getTarget())->setCategory($tool->getCategory());
         $course->addTools($toolEntity);
     }
     return $course;
 }
Example #2
0
 public function updateTools($course)
 {
     $toolChain = $this->getToolChain();
     $tools = $toolChain->getTools();
     $currentTools = $course->getTools();
     // @todo use
     //$toolChain->addToolsInCourse($course);
     $addedTools = array();
     if (!empty($currentTools)) {
         foreach ($currentTools as $tool) {
             $addedTools[] = $tool->getName();
         }
     }
     foreach ($tools as $tool) {
         $toolName = $tool->getName();
         if (!in_array($toolName, $addedTools)) {
             $toolEntity = new CTool();
             $toolEntity->setCId($course->getId())->setImage($tool->getImage())->setName($tool->getName())->setLink($tool->getLink())->setTarget($tool->getTarget())->setCategory($tool->getCategory());
             $course->addTools($toolEntity);
         }
     }
 }