public function getLocationsInfo() {
    $data = [];
    $cid = 'openy_activity_finder:locations_info';
    if ($cache = $this->cache->get($cid)) {
      $data = $cache->data;
    }
    else {
      $nids = $this->entityQuery
        ->get('node')
        ->condition('type', ['branch', 'camp'], 'IN')
        ->execute();
      $nids_chunked = array_chunk($nids, 20, TRUE);
      foreach ($nids_chunked as $chunked) {
        $locations = $this->entityTypeManager->getStorage('node')->loadMultiple($chunked);
        if (!empty($locations)) {
          foreach ($locations as $location) {
            $address = implode(', ', [
              $location->field_location_address->address_line1,
              $location->field_location_address->locality,
              $location->field_location_address->administrative_area,
              $location->field_location_address->postal_code,
            ]);
            $days = [];
            foreach ($location->field_branch_hours as $multi_hours) {
              $sub_hours = $multi_hours->getValue();
              $days = [
                [
                  0 => "Mon - Fri:",
                  1 => $sub_hours['hours_mon']
                ],
                [
                  0 => "Sat - Sun:",
                  1 => $sub_hours['hours_sat']
                ]
              ];
            }
            $data[$location->title->value] =[
              'type' => $location->bundle(),
              'address' => $address,
              'days' => $days,
              'email' => $location->field_location_email->value,
              'nid' => $location->id(),
              'phone' => $location->field_location_phone->value,
              'title' => $location->title->value
            ];
          }
        }
      }
      $expire = $this->time->getRequestTime() + self::CACHE_TTL;
      $this->cache->set($cid, $data, $expire);
    }

    return $data;
  }
public function getLocationsInfo() {
    $data = [];
    $cid = 'openy_activity_finder:locations_info';
    if ($cache = $this->cache->get($cid)) {
      $data = $cache->data;
    }
    else {
      $nids = $this->entityQuery
        ->get('node')
        ->condition('type', ['branch', 'camp'], 'IN')
        ->execute();
      $nids_chunked = array_chunk($nids, 20, TRUE);
      foreach ($nids_chunked as $chunked) {
        $locations = $this->entityTypeManager->getStorage('node')->loadMultiple($chunked);
        if (!empty($locations)) {
          foreach ($locations as $location) {
            $address = implode(', ', [
              $location->field_location_address->address_line1,
              $location->field_location_address->locality,
              $location->field_location_address->administrative_area,
              $location->field_location_address->postal_code,
            ]);
            $days = [];
            foreach ($location->field_branch_hours as $multi_hours) {
              $sub_hours = $multi_hours->getValue();
              $days = [
                [
                  0 => "Mon - Fri:",
                  1 => $sub_hours['hours_mon']
                ],
                [
                  0 => "Sat - Sun:",
                  1 => $sub_hours['hours_sat']
                ]
              ];
            }
            $data[$location->title->value] =[
              'type' => $location->bundle(),
              'address' => $address,
              'days' => $days,
              'email' => $location->field_location_email->value,
              'nid' => $location->id(),
              'phone' => $location->field_location_phone->value,
              'title' => $location->title->value
            ];
          }
        }
      }
      $expire = $this->time->getRequestTime() + self::CACHE_TTL;
      $this->cache->set($cid, $data, $expire);
    }

    return $data;
  }
public function getLocationsInfo ( ) { $ data = [ ] ; $ cid = 'openy_activity_finder:locations_info' ; if ( $ cache = $ this -> cache -> get ( $ cid ) ) { $ data = $ cache -> data ; } else { $ nids = $ this -> entityQuery -> get ( 'node' ) -> condition ( 'type' , [ 'branch' , 'camp' ] , 'IN' ) -> execute ( ) ; $ nids_chunked = array_chunk ( $ nids , 20 , TRUE ) ; foreach ( $ nids_chunked as $ chunked ) { $ locations = $ this -> entityTypeManager -> getStorage ( 'node' ) -> loadMultiple ( $ chunked ) ; if ( ! empty ( $ locations ) ) { foreach ( $ locations as $ location ) { $ address = implode ( ', ' , [ $ location -> field_location_address -> address_line1 , $ location -> field_location_address -> locality , $ location -> field_location_address -> administrative_area , $ location -> field_location_address -> postal_code , ] ) ; $ days = [ ] ; foreach ( $ location -> field_branch_hours as $ multi_hours ) { $ sub_hours = $ multi_hours -> getValue ( ) ; $ days = [ [ 0 => "Mon - Fri:" , 1 => $ sub_hours [ 'hours_mon' ] ] , [ 0 => "Sat - Sun:" , 1 => $ sub_hours [ 'hours_sat' ] ] ] ; } $ data [ $ location -> title -> value ] = [ 'type' => $ location -> bundle ( ) , 'address' => $ address , 'days' => $ days , 'email' => $ location -> field_location_email -> value , 'nid' => $ location -> id ( ) , 'phone' => $ location -> field_location_phone -> value , 'title' => $ location -> title -> value ] ; } } } $ expire = $ this -> time -> getRequestTime ( ) + self :: CACHE_TTL ; $ this -> cache -> set ( $ cid , $ data , $ expire ) ; } return $ data ; }
Get Locations Info.
Get Locations Info .