Browse Source

Minor - add function api_get_session_entity()

jmontoyaa 7 years ago
parent
commit
e24303350c
1 changed files with 14 additions and 1 deletions
  1. 14 1
      main/inc/lib/api.lib.php

+ 14 - 1
main/inc/lib/api.lib.php

@@ -1952,7 +1952,7 @@ function api_get_course_info($course_code = null, $strict = false)
  * @param int $courseId
  * @return \Chamilo\CoreBundle\Entity\Course
  */
-function api_get_course_entity($courseId)
+function api_get_course_entity($courseId = 0)
 {
     if (empty($courseId)) {
         $courseId = api_get_course_int_id();
@@ -1960,6 +1960,19 @@ function api_get_course_entity($courseId)
     return Database::getManager()->getRepository('ChamiloCoreBundle:Course')->find($courseId);
 }
 
+
+/**
+ * @param int $id
+ * @return \Chamilo\CoreBundle\Entity\Session
+ */
+function api_get_session_entity($id = 0)
+{
+    if (empty($id)) {
+        $id = api_get_session_id();
+    }
+    return Database::getManager()->getRepository('ChamiloCoreBundle:Session')->find($id);
+}
+
 /**
  * Returns the current course info array.