| @@ 17-219 (lines=203) @@ | ||
| 14 | ||
| 15 | use OroCRM\Bundle\CallBundle\Entity\Call; |
|
| 16 | ||
| 17 | class CallActivityListProvider implements |
|
| 18 | ActivityListProviderInterface, |
|
| 19 | CommentProviderInterface, |
|
| 20 | ActivityListDateProviderInterface |
|
| 21 | { |
|
| 22 | const ACTIVITY_CLASS = 'OroCRM\Bundle\CallBundle\Entity\Call'; |
|
| 23 | const ACL_CLASS = 'OroCRM\Bundle\CallBundle\Entity\Call'; |
|
| 24 | ||
| 25 | /** @var DoctrineHelper */ |
|
| 26 | protected $doctrineHelper; |
|
| 27 | ||
| 28 | /** @var ServiceLink */ |
|
| 29 | protected $entityOwnerAccessorLink; |
|
| 30 | ||
| 31 | /** @var ActivityAssociationHelper */ |
|
| 32 | protected $activityAssociationHelper; |
|
| 33 | ||
| 34 | /** @var CommentAssociationHelper */ |
|
| 35 | protected $commentAssociationHelper; |
|
| 36 | ||
| 37 | /** |
|
| 38 | * @param DoctrineHelper $doctrineHelper |
|
| 39 | * @param ServiceLink $entityOwnerAccessorLink |
|
| 40 | * @param ActivityAssociationHelper $activityAssociationHelper |
|
| 41 | * @param CommentAssociationHelper $commentAssociationHelper |
|
| 42 | */ |
|
| 43 | public function __construct( |
|
| 44 | DoctrineHelper $doctrineHelper, |
|
| 45 | ServiceLink $entityOwnerAccessorLink, |
|
| 46 | ActivityAssociationHelper $activityAssociationHelper, |
|
| 47 | CommentAssociationHelper $commentAssociationHelper |
|
| 48 | ) { |
|
| 49 | $this->doctrineHelper = $doctrineHelper; |
|
| 50 | $this->entityOwnerAccessorLink = $entityOwnerAccessorLink; |
|
| 51 | $this->activityAssociationHelper = $activityAssociationHelper; |
|
| 52 | $this->commentAssociationHelper = $commentAssociationHelper; |
|
| 53 | } |
|
| 54 | ||
| 55 | /** |
|
| 56 | * {@inheritdoc} |
|
| 57 | */ |
|
| 58 | public function isApplicableTarget($entityClass, $accessible = true) |
|
| 59 | { |
|
| 60 | return $this->activityAssociationHelper->isActivityAssociationEnabled( |
|
| 61 | $entityClass, |
|
| 62 | self::ACTIVITY_CLASS, |
|
| 63 | $accessible |
|
| 64 | ); |
|
| 65 | } |
|
| 66 | ||
| 67 | /** |
|
| 68 | * {@inheritdoc} |
|
| 69 | */ |
|
| 70 | public function getSubject($entity) |
|
| 71 | { |
|
| 72 | /** @var $entity Call */ |
|
| 73 | return $entity->getSubject(); |
|
| 74 | } |
|
| 75 | ||
| 76 | /** |
|
| 77 | * {@inheritdoc} |
|
| 78 | */ |
|
| 79 | public function getDescription($entity) |
|
| 80 | { |
|
| 81 | /** @var $entity Call */ |
|
| 82 | return $entity->getNotes(); |
|
| 83 | } |
|
| 84 | ||
| 85 | /** |
|
| 86 | * {@inheritdoc} |
|
| 87 | */ |
|
| 88 | public function getOwner($entity) |
|
| 89 | { |
|
| 90 | /** @var $entity Call */ |
|
| 91 | return $entity->getOwner(); |
|
| 92 | } |
|
| 93 | ||
| 94 | /** |
|
| 95 | * {@inheritdoc} |
|
| 96 | */ |
|
| 97 | public function getCreatedAt($entity) |
|
| 98 | { |
|
| 99 | /** @var $entity Call */ |
|
| 100 | return $entity->getCreatedAt(); |
|
| 101 | } |
|
| 102 | ||
| 103 | /** |
|
| 104 | * {@inheritdoc} |
|
| 105 | */ |
|
| 106 | public function getUpdatedAt($entity) |
|
| 107 | { |
|
| 108 | /** @var $entity Call */ |
|
| 109 | return $entity->getUpdatedAt(); |
|
| 110 | } |
|
| 111 | ||
| 112 | /** |
|
| 113 | * {@inheritdoc} |
|
| 114 | */ |
|
| 115 | public function getData(ActivityList $activityListEntity) |
|
| 116 | { |
|
| 117 | return []; |
|
| 118 | } |
|
| 119 | ||
| 120 | /** |
|
| 121 | * {@inheritdoc} |
|
| 122 | */ |
|
| 123 | public function getOrganization($activityEntity) |
|
| 124 | { |
|
| 125 | /** @var $activityEntity Call */ |
|
| 126 | return $activityEntity->getOrganization(); |
|
| 127 | } |
|
| 128 | ||
| 129 | /** |
|
| 130 | * {@inheritdoc} |
|
| 131 | */ |
|
| 132 | public function getTemplate() |
|
| 133 | { |
|
| 134 | return 'OroCRMCallBundle:Call:js/activityItemTemplate.js.twig'; |
|
| 135 | } |
|
| 136 | ||
| 137 | /** |
|
| 138 | * {@inheritdoc} |
|
| 139 | */ |
|
| 140 | public function getRoutes() |
|
| 141 | { |
|
| 142 | return [ |
|
| 143 | 'itemView' => 'orocrm_call_widget_info', |
|
| 144 | 'itemEdit' => 'orocrm_call_update', |
|
| 145 | 'itemDelete' => 'oro_api_delete_call' |
|
| 146 | ]; |
|
| 147 | } |
|
| 148 | ||
| 149 | /** |
|
| 150 | * {@inheritdoc} |
|
| 151 | */ |
|
| 152 | public function getActivityClass() |
|
| 153 | { |
|
| 154 | return self::ACTIVITY_CLASS; |
|
| 155 | } |
|
| 156 | ||
| 157 | /** |
|
| 158 | * {@inheritdoc} |
|
| 159 | */ |
|
| 160 | public function getAclClass() |
|
| 161 | { |
|
| 162 | return self::ACL_CLASS; |
|
| 163 | } |
|
| 164 | ||
| 165 | /** |
|
| 166 | * {@inheritdoc} |
|
| 167 | */ |
|
| 168 | public function getActivityId($entity) |
|
| 169 | { |
|
| 170 | return $this->doctrineHelper->getSingleEntityIdentifier($entity); |
|
| 171 | } |
|
| 172 | ||
| 173 | /** |
|
| 174 | * {@inheritdoc} |
|
| 175 | */ |
|
| 176 | public function isApplicable($entity) |
|
| 177 | { |
|
| 178 | if (is_object($entity)) { |
|
| 179 | $entity = $this->doctrineHelper->getEntityClass($entity); |
|
| 180 | } |
|
| 181 | ||
| 182 | return $entity == self::ACTIVITY_CLASS; |
|
| 183 | } |
|
| 184 | ||
| 185 | /** |
|
| 186 | * {@inheritdoc} |
|
| 187 | */ |
|
| 188 | public function getTargetEntities($entity) |
|
| 189 | { |
|
| 190 | return $entity->getActivityTargetEntities(); |
|
| 191 | } |
|
| 192 | ||
| 193 | /** |
|
| 194 | * {@inheritdoc} |
|
| 195 | */ |
|
| 196 | public function isCommentsEnabled($entityClass) |
|
| 197 | { |
|
| 198 | return $this->commentAssociationHelper->isCommentAssociationEnabled($entityClass); |
|
| 199 | } |
|
| 200 | ||
| 201 | /** |
|
| 202 | * {@inheritdoc} |
|
| 203 | */ |
|
| 204 | public function getActivityOwners($entity, ActivityList $activityList) |
|
| 205 | { |
|
| 206 | $organization = $this->getOrganization($entity); |
|
| 207 | $owner = $this->entityOwnerAccessorLink->getService()->getOwner($entity); |
|
| 208 | ||
| 209 | if (!$organization || !$owner) { |
|
| 210 | return []; |
|
| 211 | } |
|
| 212 | ||
| 213 | $activityOwner = new ActivityOwner(); |
|
| 214 | $activityOwner->setActivity($activityList); |
|
| 215 | $activityOwner->setOrganization($organization); |
|
| 216 | $activityOwner->setUser($owner); |
|
| 217 | return [$activityOwner]; |
|
| 218 | } |
|
| 219 | } |
|
| 220 | ||
| @@ 17-219 (lines=203) @@ | ||
| 14 | ||
| 15 | use OroCRM\Bundle\TaskBundle\Entity\Task; |
|
| 16 | ||
| 17 | class TaskActivityListProvider implements |
|
| 18 | ActivityListProviderInterface, |
|
| 19 | CommentProviderInterface, |
|
| 20 | ActivityListDateProviderInterface |
|
| 21 | { |
|
| 22 | const ACTIVITY_CLASS = 'OroCRM\Bundle\TaskBundle\Entity\Task'; |
|
| 23 | const ACL_CLASS = 'OroCRM\Bundle\TaskBundle\Entity\Task'; |
|
| 24 | ||
| 25 | /** @var DoctrineHelper */ |
|
| 26 | protected $doctrineHelper; |
|
| 27 | ||
| 28 | /** @var ServiceLink */ |
|
| 29 | protected $entityOwnerAccessorLink; |
|
| 30 | ||
| 31 | /** @var ActivityAssociationHelper */ |
|
| 32 | protected $activityAssociationHelper; |
|
| 33 | ||
| 34 | /** @var CommentAssociationHelper */ |
|
| 35 | protected $commentAssociationHelper; |
|
| 36 | ||
| 37 | /** |
|
| 38 | * @param DoctrineHelper $doctrineHelper |
|
| 39 | * @param ServiceLink $entityOwnerAccessorLink |
|
| 40 | * @param ActivityAssociationHelper $activityAssociationHelper |
|
| 41 | * @param CommentAssociationHelper $commentAssociationHelper |
|
| 42 | */ |
|
| 43 | public function __construct( |
|
| 44 | DoctrineHelper $doctrineHelper, |
|
| 45 | ServiceLink $entityOwnerAccessorLink, |
|
| 46 | ActivityAssociationHelper $activityAssociationHelper, |
|
| 47 | CommentAssociationHelper $commentAssociationHelper |
|
| 48 | ) { |
|
| 49 | $this->doctrineHelper = $doctrineHelper; |
|
| 50 | $this->entityOwnerAccessorLink = $entityOwnerAccessorLink; |
|
| 51 | $this->activityAssociationHelper = $activityAssociationHelper; |
|
| 52 | $this->commentAssociationHelper = $commentAssociationHelper; |
|
| 53 | } |
|
| 54 | ||
| 55 | /** |
|
| 56 | * {@inheritdoc} |
|
| 57 | */ |
|
| 58 | public function isApplicableTarget($entityClass, $accessible = true) |
|
| 59 | { |
|
| 60 | return $this->activityAssociationHelper->isActivityAssociationEnabled( |
|
| 61 | $entityClass, |
|
| 62 | self::ACTIVITY_CLASS, |
|
| 63 | $accessible |
|
| 64 | ); |
|
| 65 | } |
|
| 66 | ||
| 67 | /** |
|
| 68 | * {@inheritdoc} |
|
| 69 | */ |
|
| 70 | public function getSubject($entity) |
|
| 71 | { |
|
| 72 | /** @var $entity Task */ |
|
| 73 | return $entity->getSubject(); |
|
| 74 | } |
|
| 75 | ||
| 76 | /** |
|
| 77 | * {@inheritdoc} |
|
| 78 | */ |
|
| 79 | public function getDescription($entity) |
|
| 80 | { |
|
| 81 | /** @var $entity Task */ |
|
| 82 | return $entity->getDescription(); |
|
| 83 | } |
|
| 84 | ||
| 85 | /** |
|
| 86 | * {@inheritdoc} |
|
| 87 | */ |
|
| 88 | public function getOwner($entity) |
|
| 89 | { |
|
| 90 | /** @var $entity Task */ |
|
| 91 | return $entity->getOwner(); |
|
| 92 | } |
|
| 93 | ||
| 94 | /** |
|
| 95 | * {@inheritdoc} |
|
| 96 | */ |
|
| 97 | public function getCreatedAt($entity) |
|
| 98 | { |
|
| 99 | /** @var $entity Task */ |
|
| 100 | return $entity->getCreatedAt(); |
|
| 101 | } |
|
| 102 | ||
| 103 | /** |
|
| 104 | * {@inheritdoc} |
|
| 105 | */ |
|
| 106 | public function getUpdatedAt($entity) |
|
| 107 | { |
|
| 108 | /** @var $entity Task */ |
|
| 109 | return $entity->getUpdatedAt(); |
|
| 110 | } |
|
| 111 | ||
| 112 | /** |
|
| 113 | * {@inheritdoc} |
|
| 114 | */ |
|
| 115 | public function getData(ActivityList $activityListEntity) |
|
| 116 | { |
|
| 117 | return []; |
|
| 118 | } |
|
| 119 | ||
| 120 | /** |
|
| 121 | * {@inheritdoc} |
|
| 122 | */ |
|
| 123 | public function getOrganization($activityEntity) |
|
| 124 | { |
|
| 125 | /** @var $activityEntity Task */ |
|
| 126 | return $activityEntity->getOrganization(); |
|
| 127 | } |
|
| 128 | ||
| 129 | /** |
|
| 130 | * {@inheritdoc |
|
| 131 | */ |
|
| 132 | public function getTemplate() |
|
| 133 | { |
|
| 134 | return 'OroCRMTaskBundle:Task:js/activityItemTemplate.js.twig'; |
|
| 135 | } |
|
| 136 | ||
| 137 | /** |
|
| 138 | * {@inheritdoc} |
|
| 139 | */ |
|
| 140 | public function getRoutes() |
|
| 141 | { |
|
| 142 | return [ |
|
| 143 | 'itemView' => 'orocrm_task_widget_info', |
|
| 144 | 'itemEdit' => 'orocrm_task_update', |
|
| 145 | 'itemDelete' => 'orocrm_api_delete_task' |
|
| 146 | ]; |
|
| 147 | } |
|
| 148 | ||
| 149 | /** |
|
| 150 | * {@inheritdoc} |
|
| 151 | */ |
|
| 152 | public function getActivityClass() |
|
| 153 | { |
|
| 154 | return self::ACTIVITY_CLASS; |
|
| 155 | } |
|
| 156 | ||
| 157 | /** |
|
| 158 | * {@inheritdoc} |
|
| 159 | */ |
|
| 160 | public function getAclClass() |
|
| 161 | { |
|
| 162 | return self::ACL_CLASS; |
|
| 163 | } |
|
| 164 | ||
| 165 | /** |
|
| 166 | * {@inheritdoc} |
|
| 167 | */ |
|
| 168 | public function getActivityId($entity) |
|
| 169 | { |
|
| 170 | return $this->doctrineHelper->getSingleEntityIdentifier($entity); |
|
| 171 | } |
|
| 172 | ||
| 173 | /** |
|
| 174 | * {@inheritdoc} |
|
| 175 | */ |
|
| 176 | public function isApplicable($entity) |
|
| 177 | { |
|
| 178 | if (is_object($entity)) { |
|
| 179 | $entity = $this->doctrineHelper->getEntityClass($entity); |
|
| 180 | } |
|
| 181 | ||
| 182 | return $entity == self::ACTIVITY_CLASS; |
|
| 183 | } |
|
| 184 | ||
| 185 | /** |
|
| 186 | * {@inheritdoc} |
|
| 187 | */ |
|
| 188 | public function getTargetEntities($entity) |
|
| 189 | { |
|
| 190 | return $entity->getActivityTargetEntities(); |
|
| 191 | } |
|
| 192 | ||
| 193 | /** |
|
| 194 | * {@inheritdoc} |
|
| 195 | */ |
|
| 196 | public function isCommentsEnabled($entityClass) |
|
| 197 | { |
|
| 198 | return $this->commentAssociationHelper->isCommentAssociationEnabled($entityClass); |
|
| 199 | } |
|
| 200 | ||
| 201 | /** |
|
| 202 | * {@inheritdoc} |
|
| 203 | */ |
|
| 204 | public function getActivityOwners($entity, ActivityList $activityList) |
|
| 205 | { |
|
| 206 | $organization = $this->getOrganization($entity); |
|
| 207 | $owner = $this->entityOwnerAccessorLink->getService()->getOwner($entity); |
|
| 208 | ||
| 209 | if (!$organization || !$owner) { |
|
| 210 | return []; |
|
| 211 | } |
|
| 212 | ||
| 213 | $activityOwner = new ActivityOwner(); |
|
| 214 | $activityOwner->setActivity($activityList); |
|
| 215 | $activityOwner->setOrganization($organization); |
|
| 216 | $activityOwner->setUser($owner); |
|
| 217 | return [$activityOwner]; |
|
| 218 | } |
|
| 219 | } |
|
| 220 | ||