1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* For licensing terms, see /license.txt */ |
6
|
|
|
|
7
|
|
|
namespace Chamilo\CoreBundle\Traits; |
8
|
|
|
|
9
|
|
|
use Chamilo\CoreBundle\Repository\ResourceNodeRepository; |
10
|
|
|
use Chamilo\CoreBundle\ToolChain; |
11
|
|
|
use Cocur\Slugify\SlugifyInterface; |
12
|
|
|
use Doctrine\ORM\EntityManager; |
13
|
|
|
use Doctrine\ORM\EntityRepository; |
14
|
|
|
use Symfony\Component\HttpFoundation\Request; |
15
|
|
|
use Symfony\Component\HttpFoundation\RequestStack; |
16
|
|
|
use Symfony\Component\Routing\RouterInterface; |
17
|
|
|
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface; |
18
|
|
|
|
19
|
|
|
trait NonResourceRepository |
20
|
|
|
{ |
21
|
|
|
protected EntityRepository $repository; |
22
|
|
|
|
23
|
|
|
protected EntityManager $entityManager; |
24
|
|
|
|
25
|
|
|
protected ?RouterInterface $router = null; |
26
|
|
|
|
27
|
|
|
protected ?ResourceNodeRepository $resourceNodeRepository = null; |
28
|
|
|
|
29
|
|
|
protected ?AuthorizationCheckerInterface $authorizationChecker = null; |
30
|
|
|
|
31
|
|
|
protected ?SlugifyInterface $slugify = null; |
32
|
|
|
|
33
|
|
|
protected ?ToolChain $toolChain = null; |
34
|
|
|
|
35
|
|
|
protected ?RequestStack $requestStack; |
36
|
|
|
|
37
|
|
|
public function getAuthorizationChecker(): AuthorizationCheckerInterface |
38
|
|
|
{ |
39
|
|
|
return $this->authorizationChecker; |
|
|
|
|
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
public function setAuthorizationChecker(AuthorizationCheckerInterface $authorizationChecker): self |
43
|
|
|
{ |
44
|
|
|
$this->authorizationChecker = $authorizationChecker; |
45
|
|
|
|
46
|
|
|
return $this; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
public function getRouter(): RouterInterface |
50
|
|
|
{ |
51
|
|
|
return $this->router; |
|
|
|
|
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
public function setRouter(RouterInterface $router): self |
55
|
|
|
{ |
56
|
|
|
$this->router = $router; |
57
|
|
|
|
58
|
|
|
return $this; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
public function setSlugify(SlugifyInterface $slugify): self |
62
|
|
|
{ |
63
|
|
|
$this->slugify = $slugify; |
64
|
|
|
|
65
|
|
|
return $this; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
public function setToolChain(ToolChain $toolChain): self |
69
|
|
|
{ |
70
|
|
|
$this->toolChain = $toolChain; |
71
|
|
|
|
72
|
|
|
return $this; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* @return ResourceNodeRepository |
77
|
|
|
*/ |
78
|
|
|
public function getResourceNodeRepository() |
79
|
|
|
{ |
80
|
|
|
return $this->resourceNodeRepository; |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
public function setResourceNodeRepository(ResourceNodeRepository $resourceNodeRepository): self |
84
|
|
|
{ |
85
|
|
|
$this->resourceNodeRepository = $resourceNodeRepository; |
86
|
|
|
|
87
|
|
|
return $this; |
88
|
|
|
} |
89
|
|
|
public function setRequestStack(RequestStack $requestStack): self |
90
|
|
|
{ |
91
|
|
|
$this->requestStack = $requestStack; |
92
|
|
|
|
93
|
|
|
return $this; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
public function getRequest(): Request |
97
|
|
|
{ |
98
|
|
|
return $this->requestStack->getCurrentRequest(); |
|
|
|
|
99
|
|
|
} |
100
|
|
|
} |
101
|
|
|
|