This repository has been archived by the owner on Sep 23, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 49
/
Controller.php
116 lines (93 loc) · 3.2 KB
/
Controller.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<?php
namespace Knp\RadBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller as BaseController;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
use Doctrine\ORM\EntityRepository;
use Knp\RadBundle\Flash;
class Controller extends BaseController
{
protected function redirectToRoute($route, array $parameters = array(), $status = 302)
{
return $this->getHelper('response')->redirectToRoute($route, $parameters, $status);
}
protected function getRepository($object)
{
return $this->getHelper('doctrine')->getRepository($object);
}
protected function isGranted($attributes, $object = null)
{
return $this->getHelper('security')->isGranted($attributes, $object);
}
protected function isGrantedOr403($object, $criteria = array())
{
return $this->getHelper('security')->isGrantedOr403($object, $criteria);
}
protected function createMessage($name, array $parameters = array(), $from = null, $to = null)
{
return $this->getHelper('mail')->createMessage(get_class($this), $name, $parameters, $from, $to);
}
protected function send(\Swift_Mime_Message $message)
{
$this->getHelper('mail')->send($message);
}
protected function persist($object, $flush = false)
{
return $this->getHelper('doctrine')->persist($object, $flush);
}
protected function remove($object, $flush = false)
{
return $this->getHelper('doctrine')->remove($object, $flush);
}
protected function flush($object = null)
{
return $this->getHelper('doctrine')->flush($object);
}
protected function findBy($object, $criteria = array())
{
return $this->getHelper('doctrine')->findBy($object, $criteria);
}
protected function findOr404($object, $criteria = array())
{
return $this->getHelper('doctrine')->findOr404($object, $criteria);
}
protected function addFlash($type, $message = null, array $parameters = array(), $pluralization = null)
{
return $this->getHelper('session')->addFlash($type, $message, $parameters, $pluralization);
}
protected function createObjectForm($object, $purpose = null, array $options = array())
{
return $this->getHelper('form')->createObjectForm($object, $purpose, $options);
}
protected function createBoundObjectForm($object, $purpose = null, array $options = array())
{
return $this->getHelper('form')->createBoundObjectForm($object, $purpose, $options);
}
protected function getHelper($name)
{
return $this->get('knp_rad.controller.helper.'.$name);
}
protected function getSession()
{
return $this->get('session');
}
protected function getMailer()
{
return $this->get('mailer');
}
protected function getSecurity()
{
return $this->get('security.context');
}
protected function getManager()
{
return $this->getDoctrine()->getManager();
}
protected function getFlashBag()
{
return $this->getSession()->getFlashBag();
}
protected function getParameter($name)
{
return $this->container->getParameter($name);
}
}