public function buildBranchHours(&$form, $parameters) {
    $markup = '';
    if (!$parameters['location'] || $parameters['location'] == 'All') {
      return $markup;
    }

    $locationOptions = $this->getLocationOptions();
    if (!empty($locationOptions['branches'][$parameters['location']])) {
      $id = $parameters['location'];
    }
    if (!empty($locationOptions['camps'][$parameters['location']])) {
      $id = $parameters['location'];
    }
    if (isset($id)) {
      $branch_hours = [];
      $timezone = drupal_get_user_timezone();
      $date = DrupalDateTime::createFromFormat('m/d/Y', $parameters['date'], $timezone);
      $date = strtolower($date->format('D'));
      /* @var $location \Drupal\node\Entity\Node */
      if ($location = $this->entityTypeManager->getStorage('node')->load($id)) {
        $form['#cache']['tags'] = !empty($form['#cache']['tags']) ? $form['#cache']['tags'] : [];
        $form['#cache']['tags'] = $form['#cache']['tags'] + $location->getCacheTags();
        if ($location->hasField('field_branch_hours')) {
          $field_branch_hours = $location->field_branch_hours;
          foreach ($field_branch_hours as $multi_hours) {
            $sub_hours = $multi_hours->getValue();
            if (!empty($sub_hours['hours_' . $date])) {
              $branch_hours['main']['hours'][] = $sub_hours['hours_' . $date];
            }
          }
        }
      }
    }
    if (!empty($branch_hours)) {
      $markup = [
        '#theme' => 'openy_branch_hours_block',
        '#branch_hours' => $branch_hours,
      ];
    }

    return $markup;
  }
public function buildBranchHours(&$form, $parameters) {
    $markup = '';
    if (!$parameters['location'] || $parameters['location'] == 'All') {
      return $markup;
    }

    $locationOptions = $this->getLocationOptions();
    if (!empty($locationOptions['branches'][$parameters['location']])) {
      $id = $parameters['location'];
    }
    if (!empty($locationOptions['camps'][$parameters['location']])) {
      $id = $parameters['location'];
    }
    if (isset($id)) {
      $branch_hours = [];
      $timezone = drupal_get_user_timezone();
      $date = DrupalDateTime::createFromFormat('m/d/Y', $parameters['date'], $timezone);
      $date = strtolower($date->format('D'));
      /* @var $location \Drupal\node\Entity\Node */
      if ($location = $this->entityTypeManager->getStorage('node')->load($id)) {
        $form['#cache']['tags'] = !empty($form['#cache']['tags']) ? $form['#cache']['tags'] : [];
        $form['#cache']['tags'] = $form['#cache']['tags'] + $location->getCacheTags();
        if ($location->hasField('field_branch_hours')) {
          $field_branch_hours = $location->field_branch_hours;
          foreach ($field_branch_hours as $multi_hours) {
            $sub_hours = $multi_hours->getValue();
            if (!empty($sub_hours['hours_' . $date])) {
              $branch_hours['main']['hours'][] = $sub_hours['hours_' . $date];
            }
          }
        }
      }
    }
    if (!empty($branch_hours)) {
      $markup = [
        '#theme' => 'openy_branch_hours_block',
        '#branch_hours' => $branch_hours,
      ];
    }

    return $markup;
  }
public function buildBranchHours ( & $ form , $ parameters ) { $ markup = '' ; if ( ! $ parameters [ 'location' ] || $ parameters [ 'location' ] == 'All' ) { return $ markup ; } $ locationOptions = $ this -> getLocationOptions ( ) ; if ( ! empty ( $ locationOptions [ 'branches' ] [ $ parameters [ 'location' ] ] ) ) { $ id = $ parameters [ 'location' ] ; } if ( ! empty ( $ locationOptions [ 'camps' ] [ $ parameters [ 'location' ] ] ) ) { $ id = $ parameters [ 'location' ] ; } if ( isset ( $ id ) ) { $ branch_hours = [ ] ; $ timezone = drupal_get_user_timezone ( ) ; $ date = DrupalDateTime :: createFromFormat ( 'm/d/Y' , $ parameters [ 'date' ] , $ timezone ) ; $ date = strtolower ( $ date -> format ( 'D' ) ) ; /* @var $location \Drupal\node\Entity\Node */ if ( $ location = $ this -> entityTypeManager -> getStorage ( 'node' ) -> load ( $ id ) ) { $ form [ '#cache' ] [ 'tags' ] = ! empty ( $ form [ '#cache' ] [ 'tags' ] ) ? $ form [ '#cache' ] [ 'tags' ] : [ ] ; $ form [ '#cache' ] [ 'tags' ] = $ form [ '#cache' ] [ 'tags' ] + $ location -> getCacheTags ( ) ; if ( $ location -> hasField ( 'field_branch_hours' ) ) { $ field_branch_hours = $ location -> field_branch_hours ; foreach ( $ field_branch_hours as $ multi_hours ) { $ sub_hours = $ multi_hours -> getValue ( ) ; if ( ! empty ( $ sub_hours [ 'hours_' . $ date ] ) ) { $ branch_hours [ 'main' ] [ 'hours' ] [ ] = $ sub_hours [ 'hours_' . $ date ] ; } } } } } if ( ! empty ( $ branch_hours ) ) { $ markup = [ '#theme' => 'openy_branch_hours_block' , '#branch_hours' => $ branch_hours , ] ; } return $ markup ; }
Build Branch Hours.
Build Branch Hours .