private function enrichData() {
    $data = $this->rawData;

    foreach ($data as &$item) {
      // Get address_1.
      $item->address_1 = sprintf('%s with %s', trim($item->studio), trim($item->instructor));

      // Get day.
      $item->day = $item->date;

      // Get start and end time. Add To Calendar does not support All Day events.
      if ($item->time == "All Day") {
        $item->start = "12:00am";
        $item->end = "11:59pm";
      } else {
        preg_match("/(.*)-(.*)/i", $item->time, $output);
        $item->start = $output[1];
        $item->end = $output[2];
      }

      // Get time of day.
      $datetime = new \DateTime($item->start);
      $start_hour = $datetime->format('G');
      $item->time_of_day = 'morning';
      $item->time_of_day = ($start_hour >= self::$timeAfternoon) ? "afternoon" : $item->time_of_day;
      $item->time_of_day = ($start_hour >= self::$timeEvening) ? "evening" : $item->time_of_day;

      // Add timestamp.
      $format = 'l, F j, Y';
      $datetime = DrupalDateTime::createFromFormat($format, $item->date, $this->timezone);
      $datetime->setTime(0, 0, 0);
      $item->timestamp = $datetime->getTimestamp();

      // Add calendar data.
      $date_start = DrupalDateTime::createFromFormat('l, F j, Y g:ia', $item->date . ' ' . $item->start);
      $date_end = DrupalDateTime::createFromFormat('l, F j, Y g:ia', $item->date . ' ' . $item->end);
      $date_start = $date_start->format('Y-m-d H:i:s');
      $date_end = $date_end->format('Y-m-d H:i:s');
      $item->calendar = [
        'atc_date_start' => $date_start,
        'atc_date_end' => $date_end,
        'atc_timezone' => drupal_get_user_timezone(),
        'atc_title' => $item->title,
        'atc_description' => 'Visit ' . $item->category . ' with ' . strip_tags($item->instructor) . PHP_EOL . 'Class will take place at ' . $item->studio . '.',
        'atc_location' => $item->location,
        'atc_organizer' => $item->instructor,
      ];
    }

    $this->enrichedData = $data;
  }
private function enrichData() {
    $data = $this->rawData;

    foreach ($data as &$item) {
      // Get address_1.
      $item->address_1 = sprintf('%s with %s', trim($item->studio), trim($item->instructor));

      // Get day.
      $item->day = $item->date;

      // Get start and end time. Add To Calendar does not support All Day events.
      if ($item->time == "All Day") {
        $item->start = "12:00am";
        $item->end = "11:59pm";
      } else {
        preg_match("/(.*)-(.*)/i", $item->time, $output);
        $item->start = $output[1];
        $item->end = $output[2];
      }

      // Get time of day.
      $datetime = new \DateTime($item->start);
      $start_hour = $datetime->format('G');
      $item->time_of_day = 'morning';
      $item->time_of_day = ($start_hour >= self::$timeAfternoon) ? "afternoon" : $item->time_of_day;
      $item->time_of_day = ($start_hour >= self::$timeEvening) ? "evening" : $item->time_of_day;

      // Add timestamp.
      $format = 'l, F j, Y';
      $datetime = DrupalDateTime::createFromFormat($format, $item->date, $this->timezone);
      $datetime->setTime(0, 0, 0);
      $item->timestamp = $datetime->getTimestamp();

      // Add calendar data.
      $date_start = DrupalDateTime::createFromFormat('l, F j, Y g:ia', $item->date . ' ' . $item->start);
      $date_end = DrupalDateTime::createFromFormat('l, F j, Y g:ia', $item->date . ' ' . $item->end);
      $date_start = $date_start->format('Y-m-d H:i:s');
      $date_end = $date_end->format('Y-m-d H:i:s');
      $item->calendar = [
        'atc_date_start' => $date_start,
        'atc_date_end' => $date_end,
        'atc_timezone' => drupal_get_user_timezone(),
        'atc_title' => $item->title,
        'atc_description' => 'Visit ' . $item->category . ' with ' . strip_tags($item->instructor) . PHP_EOL . 'Class will take place at ' . $item->studio . '.',
        'atc_location' => $item->location,
        'atc_organizer' => $item->instructor,
      ];
    }

    $this->enrichedData = $data;
  }
private function enrichData ( ) { $ data = $ this -> rawData ; foreach ( $ data as & $ item ) { // Get address_1. $ item -> address_1 = sprintf ( '%s with %s' , trim ( $ item -> studio ) , trim ( $ item -> instructor ) ) ; // Get day. $ item -> day = $ item -> date ; // Get start and end time. Add To Calendar does not support All Day events. if ( $ item -> time == "All Day" ) { $ item -> start = "12:00am" ; $ item -> end = "11:59pm" ; } else { preg_match ( "/(.*)-(.*)/i" , $ item -> time , $ output ) ; $ item -> start = $ output [ 1 ] ; $ item -> end = $ output [ 2 ] ; } // Get time of day. $ datetime = new \ DateTime ( $ item -> start ) ; $ start_hour = $ datetime -> format ( 'G' ) ; $ item -> time_of_day = 'morning' ; $ item -> time_of_day = ( $ start_hour >= self :: $ timeAfternoon ) ? "afternoon" : $ item -> time_of_day ; $ item -> time_of_day = ( $ start_hour >= self :: $ timeEvening ) ? "evening" : $ item -> time_of_day ; // Add timestamp. $ format = 'l, F j, Y' ; $ datetime = DrupalDateTime :: createFromFormat ( $ format , $ item -> date , $ this -> timezone ) ; $ datetime -> setTime ( 0 , 0 , 0 ) ; $ item -> timestamp = $ datetime -> getTimestamp ( ) ; // Add calendar data. $ date_start = DrupalDateTime :: createFromFormat ( 'l, F j, Y g:ia' , $ item -> date . ' ' . $ item -> start ) ; $ date_end = DrupalDateTime :: createFromFormat ( 'l, F j, Y g:ia' , $ item -> date . ' ' . $ item -> end ) ; $ date_start = $ date_start -> format ( 'Y-m-d H:i:s' ) ; $ date_end = $ date_end -> format ( 'Y-m-d H:i:s' ) ; $ item -> calendar = [ 'atc_date_start' => $ date_start , 'atc_date_end' => $ date_end , 'atc_timezone' => drupal_get_user_timezone ( ) , 'atc_title' => $ item -> title , 'atc_description' => 'Visit ' . $ item -> category . ' with ' . strip_tags ( $ item -> instructor ) . PHP_EOL . 'Class will take place at ' . $ item -> studio . '.' , 'atc_location' => $ item -> location , 'atc_organizer' => $ item -> instructor , ] ; } $ this -> enrichedData = $ data ; }
Enriches data.
Enriches data .