Organize resource URLs, remove unused controller.

pull/3064/head
Julio Montoya 5 years ago
parent 8578c1f803
commit 3a76aa3574
  1. 2
      config/packages/sonata_page.yaml
  2. 51
      src/CoreBundle/Controller/ResourceController.php
  3. 142
      src/CoreBundle/Controller/ResourceDownloadController.php
  4. 1
      src/CoreBundle/Controller/ResourceUploaderController.php
  5. 2
      src/CoreBundle/Entity/Resource/AbstractResource.php
  6. 8
      src/CoreBundle/Entity/Resource/ResourceFile.php
  7. 11
      src/CoreBundle/Repository/IllustrationRepository.php
  8. 73
      src/CoreBundle/Repository/ResourceRepository.php
  9. 5
      src/CoreBundle/Resources/config/services.yml
  10. 26
      src/CoreBundle/Resources/views/Resource/info.html.twig
  11. 22
      src/CourseBundle/Controller/Home/HomeController.php
  12. 2
      src/CourseBundle/Repository/CDocumentRepository.php
  13. 4
      src/CourseBundle/Repository/CExerciseCategoryRepository.php
  14. 15
      src/CourseBundle/Resources/config/routing.yml

@ -44,7 +44,7 @@ sonata_page:
- ^/news/(.*) - ^/news/(.*)
- ^/courses/(.*) - ^/courses/(.*)
- ^/editor/(.*) - ^/editor/(.*)
- ^/resource/(.*) - ^/resources/(.*)
- ^/front/editor - ^/front/editor
- ^/contact(.*) # sonata admin - ^/contact(.*) # sonata admin
- ^/cms/pages/latest - ^/cms/pages/latest

@ -30,6 +30,10 @@ use Symfony\Component\HttpFoundation\StreamedResponse;
use Symfony\Component\HttpKernel\Exception\HttpException; use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Vich\UploaderBundle\Util\Transliterator; use Vich\UploaderBundle\Util\Transliterator;
use League\Flysystem\Adapter\Local;
use League\Flysystem\Filesystem;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
use Symfony\Component\Routing\Annotation\Route;
/** /**
* Class ResourceController. * Class ResourceController.
@ -401,7 +405,6 @@ class ResourceController extends BaseController implements CourseControllerInter
* Shows a resource. * Shows a resource.
* *
* @param Request $request * @param Request $request
* @param CDocumentRepository $documentRepo
* @param Glide $glide * @param Glide $glide
* *
* @return Response * @return Response
@ -429,29 +432,21 @@ class ResourceController extends BaseController implements CourseControllerInter
* *
* @return Response * @return Response
*/ */
public function showAction(Request $request, CDocumentRepository $documentRepo, Glide $glide): Response public function showAction(Request $request): Response
{ {
$file = $request->get('file'); $em = $this->getDoctrine();
$type = $request->get('type');
// see list of filters in config/services.yaml
$filter = $request->get('filter');
$type = !empty($type) ? $type : 'show';
$criteria = [
'path' => "/$file",
'course' => $this->getCourse(),
];
$document = $documentRepo->findOneBy($criteria); $id = $request->get('id');
$resourceNode = $em->getRepository('ChamiloCoreBundle:Resource\ResourceNode')->find($id);
if (null === $document) { if (null === $resourceNode) {
throw new NotFoundHttpException(); throw new NotFoundHttpException();
} }
/** @var ResourceNode $resourceNode */ $params = [
$resourceNode = $document->getResourceNode(); 'resource_node' => $resourceNode,
];
return $this->showFile($request, $resourceNode, $glide, $type, $filter); return $this->render('@ChamiloCore/Resource/info.html.twig', $params);
} }
/** /**
@ -619,4 +614,24 @@ class ResourceController extends BaseController implements CourseControllerInter
return $response; return $response;
} }
/**
* Upload form.
*
* @Route("/upload/{type}/{id}", name="resource_upload", methods={"GET", "POST"}, options={"expose"=true})
*
* @return Response
*/
public function showUploadFormAction($type, $id): Response
{
//$helper = $this->container->get('oneup_uploader.templating.uploader_helper');
//$endpoint = $helper->endpoint('courses');
return $this->render(
'@ChamiloCore/Resource/upload.html.twig',
[
'identifier' => $id,
'type' => $type,
]
);
}
} }

