1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* For licensing terms, see /license.txt */ |
6
|
|
|
|
7
|
|
|
namespace Chamilo\CourseBundle\Repository; |
8
|
|
|
|
9
|
|
|
use Chamilo\CoreBundle\Component\Resource\Settings; |
10
|
|
|
use Chamilo\CoreBundle\Component\Resource\Template; |
11
|
|
|
use Chamilo\CoreBundle\Entity\Course; |
12
|
|
|
use Chamilo\CoreBundle\Entity\ResourceInterface; |
13
|
|
|
use Chamilo\CoreBundle\Entity\ResourceNode; |
14
|
|
|
use Chamilo\CoreBundle\Entity\Session; |
15
|
|
|
use Chamilo\CoreBundle\Entity\User; |
16
|
|
|
use Chamilo\CoreBundle\Form\Resource\CGlossaryType; |
17
|
|
|
use Chamilo\CoreBundle\Repository\ResourceRepository; |
18
|
|
|
use Chamilo\CoreBundle\Repository\ResourceWithLinkInterface; |
19
|
|
|
use Chamilo\CourseBundle\Entity\CGlossary; |
20
|
|
|
use Chamilo\CourseBundle\Entity\CGroup; |
21
|
|
|
use Doctrine\ORM\QueryBuilder; |
22
|
|
|
use Doctrine\Persistence\ManagerRegistry; |
23
|
|
|
use Symfony\Component\Routing\RouterInterface; |
24
|
|
|
|
25
|
|
|
final class CGlossaryRepository extends ResourceRepository implements ResourceWithLinkInterface |
26
|
|
|
{ |
27
|
|
|
public function __construct(ManagerRegistry $registry) |
28
|
|
|
{ |
29
|
|
|
parent::__construct($registry, CGlossary::class); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
public function getResourceSettings(): Settings |
33
|
|
|
{ |
34
|
|
|
$settings = parent::getResourceSettings(); |
35
|
|
|
|
36
|
|
|
$settings->setAllowResourceCreation(true); |
37
|
|
|
|
38
|
|
|
return $settings; |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
public function getTemplates(): Template |
42
|
|
|
{ |
43
|
|
|
$templates = parent::getTemplates(); |
44
|
|
|
|
45
|
|
|
$templates |
46
|
|
|
->setViewResource('@ChamiloCore/Resource/glossary/view_resource.html.twig') |
47
|
|
|
; |
48
|
|
|
|
49
|
|
|
return $templates; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/*public function getResources(User $user, ResourceNode $parentNode, Course $course = null, Session $session = null, CGroup $group = null): QueryBuilder |
53
|
|
|
{ |
54
|
|
|
return $this->getResourcesByCourse($course, $session, $group, $parentNode); |
55
|
|
|
}*/ |
56
|
|
|
|
57
|
|
|
public function getResourceFormType(): string |
58
|
|
|
{ |
59
|
|
|
return CGlossaryType::class; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
public function getLink(ResourceInterface $resource, RouterInterface $router, array $extraParams = []): string |
63
|
|
|
{ |
64
|
|
|
$params = [ |
65
|
|
|
'name' => 'glossary/index.php', |
66
|
|
|
'glossary_id' => $resource->getResourceIdentifier(), |
67
|
|
|
]; |
68
|
|
|
if (!empty($extraParams)) { |
69
|
|
|
$params = array_merge($params, $extraParams); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
return $router->generate('legacy_main', $params); |
73
|
|
|
} |
74
|
|
|
} |
75
|
|
|
|