Author: Constant Contact
Inheritance: extends Component
Example #1
0
 /**
  * Factory method to create an Activity object from an array
  * @param array $props - associative array of initial properties to set
  * @return Campaign
  */
 public static function create(array $props)
 {
     $activity = new Activity();
     $activity->id = parent::getValue($props, "id");
     $activity->type = parent::getValue($props, "type");
     $activity->status = parent::getValue($props, "status");
     $activity->start_date = parent::getValue($props, "start_date");
     $activity->finish_date = parent::getValue($props, "finish_date");
     $activity->created_date = parent::getValue($props, "created_date");
     $activity->error_count = parent::getValue($props, "error_count");
     $activity->contact_count = parent::getValue($props, "contact_count");
     // set any errors that exist, otherewise destroy the property
     if (array_key_exists('errors', $props)) {
         foreach ($props['errors'] as $error) {
             $activity->errors[] = ActivityError::create($error);
         }
     } else {
         unset($activity->errors);
     }
     // set any warnings that exist, otherewise destroy the property
     if (array_key_exists('warnings', $props)) {
         foreach ($props['warnings'] as $error) {
             $activity->warnings[] = ActivityError::create($error);
         }
     } else {
         unset($activity->warnings);
     }
     // set the file name if exists
     if (array_key_exists('file_name', $props)) {
         $activity->file_name = $props['file_name'];
     } else {
         unset($activity->file_name);
     }
     return $activity;
 }