@ -1,142 +0,0 @@
<?php
/* For licensing terms, see /license.txt */
namespace Chamilo\CoreBundle\Controller;
use League\Flysystem\Adapter\Local;
use League\Flysystem\Filesystem;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
use Symfony\Component\HttpFoundation\File\MimeType\FileinfoMimeTypeGuesser;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\ResponseHeaderBag;
use Symfony\Component\Routing\Annotation\Route;
/**
* Class ResourceController.
*
* @author Julio Montoya <gugli100@gmail.com>.
*
* @Route("/resource")
*/
class ResourceDownloadController extends BaseController
{
/**
* Upload form.
*
* @Route("/upload/{type}/{id}", name="resource_upload", methods={"GET", "POST"}, options={"expose"=true})
*
* @return Response
*/
public function showUploadFormAction($type, $id): Response
{
//$helper = $this->container->get('oneup_uploader.templating.uploader_helper');
//$endpoint = $helper->endpoint('courses');
return $this->render(
'@ChamiloCore/Resource/upload.html.twig',
[
'identifier' => $id,
'type' => $type,
]
);
}
/**
* Downloads the file courses/MATHS/document/file.jpg to the user.
*
* @Route("/download/{course}/", name="resource_download", methods={"GET"}, options={"expose"=true})
*
* @todo check permissions
*
* @param string $course
*
* @return \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
*/
public function downloadFileAction(Request $request, $course)
{
try {
/** @var Filesystem $fs */
$fs = $this->container->get('oneup_flysystem.resources_filesystem');
$file = $request->get('file');
$path = $course.'/document/'.$file;
// Has folder
if (!$fs->has($course)) {
return $this->abort();
}
// Has file
if (!$fs->has($path)) {
return $this->abort();
}
/** @var Local $adapter */
$adapter = $fs->getAdapter();
$filePath = $adapter->getPathPrefix().$path;
$response = new BinaryFileResponse($filePath);
// To generate a file download, you need the mimetype of the file
$mimeTypeGuesser = new FileinfoMimeTypeGuesser();
// Set the mimetype with the guesser or manually
if ($mimeTypeGuesser->isSupported()) {
// Guess the mimetype of the file according to the extension of the file
$response->headers->set('Content-Type', $mimeTypeGuesser->guess($filePath));
} else {
// Set the mimetype of the file manually, in this case for a text file is text/plain
$response->headers->set('Content-Type', 'text/plain');
}
$response->setContentDisposition(
ResponseHeaderBag::DISPOSITION_ATTACHMENT,
basename($filePath)
);
return $response;
} catch (\InvalidArgumentException $e) {
return $this->abort();
}
}
/**
* Gets a document in browser courses/MATHS/document/file.jpg to the user.
*
* @Route("/get/{course}/", name="resource_get", methods={"GET"}, options={"expose"=true})
*
* @todo check permissions
*
* @param string $course
*
* @return \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
*/
public function getFileAction(Request $request, $course)
{
try {
/** @var Filesystem $fs */
$fs = $this->container->get('oneup_flysystem.resources_filesystem');
$file = $request->get('file');
$path = $course.'/document/'.$file;
// Has folder
if (!$fs->has($course)) {
return $this->abort();
}
// Has file
if (!$fs->has($path)) {
return $this->abort();
}
/** @var Local $adapter */
$adapter = $fs->getAdapter();
$filePath = $adapter->getPathPrefix().$path;
return $this->file($filePath, null, ResponseHeaderBag::DISPOSITION_INLINE);
} catch (\InvalidArgumentException $e) {
return $this->abort();
}
}
}

