/**
  * Convert the course info to array with necessary course data for save item
  * @param \Chamilo\CoreBundle\Entity\Course $course
  * @param array $defaultCurrency Optional. Currency data
  * @return array
  */
 public function getCourseForConfiguration(\Chamilo\CoreBundle\Entity\Course $course, $defaultCurrency = null)
 {
     $courseItem = ['item_id' => null, 'course_id' => $course->getId(), 'course_visual_code' => $course->getVisualCode(), 'course_code' => $course->getCode(), 'course_title' => $course->getTitle(), 'course_visibility' => $course->getVisibility(), 'visible' => false, 'currency' => empty($defaultCurrency) ? null : $defaultCurrency['iso_code'], 'price' => 0.0];
     $item = $this->getItemByProduct($course->getId(), self::PRODUCT_TYPE_COURSE);
     if ($item !== false) {
         $courseItem['item_id'] = $item['id'];
         $courseItem['visible'] = true;
         $courseItem['currency'] = $item['iso_code'];
         $courseItem['price'] = $item['price'];
     }
     return $courseItem;
 }
Esempio n. 2
0
 /**
  * @param CourseRepository $repo
  * @param Course $course
  * @param AccessUrl $url
  * @throws \Exception
  */
 private function checkLimit($repo, Course $course, AccessUrl $url)
 {
     $limit = $url->getLimitCourses();
     if (!empty($limit)) {
         $count = $repo->getCountCoursesByUrl($url);
         if ($count >= $limit) {
             api_warn_hosting_contact('hosting_limit_courses', $limit);
             throw new \Exception('PortalCoursesLimitReached');
         }
     }
     if ($course->getVisibility() != COURSE_VISIBILITY_HIDDEN) {
         $limit = $url->getLimitActiveCourses();
         if (!empty($limit)) {
             $count = $repo->getCountActiveCoursesByUrl($url);
             if ($count >= $limit) {
                 api_warn_hosting_contact('hosting_limit_active_courses', $limit);
                 throw new \Exception('PortalActiveCoursesLimitReached');
             }
         }
     }
 }