NULL, 'displayLabel' => NULL, 'id' => NULL, ]; /** * Constructor * * @param $activity_type_id int This matches up to the option_value 'value' column in the database. */ public function __construct($activity_type_id) { $this->setActivityType($activity_type_id); } /** * Get the key/value pair representing this activity type. * * @return array * @see $this->_activityType */ public function getActivityType() { return $this->_activityType; } /** * Look up the key/value pair representing this activity type from the id. * Generally called from constructor. * * @param $activity_type_id int This matches up to the option_value 'value' column in the database. */ public function setActivityType($activity_type_id) { if ($activity_type_id && is_numeric($activity_type_id)) { /* * These are pulled from CRM_Activity_Form_Activity. * To avoid unexpectedly changing things like introducing hidden * business logic or changing permission checks I've kept it using * the same function call. It may or may not be desired to have * that but this at least doesn't introduce anything that wasn't * there before. */ $machineNames = CRM_Core_OptionGroup::values('activity_type', FALSE, FALSE, FALSE, 'AND v.value = ' . $activity_type_id, 'name'); $displayLabels = CRM_Core_OptionGroup::values('activity_type', FALSE, FALSE, FALSE, 'AND v.value = ' . $activity_type_id, 'label'); $this->_activityType = [ 'machineName' => CRM_Utils_Array::value($activity_type_id, $machineNames), 'displayLabel' => CRM_Utils_Array::value($activity_type_id, $displayLabels), 'id' => $activity_type_id, ]; } } }