1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace OroCRM\Bundle\CallBundle\Provider; |
4
|
|
|
|
5
|
|
|
use Oro\Bundle\ActivityBundle\Tools\ActivityAssociationHelper; |
6
|
|
|
use Oro\Bundle\ActivityListBundle\Entity\ActivityList; |
7
|
|
|
use Oro\Bundle\ActivityListBundle\Model\ActivityListProviderInterface; |
8
|
|
|
use Oro\Bundle\ActivityListBundle\Entity\ActivityOwner; |
9
|
|
|
use Oro\Bundle\CommentBundle\Model\CommentProviderInterface; |
10
|
|
|
use Oro\Bundle\CommentBundle\Tools\CommentAssociationHelper; |
11
|
|
|
use Oro\Bundle\EntityBundle\ORM\DoctrineHelper; |
12
|
|
|
use Oro\Bundle\EntityConfigBundle\DependencyInjection\Utils\ServiceLink; |
13
|
|
|
|
14
|
|
|
use OroCRM\Bundle\CallBundle\Entity\Call; |
15
|
|
|
|
16
|
|
View Code Duplication |
class CallActivityListProvider implements ActivityListProviderInterface, CommentProviderInterface |
|
|
|
|
17
|
|
|
{ |
18
|
|
|
const ACTIVITY_CLASS = 'OroCRM\Bundle\CallBundle\Entity\Call'; |
19
|
|
|
const ACL_CLASS = 'OroCRM\Bundle\CallBundle\Entity\Call'; |
20
|
|
|
|
21
|
|
|
/** @var DoctrineHelper */ |
22
|
|
|
protected $doctrineHelper; |
23
|
|
|
|
24
|
|
|
/** @var ServiceLink */ |
25
|
|
|
protected $entityOwnerAccessorLink; |
26
|
|
|
|
27
|
|
|
/** @var ActivityAssociationHelper */ |
28
|
|
|
protected $activityAssociationHelper; |
29
|
|
|
|
30
|
|
|
/** @var CommentAssociationHelper */ |
31
|
|
|
protected $commentAssociationHelper; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @param DoctrineHelper $doctrineHelper |
35
|
|
|
* @param ServiceLink $entityOwnerAccessorLink |
36
|
|
|
* @param ActivityAssociationHelper $activityAssociationHelper |
37
|
|
|
* @param CommentAssociationHelper $commentAssociationHelper |
38
|
|
|
*/ |
39
|
|
|
public function __construct( |
40
|
|
|
DoctrineHelper $doctrineHelper, |
41
|
|
|
ServiceLink $entityOwnerAccessorLink, |
42
|
|
|
ActivityAssociationHelper $activityAssociationHelper, |
43
|
|
|
CommentAssociationHelper $commentAssociationHelper |
44
|
|
|
) { |
45
|
|
|
$this->doctrineHelper = $doctrineHelper; |
46
|
|
|
$this->entityOwnerAccessorLink = $entityOwnerAccessorLink; |
47
|
|
|
$this->activityAssociationHelper = $activityAssociationHelper; |
48
|
|
|
$this->commentAssociationHelper = $commentAssociationHelper; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* {@inheritdoc} |
53
|
|
|
*/ |
54
|
|
|
public function isApplicableTarget($entityClass, $accessible = true) |
55
|
|
|
{ |
56
|
|
|
return $this->activityAssociationHelper->isActivityAssociationEnabled( |
57
|
|
|
$entityClass, |
58
|
|
|
self::ACTIVITY_CLASS, |
59
|
|
|
$accessible |
60
|
|
|
); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* {@inheritdoc} |
65
|
|
|
*/ |
66
|
|
|
public function getSubject($entity) |
67
|
|
|
{ |
68
|
|
|
/** @var $entity Call */ |
69
|
|
|
return $entity->getSubject(); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* {@inheritdoc} |
74
|
|
|
*/ |
75
|
|
|
public function getDescription($entity) |
76
|
|
|
{ |
77
|
|
|
/** @var $entity Call */ |
78
|
|
|
return $entity->getNotes(); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* {@inheritdoc} |
83
|
|
|
*/ |
84
|
|
|
public function getData(ActivityList $activityListEntity) |
85
|
|
|
{ |
86
|
|
|
return []; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* {@inheritdoc} |
91
|
|
|
*/ |
92
|
|
|
public function getOrganization($activityEntity) |
93
|
|
|
{ |
94
|
|
|
/** @var $activityEntity Call */ |
95
|
|
|
return $activityEntity->getOrganization(); |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* {@inheritdoc} |
100
|
|
|
*/ |
101
|
|
|
public function getTemplate() |
102
|
|
|
{ |
103
|
|
|
return 'OroCRMCallBundle:Call:js/activityItemTemplate.js.twig'; |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* {@inheritdoc} |
108
|
|
|
*/ |
109
|
|
|
public function getRoutes() |
110
|
|
|
{ |
111
|
|
|
return [ |
112
|
|
|
'itemView' => 'orocrm_call_widget_info', |
113
|
|
|
'itemEdit' => 'orocrm_call_update', |
114
|
|
|
'itemDelete' => 'oro_api_delete_call' |
115
|
|
|
]; |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* {@inheritdoc} |
120
|
|
|
*/ |
121
|
|
|
public function getActivityClass() |
122
|
|
|
{ |
123
|
|
|
return self::ACTIVITY_CLASS; |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
/** |
127
|
|
|
* {@inheritdoc} |
128
|
|
|
*/ |
129
|
|
|
public function getAclClass() |
130
|
|
|
{ |
131
|
|
|
return self::ACL_CLASS; |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
/** |
135
|
|
|
* {@inheritdoc} |
136
|
|
|
*/ |
137
|
|
|
public function getActivityId($entity) |
138
|
|
|
{ |
139
|
|
|
return $this->doctrineHelper->getSingleEntityIdentifier($entity); |
140
|
|
|
} |
141
|
|
|
|
142
|
|
|
/** |
143
|
|
|
* {@inheritdoc} |
144
|
|
|
*/ |
145
|
|
|
public function isApplicable($entity) |
146
|
|
|
{ |
147
|
|
|
if (is_object($entity)) { |
148
|
|
|
$entity = $this->doctrineHelper->getEntityClass($entity); |
149
|
|
|
} |
150
|
|
|
|
151
|
|
|
return $entity == self::ACTIVITY_CLASS; |
152
|
|
|
} |
153
|
|
|
|
154
|
|
|
/** |
155
|
|
|
* {@inheritdoc} |
156
|
|
|
*/ |
157
|
|
|
public function getTargetEntities($entity) |
158
|
|
|
{ |
159
|
|
|
return $entity->getActivityTargetEntities(); |
160
|
|
|
} |
161
|
|
|
|
162
|
|
|
/** |
163
|
|
|
* {@inheritdoc} |
164
|
|
|
*/ |
165
|
|
|
public function isCommentsEnabled($entityClass) |
166
|
|
|
{ |
167
|
|
|
return $this->commentAssociationHelper->isCommentAssociationEnabled($entityClass); |
168
|
|
|
} |
169
|
|
|
|
170
|
|
|
/** |
171
|
|
|
* {@inheritdoc} |
172
|
|
|
*/ |
173
|
|
|
public function getActivityOwners($entity, ActivityList $activityList) |
174
|
|
|
{ |
175
|
|
|
$organization = $this->getOrganization($entity); |
176
|
|
|
$owner = $this->entityOwnerAccessorLink->getService()->getOwner($entity); |
177
|
|
|
|
178
|
|
|
if (!$organization || !$owner) { |
179
|
|
|
return []; |
180
|
|
|
} |
181
|
|
|
|
182
|
|
|
$activityOwner = new ActivityOwner(); |
183
|
|
|
$activityOwner->setActivity($activityList); |
184
|
|
|
$activityOwner->setOrganization($organization); |
185
|
|
|
$activityOwner->setUser($owner); |
186
|
|
|
return [$activityOwner]; |
187
|
|
|
} |
188
|
|
|
} |
189
|
|
|
|