@ -21,6 +21,7 @@ class ResourceUploaderController extends BlueimpController
*/ */
public function upload() public function upload()
{ {
return;
error_log('upload!!!'); error_log('upload!!!');
$request = $this->getRequest(); $request = $this->getRequest();
$response = new EmptyResponse(); $response = new EmptyResponse();

@ -26,6 +26,8 @@ abstract class AbstractResource implements ResourceInterface
abstract public function getResourceName(): string; abstract public function getResourceName(): string;
/** /**
* Updates the resource node name when updating the resource.
*
* @ORM\PostUpdate() * @ORM\PostUpdate()
* *
* @param LifecycleEventArgs $args * @param LifecycleEventArgs $args

@ -205,6 +205,14 @@ class ResourceFile
$this->enabled = true; $this->enabled = true;
} }
/**
* @return string
*/
public function __toString(): string
{
return (string) $this->getName();
}
/** /**
* @return mixed * @return mixed
*/ */

@ -22,7 +22,7 @@ class IllustrationRepository extends ResourceRepository
* *
* @return ResourceFile * @return ResourceFile
*/ */
public function addIllustration(AbstractResource $resource, User $user, $uploadFile) public function addIllustration(AbstractResource $resource, User $user, $uploadFile): ?ResourceFile
{ {
$illustrationNode = $this->getIllustrationNodeFromResource($resource); $illustrationNode = $this->getIllustrationNodeFromResource($resource);
$em = $this->getEntityManager(); $em = $this->getEntityManager();
@ -33,6 +33,7 @@ class IllustrationRepository extends ResourceRepository
$illustrationNode = $this->addResourceNode($illustration, $user, $resource); $illustrationNode = $this->addResourceNode($illustration, $user, $resource);
//$this->addResourceToEveryone($illustrationNode); //$this->addResourceToEveryone($illustrationNode);
} }
return $this->addFile($illustrationNode, $uploadFile); return $this->addFile($illustrationNode, $uploadFile);
} }
@ -41,7 +42,7 @@ class IllustrationRepository extends ResourceRepository
* *
* @return ResourceNode * @return ResourceNode
*/ */
public function getIllustrationNodeFromResource(AbstractResource $resource) public function getIllustrationNodeFromResource(AbstractResource $resource): ?ResourceNode
{ {
$nodeRepo = $this->getResourceNodeRepository(); $nodeRepo = $this->getResourceNodeRepository();
$resourceType = $this->getResourceType(); $resourceType = $this->getResourceType();
@ -69,7 +70,7 @@ class IllustrationRepository extends ResourceRepository
/** /**
* @param AbstractResource $resource * @param AbstractResource $resource
* @param string $filter * @param string $filter See: services.yaml parameter "glide_media_filters" to see the list of filters.
* *
* @return string * @return string
*/ */
@ -83,8 +84,8 @@ class IllustrationRepository extends ResourceRepository
$params['filter'] = $filter; $params['filter'] = $filter;
} }
return $this->router->generate( return $this->getRouter()->generate(
'core_tool_resource', 'resources_get_file',
$params $params
); );
} }

