1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace OroCRM\Bundle\ContactBundle\Controller; |
4
|
|
|
|
5
|
|
|
use Symfony\Component\HttpFoundation\Request; |
6
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller; |
7
|
|
|
|
8
|
|
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; |
9
|
|
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; |
10
|
|
|
|
11
|
|
|
use Oro\Bundle\SecurityBundle\Annotation\Acl; |
12
|
|
|
use Oro\Bundle\SecurityBundle\Annotation\AclAncestor; |
13
|
|
|
|
14
|
|
|
use OroCRM\Bundle\ContactBundle\Entity\Group; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* @Route("/group") |
18
|
|
|
*/ |
19
|
|
|
class GroupController extends Controller |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* Create group form |
23
|
|
|
* |
24
|
|
|
* @Route("/create", name="orocrm_contact_group_create") |
25
|
|
|
* @Template("OroCRMContactBundle:Group:update.html.twig") |
26
|
|
|
* @Acl( |
27
|
|
|
* id="orocrm_contact_group_create", |
28
|
|
|
* type="entity", |
29
|
|
|
* permission="CREATE", |
30
|
|
|
* class="OroCRMContactBundle:Group" |
31
|
|
|
* ) |
32
|
|
|
*/ |
33
|
|
|
public function createAction() |
34
|
|
|
{ |
35
|
|
|
return $this->update(new Group()); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Update group form |
40
|
|
|
* |
41
|
|
|
* @Route("/update/{id}", name="orocrm_contact_group_update", requirements={"id"="\d+"}, defaults={"id"=0}) |
42
|
|
|
* @Template |
43
|
|
|
* @Acl( |
44
|
|
|
* id="orocrm_contact_group_update", |
45
|
|
|
* type="entity", |
46
|
|
|
* permission="EDIT", |
47
|
|
|
* class="OroCRMContactBundle:Group" |
48
|
|
|
* ) |
49
|
|
|
*/ |
50
|
|
|
public function updateAction(Group $entity) |
51
|
|
|
{ |
52
|
|
|
return $this->update($entity); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @Route( |
57
|
|
|
* "/{_format}", |
58
|
|
|
* name="orocrm_contact_group_index", |
59
|
|
|
* requirements={"_format"="html|json"}, |
60
|
|
|
* defaults={"_format" = "html"} |
61
|
|
|
* ) |
62
|
|
|
* @Acl( |
63
|
|
|
* id="orocrm_contact_group_view", |
64
|
|
|
* type="entity", |
65
|
|
|
* permission="VIEW", |
66
|
|
|
* class="OroCRMContactBundle:Group" |
67
|
|
|
* ) |
68
|
|
|
* @Template() |
69
|
|
|
*/ |
70
|
|
|
public function indexAction() |
71
|
|
|
{ |
72
|
|
|
return [ |
73
|
|
|
'entity_class' => $this->container->getParameter('orocrm_contact.group.entity.class') |
74
|
|
|
]; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* @param Group $entity |
79
|
|
|
* |
80
|
|
|
* @return array |
81
|
|
|
*/ |
82
|
|
|
protected function update(Group $entity) |
83
|
|
|
{ |
84
|
|
|
if ($this->get('orocrm_contact.form.handler.group')->process($entity)) { |
85
|
|
|
$this->get('session')->getFlashBag()->add( |
86
|
|
|
'success', |
87
|
|
|
$this->get('translator')->trans('orocrm.contact.controller.contact_group.saved.message') |
88
|
|
|
); |
89
|
|
|
|
90
|
|
|
if (!$this->getRequest()->get('_widgetContainer')) { |
|
|
|
|
91
|
|
|
return $this->get('oro_ui.router')->redirect($entity); |
92
|
|
|
} |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
return array( |
96
|
|
|
'entity' => $entity, |
97
|
|
|
'form' => $this->get('orocrm_contact.form.group')->createView(), |
98
|
|
|
'showContactsGrid' => count($this->get('orocrm_contact.contact.manager')->getList()) ? true : false |
99
|
|
|
); |
100
|
|
|
} |
101
|
|
|
} |
102
|
|
|
|
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.