1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace OroCRM\Bundle\MarketingListBundle\Controller; |
4
|
|
|
|
5
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller; |
6
|
|
|
|
7
|
|
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; |
8
|
|
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; |
9
|
|
|
|
10
|
|
|
use Oro\Bundle\SecurityBundle\Annotation\Acl; |
11
|
|
|
use Oro\Bundle\SecurityBundle\Annotation\AclAncestor; |
12
|
|
|
use OroCRM\Bundle\MarketingListBundle\Entity\MarketingList; |
13
|
|
|
use OroCRM\Bundle\MarketingListBundle\Datagrid\ConfigurationProvider; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* @Route("/marketing-list") |
17
|
|
|
*/ |
18
|
|
|
class MarketingListController extends Controller |
19
|
|
|
{ |
20
|
|
|
/** |
21
|
|
|
* @Route("/", name="orocrm_marketing_list_index") |
22
|
|
|
* @AclAncestor("orocrm_marketing_list_view") |
23
|
|
|
* @Template |
24
|
|
|
*/ |
25
|
|
|
public function indexAction() |
26
|
|
|
{ |
27
|
|
|
return [ |
28
|
|
|
'entity_class' => $this->container->getParameter('orocrm_marketing_list.entity.class') |
29
|
|
|
]; |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @Route("/view/{id}", name="orocrm_marketing_list_view", requirements={"id"="\d+"}, defaults={"id"=0}) |
34
|
|
|
* @Acl( |
35
|
|
|
* id="orocrm_marketing_list_view", |
36
|
|
|
* type="entity", |
37
|
|
|
* permission="VIEW", |
38
|
|
|
* class="OroCRMMarketingListBundle:MarketingList" |
39
|
|
|
* ) |
40
|
|
|
* @Template |
41
|
|
|
* |
42
|
|
|
* @param MarketingList $entity |
43
|
|
|
* |
44
|
|
|
* @return array |
45
|
|
|
*/ |
46
|
|
|
public function viewAction(MarketingList $entity) |
47
|
|
|
{ |
48
|
|
|
$entityConfig = $this->get('orocrm_marketing_list.entity_provider')->getEntity($entity->getEntity()); |
49
|
|
|
|
50
|
|
|
return [ |
51
|
|
|
'entity' => $entity, |
52
|
|
|
'config' => $entityConfig, |
53
|
|
|
'gridName' => ConfigurationProvider::GRID_PREFIX . $entity->getId() |
54
|
|
|
]; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @Route("/create", name="orocrm_marketing_list_create") |
59
|
|
|
* @Template("OroCRMMarketingListBundle:MarketingList:update.html.twig") |
60
|
|
|
* @Acl( |
61
|
|
|
* id="orocrm_marketing_list_create", |
62
|
|
|
* type="entity", |
63
|
|
|
* permission="CREATE", |
64
|
|
|
* class="OroCRMMarketingListBundle:MarketingList" |
65
|
|
|
* ) |
66
|
|
|
*/ |
67
|
|
|
public function createAction() |
68
|
|
|
{ |
69
|
|
|
return $this->update(new MarketingList()); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @Route("/update/{id}", name="orocrm_marketing_list_update", requirements={"id"="\d+"}, defaults={"id"=0}) |
74
|
|
|
* |
75
|
|
|
* @Template |
76
|
|
|
* @Acl( |
77
|
|
|
* id="orocrm_marketing_list_update", |
78
|
|
|
* type="entity", |
79
|
|
|
* permission="EDIT", |
80
|
|
|
* class="OroCRMMarketingListBundle:MarketingList" |
81
|
|
|
* ) |
82
|
|
|
* |
83
|
|
|
* @param MarketingList $entity |
84
|
|
|
* |
85
|
|
|
* @return array |
86
|
|
|
*/ |
87
|
|
|
public function updateAction(MarketingList $entity) |
88
|
|
|
{ |
89
|
|
|
return $this->update($entity); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* @param MarketingList $entity |
94
|
|
|
* |
95
|
|
|
* @return array |
96
|
|
|
*/ |
97
|
|
|
protected function update(MarketingList $entity) |
98
|
|
|
{ |
99
|
|
|
$response = $this->get('oro_form.model.update_handler')->update( |
100
|
|
|
$entity, |
101
|
|
|
$this->get('orocrm_marketing_list.form.marketing_list'), |
102
|
|
|
$this->get('translator')->trans('orocrm.marketinglist.entity.saved'), |
103
|
|
|
$this->get('orocrm_marketing_list.form.handler.marketing_list') |
104
|
|
|
); |
105
|
|
|
|
106
|
|
|
if (is_array($response)) { |
107
|
|
|
return array_merge( |
108
|
|
|
$response, |
109
|
|
|
[ |
110
|
|
|
'entities' => $this->get('oro_entity.entity_provider')->getEntities(), |
111
|
|
|
'metadata' => $this->get('oro_query_designer.query_designer.manager')->getMetadata('segment') |
112
|
|
|
] |
113
|
|
|
); |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
return $response; |
117
|
|
|
} |
118
|
|
|
} |
119
|
|
|
|