|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace OroCRM\Bundle\CallBundle\Controller; |
|
4
|
|
|
|
|
5
|
|
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; |
|
6
|
|
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; |
|
7
|
|
|
|
|
8
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller; |
|
9
|
|
|
use Symfony\Component\HttpFoundation\Request; |
|
10
|
|
|
|
|
11
|
|
|
use Oro\Bundle\SecurityBundle\Annotation\Acl; |
|
12
|
|
|
use Oro\Bundle\SecurityBundle\Annotation\AclAncestor; |
|
13
|
|
|
|
|
14
|
|
|
use OroCRM\Bundle\CallBundle\Entity\Call; |
|
15
|
|
|
|
|
16
|
|
|
class CallController extends Controller |
|
17
|
|
|
{ |
|
18
|
|
|
/** |
|
19
|
|
|
* This action is used to render the list of calls associated with the given entity |
|
20
|
|
|
* on the view page of this entity |
|
21
|
|
|
* |
|
22
|
|
|
* @Route("/activity/view/{entityClass}/{entityId}", name="orocrm_call_activity_view") |
|
23
|
|
|
* @AclAncestor("orocrm_call_view") |
|
24
|
|
|
* @Template |
|
25
|
|
|
*/ |
|
26
|
|
|
public function activityAction($entityClass, $entityId) |
|
27
|
|
|
{ |
|
28
|
|
|
return array( |
|
29
|
|
|
'entity' => $this->get('oro_entity.routing_helper')->getEntity($entityClass, $entityId) |
|
30
|
|
|
); |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* @Route("/create", name="orocrm_call_create") |
|
35
|
|
|
* @Template("OroCRMCallBundle:Call:update.html.twig") |
|
36
|
|
|
* @Acl( |
|
37
|
|
|
* id="orocrm_call_create", |
|
38
|
|
|
* type="entity", |
|
39
|
|
|
* permission="CREATE", |
|
40
|
|
|
* class="OroCRMCallBundle:Call" |
|
41
|
|
|
* ) |
|
42
|
|
|
*/ |
|
43
|
|
|
public function createAction() |
|
44
|
|
|
{ |
|
45
|
|
|
$entity = new Call(); |
|
46
|
|
|
|
|
47
|
|
|
$callStatus = $this->getDoctrine() |
|
|
|
|
|
|
48
|
|
|
->getRepository('OroCRMCallBundle:CallStatus') |
|
49
|
|
|
->findOneByName('completed'); |
|
50
|
|
|
$entity->setCallStatus($callStatus); |
|
51
|
|
|
|
|
52
|
|
|
$callDirection = $this->getDoctrine() |
|
|
|
|
|
|
53
|
|
|
->getRepository('OroCRMCallBundle:CallDirection') |
|
54
|
|
|
->findOneByName('outgoing'); |
|
55
|
|
|
$entity->setDirection($callDirection); |
|
56
|
|
|
|
|
57
|
|
|
$formAction = $this->get('oro_entity.routing_helper') |
|
58
|
|
|
->generateUrlByRequest('orocrm_call_create', $this->getRequest()); |
|
|
|
|
|
|
59
|
|
|
|
|
60
|
|
|
return $this->update($entity, $formAction); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* @Route("/update/{id}", name="orocrm_call_update", requirements={"id"="\d+"}) |
|
65
|
|
|
* @Template |
|
66
|
|
|
* @Acl( |
|
67
|
|
|
* id="orocrm_call_update", |
|
68
|
|
|
* type="entity", |
|
69
|
|
|
* permission="EDIT", |
|
70
|
|
|
* class="OroCRMCallBundle:Call" |
|
71
|
|
|
* ) |
|
72
|
|
|
*/ |
|
73
|
|
|
public function updateAction(Call $entity) |
|
74
|
|
|
{ |
|
75
|
|
|
$formAction = $this->get('router')->generate('orocrm_call_update', ['id' => $entity->getId()]); |
|
76
|
|
|
|
|
77
|
|
|
return $this->update($entity, $formAction); |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
/** |
|
81
|
|
|
* @Route(name="orocrm_call_index") |
|
82
|
|
|
* @Template |
|
83
|
|
|
* @Acl( |
|
84
|
|
|
* id="orocrm_call_view", |
|
85
|
|
|
* type="entity", |
|
86
|
|
|
* permission="VIEW", |
|
87
|
|
|
* class="OroCRMCallBundle:Call" |
|
88
|
|
|
* ) |
|
89
|
|
|
*/ |
|
90
|
|
|
public function indexAction() |
|
91
|
|
|
{ |
|
92
|
|
|
return array( |
|
93
|
|
|
'entity_class' => $this->container->getParameter('orocrm_call.call.entity.class') |
|
94
|
|
|
); |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
/** |
|
98
|
|
|
* @Route("/view/{id}", name="orocrm_call_view") |
|
99
|
|
|
* @Template |
|
100
|
|
|
*/ |
|
101
|
|
|
public function viewAction(Call $entity) |
|
102
|
|
|
{ |
|
103
|
|
|
return [ |
|
104
|
|
|
'entity' => $entity, |
|
105
|
|
|
]; |
|
106
|
|
|
} |
|
107
|
|
|
|
|
108
|
|
|
/** |
|
109
|
|
|
* @Route("/widget", name="orocrm_call_widget_calls") |
|
110
|
|
|
* @Template |
|
111
|
|
|
* @AclAncestor("orocrm_call_view") |
|
112
|
|
|
* |
|
113
|
|
|
* @param Request $request |
|
114
|
|
|
* @return array |
|
115
|
|
|
*/ |
|
116
|
|
|
public function callsAction(Request $request) |
|
117
|
|
|
{ |
|
118
|
|
|
return array( |
|
119
|
|
|
'datagridParameters' => $request->query->all() |
|
120
|
|
|
); |
|
121
|
|
|
} |
|
122
|
|
|
|
|
123
|
|
|
/** |
|
124
|
|
|
* @Route("/base-widget", name="orocrm_call_base_widget_calls") |
|
125
|
|
|
* @Template |
|
126
|
|
|
* @AclAncestor("orocrm_call_view") |
|
127
|
|
|
*/ |
|
128
|
|
|
public function baseCallsAction(Request $request) |
|
129
|
|
|
{ |
|
130
|
|
|
return array( |
|
131
|
|
|
'datagridParameters' => $request->query->all() |
|
132
|
|
|
); |
|
133
|
|
|
} |
|
134
|
|
|
|
|
135
|
|
|
/** |
|
136
|
|
|
* @Route( |
|
137
|
|
|
* "/widget/info/{id}/{renderContexts}", |
|
138
|
|
|
* name="orocrm_call_widget_info", |
|
139
|
|
|
* requirements={"id"="\d+", "renderContexts"="\d+"}, |
|
140
|
|
|
* defaults={"renderContexts"=true} |
|
141
|
|
|
* ) |
|
142
|
|
|
* @Template("OroCRMCallBundle:Call/widget:info.html.twig") |
|
143
|
|
|
* @AclAncestor("orocrm_call_view") |
|
144
|
|
|
*/ |
|
145
|
|
|
public function infoAction(Call $entity, $renderContexts) |
|
146
|
|
|
{ |
|
147
|
|
|
return [ |
|
148
|
|
|
'entity' => $entity, |
|
149
|
|
|
'target' => $this->getTargetEntity(), |
|
150
|
|
|
'renderContexts' => (bool)$renderContexts |
|
151
|
|
|
]; |
|
152
|
|
|
} |
|
153
|
|
|
|
|
154
|
|
|
/** |
|
155
|
|
|
* @param Call $entity |
|
156
|
|
|
* @param string $formAction |
|
157
|
|
|
* |
|
158
|
|
|
* @return array |
|
159
|
|
|
*/ |
|
160
|
|
View Code Duplication |
protected function update(Call $entity, $formAction) |
|
|
|
|
|
|
161
|
|
|
{ |
|
162
|
|
|
$saved = false; |
|
163
|
|
|
|
|
164
|
|
|
if ($this->get('orocrm_call.call.form.handler')->process($entity)) { |
|
165
|
|
|
if (!$this->getRequest()->get('_widgetContainer')) { |
|
|
|
|
|
|
166
|
|
|
$this->get('session')->getFlashBag()->add( |
|
167
|
|
|
'success', |
|
168
|
|
|
$this->get('translator')->trans('orocrm.call.controller.call.saved.message') |
|
169
|
|
|
); |
|
170
|
|
|
|
|
171
|
|
|
return $this->get('oro_ui.router')->redirect($entity); |
|
172
|
|
|
} |
|
173
|
|
|
$saved = true; |
|
174
|
|
|
} |
|
175
|
|
|
|
|
176
|
|
|
return array( |
|
177
|
|
|
'entity' => $entity, |
|
178
|
|
|
'saved' => $saved, |
|
179
|
|
|
'form' => $this->get('orocrm_call.call.form.handler')->getForm()->createView(), |
|
180
|
|
|
'formAction' => $formAction |
|
181
|
|
|
); |
|
182
|
|
|
} |
|
183
|
|
|
|
|
184
|
|
|
/** |
|
185
|
|
|
* Get target entity |
|
186
|
|
|
* |
|
187
|
|
|
* @return object|null |
|
188
|
|
|
*/ |
|
189
|
|
View Code Duplication |
protected function getTargetEntity() |
|
|
|
|
|
|
190
|
|
|
{ |
|
191
|
|
|
$entityRoutingHelper = $this->get('oro_entity.routing_helper'); |
|
192
|
|
|
$targetEntityClass = $entityRoutingHelper->getEntityClassName($this->getRequest(), 'targetActivityClass'); |
|
|
|
|
|
|
193
|
|
|
$targetEntityId = $entityRoutingHelper->getEntityId($this->getRequest(), 'targetActivityId'); |
|
|
|
|
|
|
194
|
|
|
if (!$targetEntityClass || !$targetEntityId) { |
|
195
|
|
|
return null; |
|
196
|
|
|
} |
|
197
|
|
|
|
|
198
|
|
|
return $entityRoutingHelper->getEntity($targetEntityClass, $targetEntityId); |
|
199
|
|
|
} |
|
200
|
|
|
} |
|
201
|
|
|
|
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.