Chamilo is a learning management system focused on ease of use and accessibility
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
chamilo-lms/src/CoreBundle/Controller/CourseController.php

70 lines
1.8 KiB

<?php
/* For licensing terms, see /license.txt */
namespace Chamilo\CoreBundle\Controller;
use Chamilo\CoreBundle\Entity\Course;
use Chamilo\CoreBundle\Form\Type\CourseType;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
/**
* Class CourseController.
*
* @Route("/course")
*
* @package Chamilo\CoreBundle\Controller
*/
class CourseController extends Controller
{
/**
* @Route("/add")
* @Security("has_role('ROLE_TEACHER')")
* @Template
*
* @return Response
*/
public function addAction(Request $request)
{
$form = $this->createForm(new CourseType());
$form->handleRequest($request);
if ($form->isValid()) {
$em = $this->getDoctrine()->getManager();
$course = $form->getData();
$em->persist($course);
$em->flush();
$this->addFlash('sonata_flash_success', 'Course created');
return $this->redirectToRoute(
'chamilo_core_course_welcome',
['course' => $course]
);
}
return [
'form' => $form->createView(),
];
}
/**
* @Route("/welcome/{course}")
* @ParamConverter(
* "course",
* class="ChamiloCoreBundle:Course",
* options={"repository_method" = "findOneByCode"}
* )
* @Template
*/
public function welcomeAction(Course $course)
{
return ['course' => $course];
}
}