protected function buildActivities(array $data) {
    $activities = [];
    $message = Message::load($data['mid']);
    // Initialize fields for new activity entity.
    $activity_fields = [
      'created' => $this->getCreated($message),
      'field_activity_destinations' => $this->getFieldDestinations($data),
      'field_activity_entity' => $this->getFieldEntity($data),
      'field_activity_message' => $this->getFieldMessage($data),
      'field_activity_output_text' => $this->getFieldOutputText($message),
      'field_activity_recipient_group' => $this->getFieldRecipientGroup($data),
      'field_activity_recipient_user' => $this->getFieldRecipientUser($data),
      // Default activity status.
      'field_activity_status' => ACTIVITY_STATUS_RECEIVED,
      'user_id' => $this->getActor($data),
    ];

    // Check if aggregation is enabled for this message type.
    // @TODO: Consider if we should put aggregation to separate service.
    if ($this->getAggregationSettings($message)) {
      $activities = $this->buildAggregatedActivites($data, $activity_fields);
    }
    else {
      $activity = Activity::create($activity_fields);
      $activity->save();
      $activities[] = $activity;
    }

    return $activities;
  }
protected function buildActivities(array $data) {
    $activities = [];
    $message = Message::load($data['mid']);
    // Initialize fields for new activity entity.
    $activity_fields = [
      'created' => $this->getCreated($message),
      'field_activity_destinations' => $this->getFieldDestinations($data),
      'field_activity_entity' => $this->getFieldEntity($data),
      'field_activity_message' => $this->getFieldMessage($data),
      'field_activity_output_text' => $this->getFieldOutputText($message),
      'field_activity_recipient_group' => $this->getFieldRecipientGroup($data),
      'field_activity_recipient_user' => $this->getFieldRecipientUser($data),
      // Default activity status.
      'field_activity_status' => ACTIVITY_STATUS_RECEIVED,
      'user_id' => $this->getActor($data),
    ];

    // Check if aggregation is enabled for this message type.
    // @TODO: Consider if we should put aggregation to separate service.
    if ($this->getAggregationSettings($message)) {
      $activities = $this->buildAggregatedActivites($data, $activity_fields);
    }
    else {
      $activity = Activity::create($activity_fields);
      $activity->save();
      $activities[] = $activity;
    }

    return $activities;
  }
protected function buildActivities ( array $ data ) { $ activities = [ ] ; $ message = Message :: load ( $ data [ 'mid' ] ) ; // Initialize fields for new activity entity. $ activity_fields = [ 'created' => $ this -> getCreated ( $ message ) , 'field_activity_destinations' => $ this -> getFieldDestinations ( $ data ) , 'field_activity_entity' => $ this -> getFieldEntity ( $ data ) , 'field_activity_message' => $ this -> getFieldMessage ( $ data ) , 'field_activity_output_text' => $ this -> getFieldOutputText ( $ message ) , 'field_activity_recipient_group' => $ this -> getFieldRecipientGroup ( $ data ) , 'field_activity_recipient_user' => $ this -> getFieldRecipientUser ( $ data ) , // Default activity status. 'field_activity_status' => ACTIVITY_STATUS_RECEIVED , 'user_id' => $ this -> getActor ( $ data ) , ] ; // Check if aggregation is enabled for this message type. // @TODO: Consider if we should put aggregation to separate service. if ( $ this -> getAggregationSettings ( $ message ) ) { $ activities = $ this -> buildAggregatedActivites ( $ data , $ activity_fields ) ; } else { $ activity = Activity :: create ( $ activity_fields ) ; $ activity -> save ( ) ; $ activities [ ] = $ activity ; } return $ activities ; }
Build the activities based on a data array.

@param array $data
An array of data to create activity from.

@return array
An array of created activities.
Build the activities based on a data array .