/** * Associates the given target entity with the activity entity * If the target entity has no association with the given activity entity it will be skipped * * @param ActivityInterface $activityEntity * @param object $targetEntity * * @return bool TRUE if an association was added; otherwise, FALSE */ public function addActivityTarget(ActivityInterface $activityEntity, $targetEntity) { if ($targetEntity !== null && $activityEntity->supportActivityTarget(get_class($targetEntity)) && !$activityEntity->hasActivityTarget($targetEntity)) { $activityEntity->addActivityTarget($targetEntity); return true; } return false; }
/** * Associates the given target entity with the activity entity * If the target entity has no association with the given activity entity it will be skipped * * @param ActivityInterface $activityEntity * @param object $targetEntity * * @return bool TRUE if an association was added; otherwise, FALSE */ public function addActivityTarget(ActivityInterface $activityEntity, $targetEntity) { if ($targetEntity !== null && $activityEntity->supportActivityTarget(get_class($targetEntity)) && !$activityEntity->hasActivityTarget($targetEntity)) { $activityEntity->addActivityTarget($targetEntity); if ($this->eventDispatcher) { $event = new ActivityEvent($activityEntity, $targetEntity); $this->eventDispatcher->dispatch(Events::ADD_ACTIVITY, $event); } return true; } return false; }