@ -67,7 +67,7 @@ class ResourceRepository extends EntityRepository
public function __construct(EntityManager $entityManager, MountManager $mountManager, RouterInterface $router, string $className) public function __construct(EntityManager $entityManager, MountManager $mountManager, RouterInterface $router, string $className)
{ {
$this->repository = $entityManager->getRepository($className); $this->repository = $entityManager->getRepository($className);
// Flysystem mount name is saved in config/packages/oneup_flysystem.yaml // Flysystem mount name is saved in config/packages/oneup_flysystem.yaml @todo add it as a service.
$this->fs = $mountManager->getFilesystem('resources_fs'); $this->fs = $mountManager->getFilesystem('resources_fs');
$this->router = $router; $this->router = $router;
$this->resourceNodeRepository = $entityManager->getRepository('ChamiloCoreBundle:Resource\ResourceNode'); $this->resourceNodeRepository = $entityManager->getRepository('ChamiloCoreBundle:Resource\ResourceNode');
@ -81,6 +81,14 @@ class ResourceRepository extends EntityRepository
return new $this->className(); return new $this->className();
} }
/**
* @return RouterInterface
*/
public function getRouter(): RouterInterface
{
return $this->router;
}
/** /**
* @return EntityRepository * @return EntityRepository
*/ */
@ -120,7 +128,7 @@ class ResourceRepository extends EntityRepository
* *
* @return AbstractResource|null * @return AbstractResource|null
*/ */
public function find($id, $lockMode = null, $lockVersion = null) public function find($id, $lockMode = null, $lockVersion = null): ?AbstractResource
{ {
return $this->getRepository()->find($id); return $this->getRepository()->find($id);
} }
@ -131,7 +139,7 @@ class ResourceRepository extends EntityRepository
* *
* @return AbstractResource * @return AbstractResource
*/ */
public function findOneBy(array $criteria, array $orderBy = null) public function findOneBy(array $criteria, array $orderBy = null): ?AbstractResource
{ {
return $this->getRepository()->findOneBy($criteria, $orderBy); return $this->getRepository()->findOneBy($criteria, $orderBy);
} }
@ -142,7 +150,7 @@ class ResourceRepository extends EntityRepository
* *
* @return ResourceFile * @return ResourceFile
*/ */
public function addFile(ResourceNode $resourceNode, UploadedFile $file) public function addFile(ResourceNode $resourceNode, UploadedFile $file): ?ResourceFile
{ {
$resourceFile = $resourceNode->getResourceFile(); $resourceFile = $resourceNode->getResourceFile();
if ($resourceFile === null) { if ($resourceFile === null) {
@ -170,11 +178,8 @@ class ResourceRepository extends EntityRepository
* *
* @return ResourceNode * @return ResourceNode
*/ */
public function addResourceNode( public function addResourceNode(AbstractResource $resource, User $creator, AbstractResource $parent = null): ResourceNode
AbstractResource $resource, {
User $creator,
AbstractResource $parent = null
): ResourceNode {
$em = $this->getEntityManager(); $em = $this->getEntityManager();
$resourceType = $this->getResourceType(); $resourceType = $this->getResourceType();
@ -199,7 +204,15 @@ class ResourceRepository extends EntityRepository
return $resourceNode; return $resourceNode;
} }
public function addResourceToCourse(AbstractResource $resource, $visibility, User $creator, Course $course, $session = null, $group = null) /**
* @param AbstractResource $resource
* @param int $visibility
* @param User $creator
* @param Course $course
* @param Session $session
* @param CGroupInfo $group
*/
public function addResourceToCourse(AbstractResource $resource, int $visibility, User $creator, Course $course, Session $session = null, CGroupInfo $group = null)
{ {
$node = $this->addResourceNode($resource, $creator, $course); $node = $this->addResourceNode($resource, $creator, $course);
$this->addResourceNodeToCourse($node, $visibility, $course, $session, $group); $this->addResourceNodeToCourse($node, $visibility, $course, $session, $group);
@ -305,8 +318,6 @@ class ResourceRepository extends EntityRepository
return $resourceLink; return $resourceLink;
} }
/** /**
* @param ResourceNode $resourceNode * @param ResourceNode $resourceNode
* @param Course $course * @param Course $course
@ -463,7 +474,7 @@ class ResourceRepository extends EntityRepository
); );
$type = $this->getResourceType(); $type = $this->getResourceType();
$query = $this->getEntityManager()->createQueryBuilder() $qb = $this->getEntityManager()->createQueryBuilder()
->select('resource') ->select('resource')
->from(ResourceNode::class, 'node') ->from(ResourceNode::class, 'node')
->innerJoin('node.resourceLinks', 'links') ->innerJoin('node.resourceLinks', 'links')
@ -486,37 +497,39 @@ class ResourceRepository extends EntityRepository
); );
if ($session === null) { if ($session === null) {
$query->andWhere('links.session IS NULL'); $qb->andWhere('links.session IS NULL');
} else { } else {
if ($loadBaseSessionContent) { if ($loadBaseSessionContent) {
$query->andWhere('links.session = :session OR links.session IS NULL'); $qb->andWhere('links.session = :session OR links.session IS NULL');
$query->setParameter('session', $session); $qb->setParameter('session', $session);
} else { } else {
$query->andWhere('links.session = :session'); $qb->andWhere('links.session = :session');
$query->setParameter('session', $session); $qb->setParameter('session', $session);
} }
} }
if ($group === null) { if ($group === null) {
$query->andWhere('links.group IS NULL'); $qb->andWhere('links.group IS NULL');
} }
/*if ($parent !== null) { /*if ($parent !== null) {
$query->andWhere('node.parent = :parentId'); $qb->andWhere('node.parent = :parentId');
$query->setParameter('parentId', $parent->getResourceNode()->getId()); $qb->setParameter('parentId', $parent->getResourceNode()->getId());
} else { } else {
$query->andWhere('node.parent = :parentId'); $qb->andWhere('node.parent = :parentId');
$query->setParameter('parentId', $course->getResourceNode()); $qb->setParameter('parentId', $course->getResourceNode());
}*/ }*/
/*$query->setFirstResult(); /*$qb->setFirstResult();
$query->setMaxResults(); $qb->setMaxResults();
$query->orderBy();*/ $qb->orderBy();*/
return $qb;
$query = $query->getQuery(); $qb = $qb->getQuery();
//var_dump($query->getSQL()); //var_dump($qb->getSQL());
/*$query = $this->getEntityManager()->createQueryBuilder() /*$qb = $this->getEntityManager()->createQueryBuilder()
->select('notebook') ->select('notebook')
->from('ChamiloNotebookBundle:CNotebook', 'notebook') ->from('ChamiloNotebookBundle:CNotebook', 'notebook')
->innerJoin('notebook.resourceNodes', 'node') ->innerJoin('notebook.resourceNodes', 'node')
@ -531,7 +544,7 @@ class ResourceRepository extends EntityRepository
) )
->getQuery() ->getQuery()
;*/ ;*/
return $query->getResult(); return $qb->getResult();
} }
/** /**

@ -67,6 +67,11 @@ services:
# tags: # tags:
# - {name: twig.extension} # - {name: twig.extension}
# twig.extension.date:
# class: Twig_Extensions_Extension_Date
# tags:
# - { name: twig.extension }
# Chamilo custom password encoder (depends on the password_encryption param) # Chamilo custom password encoder (depends on the password_encryption param)
# chamilo_user.security.encoder: # chamilo_user.security.encoder:
# class: Chamilo\UserBundle\Security\Encoder # class: Chamilo\UserBundle\Security\Encoder

@ -0,0 +1,26 @@
{% extends "@ChamiloTheme/Layout/layout_one_col.html.twig" %}
{% block content %}
{% autoescape false %}
<h3>{{ resource_node.name }} </h3>
Type: {{ resource_node.resourceType }} <br />
{% if resource_node.resourceFile %}
File:
<a href="{{ url('resources_get_file', {id: resource_node.id } ) }}">
{{ resource_node.resourceFile }}
</a>
<br />
Size: {{ resource_node.resourceFile.size }}
<br /><br />
{% endif %}
Updated at: {{ resource_node.updatedAt | date_to_time_ago }}
<br />
Created at: {{ resource_node.createdAt | date_to_time_ago }}<br />
<br />
Creator: {{ resource_node.creator }}
{% endautoescape %}
{% endblock %}

@ -3,6 +3,7 @@
namespace Chamilo\CourseBundle\Controller\Home; namespace Chamilo\CourseBundle\Controller\Home;
use APY\DataGridBundle\Grid\Source\Entity;
use Chamilo\CourseBundle\Controller\ToolBaseController; use Chamilo\CourseBundle\Controller\ToolBaseController;
use Chamilo\CourseBundle\Entity\CTool; use Chamilo\CourseBundle\Entity\CTool;
use CourseHome; use CourseHome;
@ -16,6 +17,7 @@ use Security;
use Event; use Event;
use Database; use Database;
use ExtraFieldValue; use ExtraFieldValue;
use Ublaboo\DataGrid\DataGrid;
/** /**
* Class HomeController. * Class HomeController.
@ -106,8 +108,6 @@ class HomeController extends ToolBaseController
$logInfo = [ $logInfo = [
'tool' => 'course-main', 'tool' => 'course-main',
'tool_id' => 0,
'tool_id_detail' => 0,
'action' => $action, 'action' => $action,
]; ];
Event::registerLog($logInfo); Event::registerLog($logInfo);
@ -285,13 +285,11 @@ class HomeController extends ToolBaseController
//require 'activity.php'; //require 'activity.php';
// Activity start // Activity start
$id = isset($_GET['id']) ? (int) $_GET['id'] : null; $id = isset($_GET['id']) ? (int) $_GET['id'] : null;
$course_id = api_get_course_int_id(); $course_id = api_get_course_int_id();
$session_id = api_get_session_id(); $session_id = api_get_session_id();
// Work with data post askable by admin of course // Work with data post askable by admin of course
if (api_is_platform_admin()) { if (api_is_platform_admin()) {
// Show message to confirm that a tool it to be hidden from available tools // Show message to confirm that a tool it to be hidden from available tools
// visibility 0,1->2 // visibility 0,1->2
@ -317,7 +315,7 @@ class HomeController extends ToolBaseController
$pluginExtra = $plugin->getTeacherLink(); $pluginExtra = $plugin->getTeacherLink();
} }
// Start of tools for CourseAdmins (teachers/tutors) // Start of tools for CourseAdmins (teachers/tutors)
if ($session_id === 0 && api_is_course_admin() && api_is_allowed_to_edit(null, true)) { if ($session_id === 0 && api_is_course_admin() && api_is_allowed_to_edit(null, true)) {
$content .= '<div class="alert alert-success" style="border:0px; margin-top: 0px;padding:0px;"> $content .= '<div class="alert alert-success" style="border:0px; margin-top: 0px;padding:0px;">
<div class="normal-message" id="id_normal_message" style="display:none">'; <div class="normal-message" id="id_normal_message" style="display:none">';
@ -340,11 +338,9 @@ class HomeController extends ToolBaseController
} }
$blocks = CourseHome::getUserBlocks(); $blocks = CourseHome::getUserBlocks();
// Activity end // Activity end
// Get session-career diagram // Get session-career diagram
$diagram = ''; $diagram = '';
$allow = api_get_configuration_value('allow_career_diagram'); $allow = api_get_configuration_value('allow_career_diagram');
if ($allow === true) { if ($allow === true) {
@ -395,6 +391,10 @@ class HomeController extends ToolBaseController
$content = '<div id="course_tools">'.$diagram.$content.'</div>'; $content = '<div id="course_tools">'.$diagram.$content.'</div>';
$source = new Entity('ChamiloCourseBundle:CExerciseCategory');
$grid = $this->get('grid');
$grid ->setSource($source);
// Deleting the objects // Deleting the objects
Session::erase('_gid'); Session::erase('_gid');
Session::erase('oLP'); Session::erase('oLP');
@ -403,11 +403,15 @@ class HomeController extends ToolBaseController
\Exercise::cleanSessionVariables(); \Exercise::cleanSessionVariables();
\DocumentManager::removeGeneratedAudioTempFile(); \DocumentManager::removeGeneratedAudioTempFile();
return $this->render( return $this->render(
'@ChamiloTheme/Course/home.html.twig', '@ChamiloTheme/Course/home.html.twig',
[ [
'course' => $course, 'course' => $course,
'diagram' => $diagram, 'diagram' => $diagram,
'grid' => $grid,
// 'session_info' => $sessionInfo, // 'session_info' => $sessionInfo,
'icons' => $result['content'], 'icons' => $result['content'],
'blocks' => $blocks, 'blocks' => $blocks,

@ -38,7 +38,7 @@ final class CDocumentRepository extends ResourceRepository
]; ];
return $this->getRouter()->generate( return $this->getRouter()->generate(
'core_tool_document', 'resources_document_get_file',
$params $params
); );
} }

@ -22,7 +22,7 @@ final class CExerciseCategoryRepository extends ResourceRepository
{ {
$query = $this->getRepository()->createQueryBuilder('e'); $query = $this->getRepository()->createQueryBuilder('e');
$query->select('count(e.id)'); $query->select('count(e.id)');
$query->where('e.cId = :cId'); $query->where('e.course = :cId');
$query->setParameter('cId', $courseId); $query->setParameter('cId', $courseId);
return $query->getQuery()->getSingleScalarResult(); return $query->getQuery()->getSingleScalarResult();
@ -36,7 +36,7 @@ final class CExerciseCategoryRepository extends ResourceRepository
public function getCategories($courseId) public function getCategories($courseId)
{ {
$query = $this->getRepository()->createQueryBuilder('e'); $query = $this->getRepository()->createQueryBuilder('e');
$query->where('e.cId = :cId'); $query->where('e.course = :cId');
$query->setParameter('cId', $courseId); $query->setParameter('cId', $courseId);
$query->orderBy('e.position'); $query->orderBy('e.position');

@ -7,20 +7,27 @@ core_tool:
type: annotation type: annotation
prefix: /courses/{course}/ prefix: /courses/{course}/
core_tool_document: resources_get_info:
path: /courses/{course}/document/{file} path: /resources/{id}
defaults: defaults:
_controller: Chamilo\CoreBundle\Controller\ResourceController::showAction _controller: Chamilo\CoreBundle\Controller\ResourceController::showAction
requirements: requirements:
file: .+ # allow "/" in {file} file: .+ # allow "/" in {file}
core_tool_resource: resources_get_file:
path: /resources/{id} path: /resources/file/{id}
defaults: defaults:
_controller: Chamilo\CoreBundle\Controller\ResourceController::getResourceFileAction _controller: Chamilo\CoreBundle\Controller\ResourceController::getResourceFileAction
requirements: requirements:
file: .+ # allow "/" in {file} file: .+ # allow "/" in {file}
resources_document_get_file:
path: /courses/{course}/document/{file}
defaults:
_controller: Chamilo\CoreBundle\Controller\ResourceController::showAction
requirements:
file: .+ # allow "/" in {file}
chamilo_course_tool_intro_create: chamilo_course_tool_intro_create:
path: /courses/{course}/introduction/{tool}/create/ path: /courses/{course}/introduction/{tool}/create/
methods: [GET, POST] methods: [GET, POST]

Loading…
Cancel
Save